New project structure
Beta of extract.js for extracting english locale
This commit is contained in:
parent
e18d2b2f84
commit
2edbd67205
247 changed files with 6405 additions and 4237 deletions
51
server/lib/translate.js
Normal file
51
server/lib/translate.js
Normal file
|
@ -0,0 +1,51 @@
|
|||
'use strict';
|
||||
|
||||
const config = require('config');
|
||||
|
||||
const i18n = require("i18next");
|
||||
const Backend = require("i18next-node-fs-backend");
|
||||
|
||||
const path = require('path');
|
||||
|
||||
i18n
|
||||
.use(Backend)
|
||||
// .use(Cache)
|
||||
.init({
|
||||
lng: config.language,
|
||||
|
||||
wait: true, // globally set to wait for loaded translations in translate hoc
|
||||
|
||||
// have a common namespace used around the full app
|
||||
ns: ['common'],
|
||||
defaultNS: 'common',
|
||||
|
||||
debug: true,
|
||||
|
||||
backend: {
|
||||
loadPath: path.join(__dirname, 'locales/{{lng}}/{{ns}}.json')
|
||||
}
|
||||
})
|
||||
|
||||
function tLog(key, args) {
|
||||
if (!args) {
|
||||
args = {};
|
||||
}
|
||||
|
||||
return JSON.stringify([key, args]);
|
||||
}
|
||||
|
||||
function tUI(key, lang, args) {
|
||||
if (!args) {
|
||||
args = {};
|
||||
}
|
||||
|
||||
return i18n.t(key, { ...args, defaultValue, lng: lang });
|
||||
}
|
||||
|
||||
function tMark(key) {
|
||||
return key;
|
||||
}
|
||||
|
||||
module.exports.tLog = tLog;
|
||||
module.exports.tUI = tUI;
|
||||
module.exports.tMark = tMark;
|
Loading…
Add table
Add a link
Reference in a new issue