mirror of
https://github.com/romancm/gamebrary
synced 2024-12-21 08:43:04 +00:00
84 lines
1.3 KiB
JavaScript
84 lines
1.3 KiB
JavaScript
/* eslint-disable */
|
|
|
|
const fs = require('fs');
|
|
const translate = require('translate-json-object')();
|
|
const baseJson = require('../src/i18n/en.json');
|
|
|
|
translate.init({ googleApiKey: 'GOOGLE_TRANSLATE_API_KEY' });
|
|
|
|
const supportedLanguages = [
|
|
'af',
|
|
'ar',
|
|
'az',
|
|
'be',
|
|
'bg',
|
|
'ca',
|
|
'cs',
|
|
'cy',
|
|
'da',
|
|
'de',
|
|
'el',
|
|
'en',
|
|
'es',
|
|
'et',
|
|
'eu',
|
|
'fa',
|
|
'fi',
|
|
'fr',
|
|
'ga',
|
|
'gl',
|
|
'hi',
|
|
'hr',
|
|
'ht',
|
|
'hu',
|
|
'hy',
|
|
'id',
|
|
'is',
|
|
'it',
|
|
'iw',
|
|
'ja',
|
|
'ka',
|
|
'ko',
|
|
'lt',
|
|
'lv',
|
|
'mk',
|
|
'ms',
|
|
'mt',
|
|
'nl',
|
|
'no',
|
|
'pl',
|
|
'pt',
|
|
'ro',
|
|
'ru',
|
|
'sk',
|
|
'sl',
|
|
'sq',
|
|
'sr',
|
|
'sv',
|
|
'sw',
|
|
'th',
|
|
'tl',
|
|
'tr',
|
|
'uk',
|
|
'ur',
|
|
'vi',
|
|
'yi',
|
|
'zh-CN',
|
|
'zh-TW',
|
|
];
|
|
|
|
for (let i = 0, promise = Promise.resolve(); i < supportedLanguages.length; i++) {
|
|
promise = promise.then(() => new Promise(resolve => {
|
|
const language = supportedLanguages[i];
|
|
|
|
translate.translate(baseJson, language)
|
|
.then((data) => {
|
|
fs.writeFile(`src/i18n/${language}.json`, JSON.stringify(data, null, 4), () => {
|
|
console.log(`Translation to ${language} completed`);
|
|
resolve();
|
|
});
|
|
}).catch((err) => {
|
|
console.log('error ', err)
|
|
});
|
|
}));
|
|
}
|