import { CrowdinApi , DownloadLink , ResponseList , ResponseObject , Status } from '../core' ; export class Translations extends CrowdinApi { param projectId param request applyPreTranslation ( projectId , request ) { const url = `${ this . url }/projects/${ projectId }/pre-translations` ; return this . post ( url , request , this . defaultConfig ( ) ) ; } param projectId param preTranslationId preTranslationStatus ( projectId , preTranslationId ) { const url = `${ this . url }/projects/${ projectId }/pre-translations/${ preTranslationId }` ; return this . get ( url , this . defaultConfig ( ) ) ; } param projectId param directoryId param request buildProjectDirectoryTranslation ( projectId , directoryId , request ) { const url = `${ this . url }/projects/${ projectId }/translations/builds/directories/${ directoryId }` ; const config = this . defaultConfig ( ) ; return this . post ( url , request , config ) ; } param projectId param fileId param request param eTag buildProjectFileTranslation ( projectId , fileId , request , eTag ? ) { const url = `${ this . url }/projects/${ projectId }/translations/builds/files/${ fileId }` ; const config = this . defaultConfig ( ) ; if ( ! ! eTag ) { config . headers [ 'If-None-Match' ] = eTag ; } return this . post ( url , request , config ) ; } param projectId param branchId param limit param offset listProjectBuilds ( projectId , branchId ? , limit ? , offset ? ) { let url = `${ this . url }/projects/${ projectId }/translations/builds` ; url = this . addQueryParam ( url , 'branchId' , branchId ) ; return this . getList ( url , limit , offset ) ; } param projectId param request buildProject ( projectId , request = { } ) { const url = `${ this . url }/projects/${ projectId }/translations/builds` ; return this . post ( url , request , this . defaultConfig ( ) ) ; } param projectId param buildId downloadTranslations ( projectId , buildId ) { const url = `${ this . url }/projects/${ projectId }/translations/builds/${ buildId }/download` ; return this . get ( url , this . defaultConfig ( ) ) ; } param projectId param buildId checkBuildStatus ( projectId , buildId ) { const url = `${ this . url }/projects/${ projectId }/translations/builds/${ buildId }` ; return this . get ( url , this . defaultConfig ( ) ) ; } param projectId param buildId cancelBuild ( projectId , buildId ) { const url = `${ this . url }/projects/${ projectId }/translations/builds/${ buildId }` ; return this . delete ( url , this . defaultConfig ( ) ) ; } param projectId param languageId param request uploadTranslation ( projectId , languageId , request ) { const url = `${ this . url }/projects/${ projectId }/translations/${ languageId }` ; return this . post ( url , request , this . defaultConfig ( ) ) ; } param projectId param request exportProjectTranslation ( projectId , request ) { const url = `${ this . url }/projects/${ projectId }/translations/exports` ; return this . post ( url , request , this . defaultConfig ( ) ) ; } } export namespace TranslationsModel { export interface PreTranslateRequest { languageIds : string [ ] ; fileIds : number [ ] ; method ? : Method ; engineId ? : number ; autoApproveOption ? : AutoApproveOption ; duplicateTranslations ? : boolean ; translateUntranslatedOnly ? : boolean ; translateWithPerfectMatchOnly ? : boolean ; markAddedTranslationsAsDone ? : boolean ; } export interface BuildProjectDirectoryTranslationRequest { targetLanguageIds ? : string [ ] ; skipUntranslatedStrings ? : boolean ; skipUntranslatedFiles ? : boolean ; exportApprovedOnly ? : boolean ; exportWithMinApprovalsCount ? : number ; } export interface BuildProjectDirectoryTranslationResponse { id : number ; projectId : number ; status : BuildStatus ; progress : number ; } export enum BuildStatus { CREATED = 'created' , IN_PROGRESS = 'inProgress' , CANCELED = 'canceled' , FAILED = 'failed' , FINISHED = 'finished' } export interface BuildProjectFileTranslationRequest { targetLanguageId : string ; exportAsXliff ? : boolean ; skipUntranslatedStrings ? : boolean ; skipUntranslatedFiles ? : boolean ; exportApprovedOnly ? : boolean ; exportWithMinApprovalsCount ? : number ; } export interface BuildProjectFileTranslationResponse extends DownloadLink { etag : string ; } export interface PreTranslationStatusAttributes { languageIds : string [ ] ; fileIds : number [ ] ; method : Method ; autoApproveOption : AutoApproveOption ; duplicateTranslations : boolean ; translateUntranslatedOnly : boolean ; translateWithPerfectMatchOnly : boolean ; } export enum Method { TM = 'tm' , MT = 'mt' } export enum AutoApproveOption { ALL = 'all' , EXCEPT_AUTO_SUBSTITUTED = 'exceptAutoSubstituted' , PERFECT_MATCH_ONLY = 'perfectMatchOnly' , NONE = 'none' } export enum CharTransformation { ASIAN = 'asian' , EUROPEAN = 'european' , ARABIC = 'arabic' , CYRILLIC = 'cyrillic' } export interface Build { id : number ; status : string ; progress : number ; attributes : Attribute [ ] ; } export interface Attribute { projectId : number ; branchId : number ; targetLanguagesId : string [ ] ; skipUntranslatedStrings : boolean ; exportApprovedOnly : boolean ; exportWithMinApprovalsCount : number ; skipUntranslatedFiles : boolean ; } export interface BuildRequest { branchId ? : number ; targetLanguageIds ? : string [ ] ; skipUntranslatedStrings ? : boolean ; skipUntranslatedFiles ? : boolean ; exportApprovedOnly ? : boolean ; exportWithMinApprovalsCount ? : number ; } export interface PseudoBuildRequest { pseudo : boolean ; branchId ? : number ; prefix ? : string ; suffix ? : string ; lengthTransformation ? : number ; charTransformation ? : CharTransformation ; } export interface UploadTranslationRequest { storageId : number ; fileId : number ; importEqSuggestions ? : boolean ; autoApproveImported ? : boolean ; markAddedTranslationsAsDone ? : boolean ; translateHidden ? : boolean ; } export interface UploadTranslationResponse { projectId : number ; storageId : number ; languageId : string ; fileId : number ; } export interface ExportProjectTranslationRequest { targetLanguageId : string ; format ? : string ; labelIds ? : number [ ] ; branchIds ? : number [ ] ; directoryIds ? : number [ ] ; fileIds ? : number [ ] ; skipUntranslatedStrings ? : boolean ; skipUntranslatedFiles ? : boolean ; exportWithMinApprovalsCount ? : number ; } }