2019-06-18 23:48:29 +00:00
|
|
|
/* eslint-disable */
|
|
|
|
|
2019-06-18 23:46:15 +00:00
|
|
|
const fs = require('fs');
|
|
|
|
const translate = require('translate-json-object')();
|
2019-06-19 19:09:44 +00:00
|
|
|
const baseJson = require('../src/i18n/en.json');
|
2019-06-18 23:46:15 +00:00
|
|
|
|
2020-11-04 06:03:24 +00:00
|
|
|
// NOTE: Please be careful using you api key, translating the entire app to all languages can get costly
|
2020-10-08 18:11:07 +00:00
|
|
|
translate.init({ googleApiKey: 'GOOGLE_TRANSLATE_API_KEY' });
|
2019-06-18 23:46:15 +00:00
|
|
|
|
2021-02-19 19:44:13 +00:00
|
|
|
const supportedLanguages = ['ar','zh-CN','en','fr','de','it','ja','pt','ru','es'];
|
2019-06-18 23:46:15 +00:00
|
|
|
|
|
|
|
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) => {
|
2019-06-19 19:09:44 +00:00
|
|
|
fs.writeFile(`src/i18n/${language}.json`, JSON.stringify(data, null, 4), () => {
|
2019-06-18 23:46:15 +00:00
|
|
|
console.log(`Translation to ${language} completed`);
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
}).catch((err) => {
|
|
|
|
console.log('error ', err)
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
}
|