How to use the init function from i18next
Find comprehensive JavaScript i18next.init code examples handpicked from public code repositorys.
28 29 30 31 32 33 34 35 36 37
}; const { namespaces, languages } = await walkDirectory(path.resolve(__dirname, '../languages/')); i18next.use(Backend); await i18next.init({ backend: options, debug: false, fallbackLng: 'en-US', initImmediate: false,
325
475
19
315 316 317 318 319 320 321 322 323 324 325
// Prepare the renderer once the app is ready app.on('ready', async () => { await prepareNext('./renderer') const i18nConfig = getI18nConfig() i18next.init(i18nConfig, function(err) { if (err) { logger.error(err) }
66
94
6
318 319 320 321 322 323 324 325 326 327 328
// Prepare the renderer once the app is ready app.on('ready', async () => { await prepareNext('./renderer') const i18nConfig = getI18nConfig() i18next.init(i18nConfig, (err) => { if (err) { logger.error(err) }
66
94
6
+ 20 other calls in file
GitHub: hmcts/one-per-page
2 3 4 5 6 7 8 9 10 11
const { isDev } = require('../util/nodeEnv'); const defaultIfUndefined = require('../util/defaultIfUndefined'); const log = require('../util/logging')('i18Next'); const crypto = require('crypto'); const i18NextInstance = i18Next.init({ fallbackLng: 'en' }); i18NextInstance.contentBundles = {}; const getHash = (namespace, lang) => { const key = `${namespace}.${lang}`;
3
8
187
GitHub: IpshitaC/sociable
19 20 21 22 23 24 25 26 27 28
dynamicLoad : true }; module.exports = function(app) { i18n.init(i18nOptions, function(err) { if (err) console.warn('error initializing i18n module'); else console.log('i18n module initialized');
0
13
2
13 14 15 16 17 18 19 20 21 22
* @param app {*} * @param passport {*} * @param sessionStore {*} */ module.exports = function(app,passport,sessionStore){ i18n.init({ resGetPath: './locales/__lng__/__ns__.json', fallbackLng: 'en-US', ns: 'server', saveMissing: true,
0
5
2
GitHub: 4gray/compodoc
40 41 42 43 44 45 46 47 48 49
}; public fallbackLanguage = 'en-US'; public async init(language: string) { return i18next.init({ lng: language, fallbackLng: this.fallbackLanguage, resources: { 'de-DE': {
383
0
2
GitHub: bplmp/yby
79 80 81 82 83 84 85 86 87 88
// bodyParser should be above methodOverride app.use(express.bodyParser()) // i18next i18n.init(config.i18n); app.use(i18n.handle); i18n.registerAppHelper(app); // cookieParser should be above session
2
0
2
90 91 92 93 94 95 96 97 98 99 100
return inputText; } module.exports.LocalizationInterceptor = { process(handlerInput) { const localizationClient = i18n.init({ lng: handlerInput.requestEnvelope.request.locale || 'en-US', resources: require('./i18n'), returnObjects: true });
0
1
0
GitHub: hmcts/cet-frontend
31 32 33 34 35 36 37 38 39 40 41
}; const initSteps = (stepLocations) => { const content = requireDir(module, '../', {include: /resources/}); i18next.createInstance(); i18next.init(content, (err) => { if (err) { logger.error(err); } });
1
0
0
GitHub: stevanna98/CoTra
71 72 73 74 75 76 77 78 79 80 81
} }; const LocalisationRequestInterceptor = { process(handlerInput) { const localisationClient = i18n.init({ lng: Alexa.getLocale(handlerInput.requestEnvelope), resources: languageStrings, returnObjects: true });
0
0
1
GitHub: 444748104/oa
153 154 155 156 157 158 159 160 161 162
}; var lang = settings.lang || getCurrentLocale(); if (lang) { opt.lng = lang; } i18n.init(opt ,function() { resolve(); }); }); }
0
0
1
+ 35 other calls in file
GitHub: boutdecode/site-template
0 1 2 3 4 5 6 7 8 9 10
const i18next = require('i18next'); const ObjectUtils = require("../Services/ObjectUtils"); module.exports = class I18N { constructor(defaultLocale, resources) { i18next.init({ fallbackLng: defaultLocale, resources: resources.reduce((config, resource) => { return ObjectUtils.deepMerge(config, require(resource)); }, {}),
0
0
0
2 3 4 5 6 7 8 9 10 11
const it = require('../i18n/it.json') let initialized = false const init = options => new Promise(resolve => { i18next.init(options, resolve) }) const get = (language, key, options) => `<speak> ${i18next.getFixedT(language)(key,options)}
0
0
4
GitHub: ersinfotech/e18n
138 139 140 141 142 143 144 145 146 147
}; exports.enable = function(app, option) { i18n.init(); app.use(i18n.handle); // have i18n befor app.router i18n.registerAppHelper(app)
0
0
4
+ 3 other calls in file
98 99 100 101 102 103 104 105 106 107
fs.mkdirSync(lngFolder); } }); } i18next.init(i18nextOptions); translationNamespaces = ComponentService.getComponentNames(); if (i18nextOptions.extraNamespaces) { translationNamespaces.concat(i18nextOptions.extraNamespaces);
0
0
3