2021-09-14 10:43:57 +00:00
|
|
|
const Path = require('path')
|
2020-10-27 10:44:01 +00:00
|
|
|
const fs = require('fs')
|
|
|
|
|
|
|
|
const LANGUAGES = [
|
|
|
|
'cs',
|
|
|
|
'da',
|
|
|
|
'de',
|
|
|
|
'en',
|
|
|
|
'es',
|
|
|
|
'fi',
|
|
|
|
'fr',
|
|
|
|
'it',
|
|
|
|
'ja',
|
|
|
|
'ko',
|
|
|
|
'nl',
|
|
|
|
'no',
|
|
|
|
'pl',
|
|
|
|
'pt',
|
|
|
|
'ru',
|
|
|
|
'sv',
|
|
|
|
'tr',
|
2021-04-27 07:52:58 +00:00
|
|
|
'zh-CN',
|
2020-10-27 10:44:01 +00:00
|
|
|
]
|
|
|
|
const LOCALES = {}
|
|
|
|
LANGUAGES.forEach(loadLocales)
|
|
|
|
function loadLocales(language) {
|
|
|
|
LOCALES[language] = require(`../../locales/${language}.json`)
|
|
|
|
}
|
|
|
|
|
|
|
|
function transformLocales(mapping, transformLocale) {
|
|
|
|
Object.entries(LOCALES).forEach(([language, translatedLocales]) => {
|
|
|
|
Object.entries(mapping).forEach(([localeKey, spec]) => {
|
|
|
|
const locale = translatedLocales[localeKey]
|
|
|
|
if (!locale) {
|
|
|
|
// This locale is not translated yet.
|
|
|
|
return
|
|
|
|
}
|
|
|
|
translatedLocales[localeKey] = transformLocale(locale, spec)
|
|
|
|
})
|
|
|
|
|
|
|
|
fs.writeFileSync(
|
2021-09-14 10:43:57 +00:00
|
|
|
Path.join(__dirname, `/../../locales/${language}.json`),
|
2020-10-27 10:44:01 +00:00
|
|
|
JSON.stringify(translatedLocales, null, 2) + '\n'
|
|
|
|
)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
2021-04-27 07:52:58 +00:00
|
|
|
transformLocales,
|
2020-10-27 10:44:01 +00:00
|
|
|
}
|