mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-23 00:22:57 +05:30
Allow to pull languages without proofreading
This commit is contained in:
parent
73caa34acc
commit
a2d4243bc3
@ -16,6 +16,6 @@ module.exports = {
|
|||||||
filePath: 'accounts/site.json',
|
filePath: 'accounts/site.json',
|
||||||
sourceLang: 'en',
|
sourceLang: 'en',
|
||||||
basePath: `${__dirname}/packages/app/i18n`,
|
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
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -10,6 +10,8 @@ const localeToCountryCode: Record<string, string> = {
|
|||||||
sr: 'rs',
|
sr: 'rs',
|
||||||
zh: 'cn',
|
zh: 'cn',
|
||||||
cs: 'cz',
|
cs: 'cz',
|
||||||
|
fil: 'ph',
|
||||||
|
he: 'il',
|
||||||
};
|
};
|
||||||
const SUPPORTED_LANGUAGES: ReadonlyArray<string> = Object.keys(supportedLocales);
|
const SUPPORTED_LANGUAGES: ReadonlyArray<string> = Object.keys(supportedLocales);
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ const CROWDIN_FILE_PATH = config.filePath;
|
|||||||
const SOURCE_LANG = config.sourceLang;
|
const SOURCE_LANG = config.sourceLang;
|
||||||
const LANG_DIR = config.basePath;
|
const LANG_DIR = config.basePath;
|
||||||
const INDEX_FILE_NAME = 'index.js';
|
const INDEX_FILE_NAME = 'index.js';
|
||||||
const MIN_RELEASE_PROGRESS = config.minApproved;
|
const MIN_RELEASE_PROGRESS = config.minTranslated;
|
||||||
|
|
||||||
const crowdin = new Crowdin({
|
const crowdin = new Crowdin({
|
||||||
token: config.apiKey,
|
token: config.apiKey,
|
||||||
@ -43,6 +43,7 @@ const releasedLocales: ReadonlyArray<string> = ['be', 'fr', 'id', 'pt', 'ru', 'u
|
|||||||
* Map Crowdin locales into our internal locales representation
|
* Map Crowdin locales into our internal locales representation
|
||||||
*/
|
*/
|
||||||
const LOCALES_MAP: Record<string, string> = {
|
const LOCALES_MAP: Record<string, string> = {
|
||||||
|
'es-ES': 'es',
|
||||||
'pt-BR': 'pt',
|
'pt-BR': 'pt',
|
||||||
'zh-CN': 'zh',
|
'zh-CN': 'zh',
|
||||||
};
|
};
|
||||||
@ -54,6 +55,7 @@ const LOCALES_MAP: Record<string, string> = {
|
|||||||
const NATIVE_NAMES_MAP: Record<string, string> = {
|
const NATIVE_NAMES_MAP: Record<string, string> = {
|
||||||
be: 'Беларуская',
|
be: 'Беларуская',
|
||||||
cs: 'Čeština',
|
cs: 'Čeština',
|
||||||
|
fil: 'Wikang Filipino',
|
||||||
id: 'Bahasa Indonesia',
|
id: 'Bahasa Indonesia',
|
||||||
lt: 'Lietuvių',
|
lt: 'Lietuvių',
|
||||||
pl: 'Polski',
|
pl: 'Polski',
|
||||||
@ -67,6 +69,7 @@ const NATIVE_NAMES_MAP: Record<string, string> = {
|
|||||||
* This arrays allows us to override Crowdin English languages names
|
* This arrays allows us to override Crowdin English languages names
|
||||||
*/
|
*/
|
||||||
const ENGLISH_NAMES_MAP: Record<string, string> = {
|
const ENGLISH_NAMES_MAP: Record<string, string> = {
|
||||||
|
fil: 'Filipino',
|
||||||
pt: 'Portuguese, Brazilian',
|
pt: 'Portuguese, Brazilian',
|
||||||
sr: 'Serbian',
|
sr: 'Serbian',
|
||||||
zh: 'Simplified Chinese',
|
zh: 'Simplified Chinese',
|
||||||
@ -225,7 +228,7 @@ async function pull(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log('Pulling translation progress...');
|
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<string> = [];
|
const localesToPull: Array<string> = [];
|
||||||
const indexFileEntries: Record<string, IndexFileEntry> = {
|
const indexFileEntries: Record<string, IndexFileEntry> = {
|
||||||
@ -238,16 +241,16 @@ async function pull(): Promise<void> {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
translationProgress.forEach(({ data: { languageId, approvalProgress } }) => {
|
fileProgress.forEach(({ data: { languageId, translationProgress } }) => {
|
||||||
const locale = toInternalLocale(languageId);
|
const locale = toInternalLocale(languageId);
|
||||||
|
|
||||||
if (releasedLocales.includes(locale) || approvalProgress >= MIN_RELEASE_PROGRESS) {
|
if (releasedLocales.includes(locale) || translationProgress >= MIN_RELEASE_PROGRESS) {
|
||||||
localesToPull.push(languageId);
|
localesToPull.push(languageId);
|
||||||
indexFileEntries[locale] = {
|
indexFileEntries[locale] = {
|
||||||
code: locale,
|
code: locale,
|
||||||
name: NATIVE_NAMES_MAP[locale] || iso639.getNativeName(locale),
|
name: NATIVE_NAMES_MAP[locale] || iso639.getNativeName(locale),
|
||||||
englishName: ENGLISH_NAMES_MAP[locale] || iso639.getName(locale),
|
englishName: ENGLISH_NAMES_MAP[locale] || iso639.getName(locale),
|
||||||
progress: approvalProgress,
|
progress: translationProgress,
|
||||||
isReleased: releasedLocales.includes(locale),
|
isReleased: releasedLocales.includes(locale),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -268,7 +271,6 @@ async function pull(): Promise<void> {
|
|||||||
data: { url },
|
data: { url },
|
||||||
} = await crowdin.translationsApi.buildProjectFileTranslation(PROJECT_ID, fileId, {
|
} = await crowdin.translationsApi.buildProjectFileTranslation(PROJECT_ID, fileId, {
|
||||||
targetLanguageId: languageId,
|
targetLanguageId: languageId,
|
||||||
exportApprovedOnly: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data: fileContents } = await axios.get(url, {
|
const { data: fileContents } = await axios.get(url, {
|
||||||
|
Loading…
Reference in New Issue
Block a user