Extracted strings and fixes on localization support

Language chooser in the UI
This commit is contained in:
Tomas Bures 2018-11-18 21:31:22 +01:00
parent 9f449c0a2f
commit dc7789c17b
126 changed files with 2919 additions and 2028 deletions

View file

@ -1,31 +1,44 @@
'use strict';
const config = require('config');
const i18n = require("i18next");
const Backend = require("i18next-node-fs-backend");
const fs = require('fs');
const path = require('path');
const {convertToFake, langCodes} = require('../../shared/langs');
const resourcesCommon = {};
function loadLanguage(shortCode) {
resourcesCommon[shortCode] = {
common: JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'locales', shortCode, 'common.json')))
};
}
loadLanguage('en');
loadLanguage('es');
resourcesCommon.fake = convertToFake(resourcesCommon.en);
const resources = {};
for (const lng of config.enabledLanguages) {
const shortCode = langCodes[lng].shortCode;
resources[shortCode] = {
common: resourcesCommon[shortCode]
};
}
i18n
.use(Backend)
// .use(Cache)
.init({
lng: config.language,
resources,
wait: true, // globally set to wait for loaded translations in translate hoc
// have a common namespace used around the full app
ns: ['common'],
fallbackLng: config.defaultLanguage,
defaultNS: 'common',
debug: true,
backend: {
loadPath: path.join(__dirname, 'locales/{{lng}}/{{ns}}.json')
}
debug: false
})
function tLog(key, args) {
if (!args) {
args = {};