Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/translations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@ export class Translations extends CrowdinApi {
return this.patch(url, request, this.defaultConfig());
}

/**
* @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<ResponseList<Status<TranslationsModel.PreTranslationStatusAttributes>>> {
const url = `${this.url}/projects/${projectId}/pre-translations`;
return this.patch(url, request, this.defaultConfig());
}

/**
* @param projectId project identifier
* @param preTranslationId pre translation identifier
Expand Down Expand Up @@ -389,12 +402,15 @@ export namespace TranslationsModel {
skipApprovedTranslations: boolean;
translateUntranslatedOnly: boolean;
translateWithPerfectMatchOnly: boolean;
priority: Priority;
}

export type Method = 'tm' | 'mt' | 'ai';

export type AutoApproveOption = 'all' | 'exceptAutoSubstituted' | 'perfectMatchOnly' | 'none';

export type Priority = 'low' | 'normal' | 'high';

export type CharTransformation = 'asian' | 'european' | 'arabic' | 'cyrillic';

export interface Build {
Expand Down
36 changes: 36 additions & 0 deletions tests/translations/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,30 @@ describe('Translations API', () => {
identifier: preTranslationId,
},
})
.patch(
`/projects/${projectId}/pre-translations`,
[
{
op: 'replace',
path: `/${preTranslationId}/status`,
value: sampleStatus,
},
],
{
reqheaders: {
Authorization: `Bearer ${api.token}`,
},
},
)
.reply(200, {
data: [
{
data: {
identifier: preTranslationId,
},
},
],
})
.get(`/projects/${projectId}/pre-translations/${preTranslationId}/report`, undefined, {
reqheaders: {
Authorization: `Bearer ${api.token}`,
Expand Down Expand Up @@ -384,6 +408,18 @@ describe('Translations API', () => {
expect(preTranslation.data.identifier).toBe(preTranslationId);
});

it('Edit Pre-translations (batch)', async () => {
const preTranslations = await api.editPreTranslations(projectId, [
{
op: 'replace',
path: `/${preTranslationId}/status`,
value: sampleStatus,
},
]);
expect(preTranslations.data.length).toBe(1);
expect(preTranslations.data[0].data.identifier).toBe(preTranslationId);
});

it('Get Pre-translation Report', async () => {
const report = await api.getPreTranslationReport(projectId, preTranslationId);
expect(report.data.languages.length).toBe(1);
Expand Down
Loading