Skip to content

Commit

Permalink
docs: download translations
Browse files Browse the repository at this point in the history
  • Loading branch information
yevheniyJ committed Jun 11, 2023
1 parent 81c9fdb commit 1e7f0a3
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [Create TM](#create-tm)
- [Create Glossary](#create-glossary)
- [Pre-Translate project](#pre-translate-project)
- [Download translations](#download-translations)

---

Expand Down Expand Up @@ -168,3 +169,31 @@ async function preTranslateProject(projectId: number, languageIds: string[], fil
preTranslateProject(123, ['uk'], [456]);

```

## Download translations

```typescript
import crowdin from '@crowdin/crowdin-api-client';

const { translationsApi } = new crowdin({
token: 'token',
organization: 'org'
});

async function downloadTranslations(projectId: number): Promise<string> {
const result = await translationsApi.buildProject(projectId);

let status = result.data.status;
while (status !== 'finished') {
const progress = await translationsApi.checkBuildStatus(projectId, result.data.id);
status = progress.data.status;
}

const translations = await translationsApi.downloadTranslations(projectId, result.data.id);

return translations.data.url;
}

downloadTranslations(123);

```

0 comments on commit 1e7f0a3

Please sign in to comment.