From a2d4243bc3437ee407e47180dc08b11f88e7254f Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Thu, 25 Mar 2021 04:35:45 +0100 Subject: [PATCH] Allow to pull languages without proofreading --- config.js | 2 +- packages/app/components/i18n/localeFlags.ts | 2 ++ packages/scripts/i18n-crowdin.ts | 14 ++++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/config.js b/config.js index ff7ed81..450f19b 100644 --- a/config.js +++ b/config.js @@ -16,6 +16,6 @@ module.exports = { filePath: 'accounts/site.json', sourceLang: 'en', basePath: `${__dirname}/packages/app/i18n`, - minApproved: 80, // Minimal ready percent before translation can be published + minTranslated: 80, // Minimal ready percent before translation can be published }, }; diff --git a/packages/app/components/i18n/localeFlags.ts b/packages/app/components/i18n/localeFlags.ts index c0151af..68f8f08 100644 --- a/packages/app/components/i18n/localeFlags.ts +++ b/packages/app/components/i18n/localeFlags.ts @@ -10,6 +10,8 @@ const localeToCountryCode: Record = { sr: 'rs', zh: 'cn', cs: 'cz', + fil: 'ph', + he: 'il', }; const SUPPORTED_LANGUAGES: ReadonlyArray = Object.keys(supportedLocales); diff --git a/packages/scripts/i18n-crowdin.ts b/packages/scripts/i18n-crowdin.ts index fc2f7ff..7425a3c 100644 --- a/packages/scripts/i18n-crowdin.ts +++ b/packages/scripts/i18n-crowdin.ts @@ -28,7 +28,7 @@ const CROWDIN_FILE_PATH = config.filePath; const SOURCE_LANG = config.sourceLang; const LANG_DIR = config.basePath; const INDEX_FILE_NAME = 'index.js'; -const MIN_RELEASE_PROGRESS = config.minApproved; +const MIN_RELEASE_PROGRESS = config.minTranslated; const crowdin = new Crowdin({ token: config.apiKey, @@ -43,6 +43,7 @@ const releasedLocales: ReadonlyArray = ['be', 'fr', 'id', 'pt', 'ru', 'u * Map Crowdin locales into our internal locales representation */ const LOCALES_MAP: Record = { + 'es-ES': 'es', 'pt-BR': 'pt', 'zh-CN': 'zh', }; @@ -54,6 +55,7 @@ const LOCALES_MAP: Record = { const NATIVE_NAMES_MAP: Record = { be: 'Беларуская', cs: 'Čeština', + fil: 'Wikang Filipino', id: 'Bahasa Indonesia', lt: 'Lietuvių', pl: 'Polski', @@ -67,6 +69,7 @@ const NATIVE_NAMES_MAP: Record = { * This arrays allows us to override Crowdin English languages names */ const ENGLISH_NAMES_MAP: Record = { + fil: 'Filipino', pt: 'Portuguese, Brazilian', sr: 'Serbian', zh: 'Simplified Chinese', @@ -225,7 +228,7 @@ async function pull(): Promise { } console.log('Pulling translation progress...'); - const { data: translationProgress } = await crowdin.translationStatusApi.getFileProgress(PROJECT_ID, fileId, 100); + const { data: fileProgress } = await crowdin.translationStatusApi.getFileProgress(PROJECT_ID, fileId, 100); const localesToPull: Array = []; const indexFileEntries: Record = { @@ -238,16 +241,16 @@ async function pull(): Promise { }, }; - translationProgress.forEach(({ data: { languageId, approvalProgress } }) => { + fileProgress.forEach(({ data: { languageId, translationProgress } }) => { const locale = toInternalLocale(languageId); - if (releasedLocales.includes(locale) || approvalProgress >= MIN_RELEASE_PROGRESS) { + if (releasedLocales.includes(locale) || translationProgress >= MIN_RELEASE_PROGRESS) { localesToPull.push(languageId); indexFileEntries[locale] = { code: locale, name: NATIVE_NAMES_MAP[locale] || iso639.getNativeName(locale), englishName: ENGLISH_NAMES_MAP[locale] || iso639.getName(locale), - progress: approvalProgress, + progress: translationProgress, isReleased: releasedLocales.includes(locale), }; } @@ -268,7 +271,6 @@ async function pull(): Promise { data: { url }, } = await crowdin.translationsApi.buildProjectFileTranslation(PROJECT_ID, fileId, { targetLanguageId: languageId, - exportApprovedOnly: true, }); const { data: fileContents } = await axios.get(url, {