import { CrowdinApi, DownloadLink, PaginationOptions, PatchRequest, ResponseList, ResponseObject, Status } from '../core'; import { ProjectsGroupsModel } from '../projectsGroups'; /** * Translators can work with entirely untranslated project or you can pre-translate the files to ease the translations process. * * Use API to pre-translate files via Machine Translation (MT) or Translation Memory (TM), upload your existing translations, and download translations correspondingly. * Pre-translate and build are asynchronous operations and shall be completed with sequence of API methods. */ export declare class Translations extends CrowdinApi { /** * @requiredScope project.translation:read * @param projectId project identifier * @param options optional parameters for the request * @see https://developer.crowdin.com/api/v2/#operation/api.projects.pre-translations.getMany */ listPreTranslations(projectId: number, options?: TranslationsModel.ListPreTranslationsOptions): Promise>>; /** * @param projectId project identifier * @param preTranslationId pre translation identifier * @see https://developer.crowdin.com/api/v2/#tag/Translations/paths/~1projects~1{projectId}~1pre-translations~1{preTranslationId}/get */ preTranslationStatus(projectId: number, preTranslationId: string): Promise>>; /** * @requiredScope project.translation:write * @param projectId project identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.pre-translations.post */ applyPreTranslation(projectId: number, request: TranslationsModel.PreTranslateRequest | TranslationsModel.PreTranslateStringsRequest | TranslationsModel.PreTranslateByTaskRequest): Promise>>; /** * @requiredScope project.translation:write * @param projectId project identifier * @param preTranslationId pre translation identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.pre-translations.patch */ editPreTranslation(projectId: number, preTranslationId: string, request: PatchRequest[]): Promise>>; /** * @requiredScope project.translation:write * @param projectId project identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#tag/Translations/operation/api.projects.pre-translations.patchBatch */ editPreTranslations(projectId: number, request: PatchRequest[]): Promise>>; /** * @requiredScope project.translation:write * @param projectId project identifier * @param preTranslationId pre translation identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.pre-translations.report.getReport */ getPreTranslationReport(projectId: number, preTranslationId: string): Promise>; /** * @requiredScope project.source.file:read * @param projectId project identifier * @param directoryId directory identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.builds.directories.post */ buildProjectDirectoryTranslation(projectId: number, directoryId: number, request?: TranslationsModel.BuildProjectDirectoryTranslationRequest): Promise>; /** * @requiredScope project.source.file:read * @param projectId project identifier * @param fileId file identifier * @param request request body * @param eTag 'If-None-Match' header * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.builds.files.post */ buildProjectFileTranslation(projectId: number, fileId: number, request: TranslationsModel.BuildProjectFileTranslationRequest, eTag?: string): Promise>; /** * @requiredScope project.translation:read * @param projectId project identifier * @param options optional parameters for the request * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.builds.getMany */ listProjectBuilds(projectId: number, options?: TranslationsModel.ListProjectBuildsOptions): Promise>; /** * @requiredScope project.translation:read * @param projectId project identifier * @param branchId branch identifier * @param limit maximum number of items to retrieve (default 25) * @param offset starting offset in the collection (default 0) * @deprecated optional parameters should be passed through an object * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.builds.getMany */ listProjectBuilds(projectId: number, branchId?: number, limit?: number, offset?: number): Promise>; /** * @requiredScope project.translation:read * @param projectId project identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.builds.post */ buildProject(projectId: number, request?: TranslationsModel.BuildRequest | TranslationsModel.PseudoBuildRequest): Promise>; /** * @requiredScope project.translation:write * @deprecated Use {@link Translations.importTranslations} instead * * @param projectId project identifier * @param languageId language identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.postOnLanguage */ uploadTranslation(projectId: number, languageId: string, request: TranslationsModel.UploadTranslationRequest): Promise>; /** * @requiredScope project.translation:write * @deprecated Use {@link Translations.importTranslations} instead * * @param projectId project identifier * @param languageId language identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.postOnLanguage */ uploadTranslationStrings(projectId: number, languageId: string, request: TranslationsModel.UploadTranslationStringsRequest): Promise>; /** * @requiredScope project.translation:read * @param projectId project identifier * @param buildId build identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.builds.download.download */ downloadTranslations(projectId: number, buildId: number): Promise>; /** * @requiredScope project.translation:read * @param projectId project identifier * @param buildId build identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.builds.get */ checkBuildStatus(projectId: number, buildId: number): Promise>; /** * @requiredScope project.translation:read * @param projectId project identifier * @param buildId build identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.builds.delete */ cancelBuild(projectId: number, buildId: number): Promise; /** * @requiredScope project.translation:read * @param projectId project identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.exports.post */ exportProjectTranslation(projectId: number, request: TranslationsModel.ExportProjectTranslationRequest): Promise>; /** * @requiredScope project.translation:write * @param projectId project identifier * @param request request body * @see https://support.crowdin.com/developer/api/v2/#tag/Translations/operation/api.projects.translations.imports */ importTranslations(projectId: number, request: TranslationsModel.ImportTranslationsRequest | TranslationsModel.ImportTranslationsStringsRequest): Promise>>; /** * @requiredScope project.translation:read * @param projectId project identifier * @param importId import identifier * @see https://support.crowdin.com/developer/api/v2/#tag/Translations/operation/api.projects.translations.imports.get */ importTranslationsStatus(projectId: number, importId: string): Promise>>; /** * @requiredScope project.translation:read * @param projectId project identifier * @param importId import identifier * @see https://support.crowdin.com/developer/api/v2/#tag/Translations/operation/api.projects.translations.imports.report.get */ importTranslationsReport(projectId: number, importId: string): Promise>; /** * @requiredScope none * @param projectId project identifier * @param request request body * @see https://support.crowdin.com/developer/api/v2/#tag/Translations/operation/api.projects.translations.validate-qa-checks.post */ validateQaChecks(projectId: number, request: TranslationsModel.ValidateQaChecksRequest[]): Promise>; /** * @requiredScope project.translation:read * @param options optional parameters for the request * @see https://developer.crowdin.com/enterprise/api/v2/#operation/api.translations.getMany */ listTranslations(options: TranslationsModel.ListTranslationsOptions): Promise>; } export declare namespace TranslationsModel { interface PreTranslateRequest { languageIds: string[]; fileIds?: number[]; directoryIds?: number[]; branchIds?: number[]; method?: Method; priority?: Priority; engineId?: number; aiPromptId?: number; autoApproveOption?: AutoApproveOption; duplicateTranslations?: boolean; skipApprovedTranslations?: boolean; /** * @deprecated Use {@link scope} instead */ translateUntranslatedOnly?: boolean; scope?: Scope; translationModifiedBefore?: string | null; translationModifiedAfter?: string | null; replaceTranslationsOption?: ReplaceTranslationsOption; resetApprovalStatus?: boolean; notifyOnCompletion?: boolean; translateWithPerfectMatchOnly?: boolean; /** * Enterprise only */ minimumMatchRatio?: number; fallbackLanguages?: { languageId?: string[]; }; labelIds?: number[]; excludeLabelIds?: number[]; sourceLanguageId?: string; customInstruction?: string; } interface PreTranslateStringsRequest { languageIds: string[]; branchIds?: number[]; method?: Method; priority?: Priority; engineId?: number; aiPromptId?: number; autoApproveOption?: AutoApproveOption; duplicateTranslations?: boolean; skipApprovedTranslations?: boolean; /** * @deprecated Use {@link scope} instead */ translateUntranslatedOnly?: boolean; scope?: Scope; translationModifiedBefore?: string | null; translationModifiedAfter?: string | null; replaceTranslationsOption?: ReplaceTranslationsOption; resetApprovalStatus?: boolean; notifyOnCompletion?: boolean; translateWithPerfectMatchOnly?: boolean; /** * Enterprise only */ minimumMatchRatio?: number; fallbackLanguages?: { languageId: string[]; }; labelIds?: number[]; excludeLabelIds?: number[]; sourceLanguageId?: string; customInstruction?: string; } interface PreTranslateByTaskRequest { taskId: number; method?: Method; priority?: Priority; engineId?: number; aiPromptId?: number; autoApproveOption?: AutoApproveOption; duplicateTranslations?: boolean; skipApprovedTranslations?: boolean; scope?: Scope; translationModifiedBefore?: string | null; translationModifiedAfter?: string | null; replaceTranslationsOption?: ReplaceTranslationsOption; resetApprovalStatus?: boolean; notifyOnCompletion?: boolean; translateWithPerfectMatchOnly?: boolean; /** * Enterprise only */ minimumMatchRatio?: number; fallbackLanguages?: { languageId?: string[]; }; sourceLanguageId?: string; customInstruction?: string; } interface ListPreTranslationsOptions extends PaginationOptions { orderBy?: string; } interface BuildProjectDirectoryTranslationRequest { targetLanguageIds?: string[]; skipUntranslatedStrings?: boolean; skipUntranslatedFiles?: boolean; preserveFolderHierarchy?: boolean; exportStringsThatPassedWorkflow?: boolean; exportWithMinApprovalsCount?: number; exportApprovedOnly?: boolean; } interface BuildProjectDirectoryTranslationResponse { id: number; projectId: number; status: BuildStatus; progress: number; createdAt: string | null; updatedAt: string | null; finishedAt: string | null; attributes?: BuildProjectDirectoryTranslationAttributes; } interface BuildProjectDirectoryTranslationAttributes { directoryId: number | null; targetLanguageIds: string[]; skipUntranslatedStrings: boolean; skipUntranslatedFiles: boolean; preserveFolderHierarchy?: boolean; exportApprovedOnly?: boolean; exportWithMinApprovalsCount?: number; exportStringsThatPassedWorkflow?: boolean; } type BuildStatus = 'created' | 'inProgress' | 'canceled' | 'failed' | 'finished'; interface BuildProjectFileTranslationRequest { targetLanguageId: string; /** * @deprecated Use {@link Translations.exportProjectTranslation} instead */ exportAsXliff?: boolean; skipUntranslatedStrings?: boolean; skipUntranslatedFiles?: boolean; exportApprovedOnly?: boolean; exportWithMinApprovalsCount?: number; exportStringsThatPassedWorkflow?: boolean; } interface BuildProjectFileTranslationResponse extends DownloadLink { etag: string; } interface PreTranslationStatusAttributes { languageIds: string[]; fileIds: number[]; directoryIds: number[]; branchIds: number[]; method: Method; autoApproveOption: AutoApproveOption; duplicateTranslations: boolean; skipApprovedTranslations: boolean; /** * @deprecated Use {@link scope} instead */ translateUntranslatedOnly: boolean; translateWithPerfectMatchOnly: boolean; priority: Priority; taskId?: number; scope?: Scope; translationModifiedBefore?: string | null; translationModifiedAfter?: string | null; replaceTranslationsOption?: ReplaceTranslationsOption; resetApprovalStatus?: boolean; notifyOnCompletion?: boolean; /** * Enterprise only */ minimumMatchRatio?: number; } type Method = 'tm' | 'mt' | 'ai'; type AutoApproveOption = 'all' | 'exceptAutoSubstituted' | 'perfectMatchOnly' | 'perfectMatchApprovedOnly' | 'none'; type Scope = 'untranslated' | 'translated' | 'all'; type ReplaceTranslationsOption = 'none' | 'autoTranslated' | 'all'; type Priority = 'low' | 'normal' | 'high'; type CharTransformation = 'asian' | 'european' | 'arabic' | 'cyrillic'; interface Build { id: number; projectId: number; status: BuildStatus; progress: number; attributes: Attribute; createdAt: string | null; updatedAt: string | null; finishedAt: string | null; error?: { message: string; }; } interface Attribute { branchId: number | null; directoryId: number | null; targetLanguageIds: string[]; skipUntranslatedStrings: boolean; skipUntranslatedFiles: boolean; exportApprovedOnly: boolean; exportWithMinApprovalsCount: number; exportStringsThatPassedWorkflow: boolean; pseudo?: boolean; prefix?: string; suffix?: string; lengthTransformation?: number; charTransformation?: CharTransformation; } interface BuildRequest { branchId?: number; targetLanguageIds?: string[]; skipUntranslatedStrings?: boolean; skipUntranslatedFiles?: boolean; exportApprovedOnly?: boolean; exportWithMinApprovalsCount?: number; exportStringsThatPassedWorkflow?: boolean; } interface PseudoBuildRequest { pseudo: boolean; branchId?: number; prefix?: string; suffix?: string; lengthTransformation?: number; charTransformation?: CharTransformation; } interface UploadTranslationRequest { storageId: number; fileId?: number; importEqSuggestions?: boolean; autoApproveImported?: boolean; translateHidden?: boolean; addToTm?: boolean; } interface UploadTranslationStringsRequest { storageId: number; branchId?: number; importEqSuggestions?: boolean; autoApproveImported?: boolean; translateHidden?: boolean; addToTm?: boolean; } interface UploadTranslationResponse { projectId: number; storageId: number; languageId: string; fileId: number; info?: { imported: { strings: number; words: number; }; approved: { strings: number; words: number; }; skipped: { translation_eq_source: number; qa_check: number; hidden_strings: number; ai_error: number; }; skippedQaCheckCategories: Record; }; } interface UploadTranslationStringsResponse { projectId: number; storageId: number; languageId: string; branchId: number; } interface ExportProjectTranslationRequest { targetLanguageId: string; format?: string; labelIds?: number[]; branchIds?: number[]; directoryIds?: number[]; fileIds?: number[]; skipUntranslatedStrings?: boolean; skipUntranslatedFiles?: boolean; exportApprovedOnly?: boolean; exportWithMinApprovalsCount?: number; exportStringsThatPassedWorkflow?: boolean; } interface ListProjectBuildsOptions extends PaginationOptions { branchId?: number; } interface PreTranslationReport { languages: TargetLanguage[]; preTranslateType: Method; } interface TargetLanguage { id: string; files: TargetLanguageFile[]; skipped: SkippedInfo; skippedQaCheckCategories: ProjectsGroupsModel.CheckCategories; } interface TargetLanguageFile { id: number; statistics: TargetLanguageFileStatistics; } interface TargetLanguageFileStatistics { phrases: number; words: number; } interface SkippedInfo { [key: string]: any; } interface ImportTranslationsRequest { storageId: number; languageIds?: string[]; fileId?: number; importEqSuggestions?: boolean; autoApproveImported?: boolean; translateHidden?: boolean; addToTm?: boolean; } interface ImportTranslationsStringsRequest { storageId: number; languageIds?: string[]; branchId: number; importEqSuggestions?: boolean; autoApproveImported?: boolean; translateHidden?: boolean; addToTm?: boolean; importOptions?: { scheme?: { none?: number; identifier?: number; sourceOrTranslation?: number; translation?: number; [languageCode: string]: number | undefined; }; }; } interface ImportTranslationsStatusAttributes { storageId: number; fileId: number; importEqSuggestions: boolean; autoApproveImported: boolean; translateHidden: boolean; addToTm: boolean; languageIds: string[]; } interface ImportTranslationsStringsStatusAttributes { storageId: number; branchId: number; importEqSuggestions: boolean; autoApproveImported: boolean; translateHidden: boolean; addToTm: boolean; languageIds: string[]; } interface ImportTranslationsReport { languages: { id: string; files: { id: number; statistics: { phrases: number; words: number; }; }[]; skipped: { translationEqSource: number; hiddenStrings: number; qaCheck: number; }; skippedQaCheckCategories: { size: number; duplicate: number; }; }[]; } interface ImportTranslationsStringsReport { languages: { id: string; branches: { id: number; statistics: { phrases: number; words: number; }; }[]; skipped: { translationEqSource: number; hiddenStrings: number; qaCheck: number; }; skippedQaCheckCategories: { size: number; duplicate: number; }; }[]; } interface ListTranslationsOptions extends PaginationOptions { filter: string; projectIds?: number[]; userId?: number; languageIds?: string[]; denormalizePlaceholders?: 0 | 1; } interface TranslationSearchResult { id: number; text: string; pluralCategoryName?: string; projectId: number; stringId: number; languageId: string; user?: { id: number; username: string; fullName: string; avatarUrl: string; }; rating?: number; provider: string | null; providerId?: number | null; isPreTranslated: boolean; matchRate: number | null; matchType: string | null; createdAt: string; /** * Enterprise only */ workflowStepId?: number; } interface ValidateQaChecksRequest { stringId: number; languageId: string; text: string; pluralCategoryName?: string; } interface QaCheckValidationResult { stringId: number; languageId: string; category: string; categoryDescription: string; validation: string; validationDescription: string; pluralId: number; pluralCategoryName: string; text: string; translation: string; } }