How to use the createInstance function from i18next
Find comprehensive JavaScript i18next.createInstance code examples handpicked from public code repositorys.
GitHub: apostrophecms/apostrophe
73 74 75 76 77 78 79 80 81 82
// In case the default locale also has inadequate admin UI phrases if (fallbackLng[0] !== 'en') { fallbackLng.push('en'); } // Make sure we have our own instance to avoid conflicts with other apos objects self.i18next = i18next.createInstance({ fallbackLng, // Required to prevent the debugger from complaining languages: Object.keys(self.locales), // Added later, but required here
544
0
125
GitHub: sound-sync/core
5 6 7 8 9 10 11 12 13 14
const YAML = require('yaml'); const source = fs.readFileSync(path.join(__dirname, '../locale/en.yaml'), 'utf8'); const en = YAML.parse(source); const i18n = i18next.createInstance(); i18n.init({ fallbackLng: 'en', lng: 'en', defaultNS: 'uwave',
12
0
0
203 204 205 206 207 208 209 210 211 212
* @param {Array<string>} fallbacks A prioritized list of translation fallbacks * for the locale. * @param {Object<string, Object>} translations A map of locales to translations */ static async create (locale, fallbacks, translations) { const i18nextInstance = i18next.createInstance(); await i18nextInstance.init({ lng: locale, nsSeparator: false, // allow keys to be phrases having `:` keySeparator: false, // allow keys to be phrases having `.`
6
23
8
55 56 57 58 59 60 61 62 63 64
constructor(steps, section = null, templatePath, content = {}) { this.steps = steps; this.section = section; this.templatePath = templatePath; this.content = JSON.parse(JSON.stringify(content)); this.i18next = i18next.createInstance(); this.i18next.init(this.content, error => { if (error) { process.emit('applicaton-log', { level: 'ERROR',
7
4
46
GitHub: hmcts/cet-frontend
30 31 32 33 34 35 36 37 38 39 40
return new stepObject(steps, section.toString(), resourcePath, i18next, schema); }; const initSteps = (stepLocations) => { const content = requireDir(module, '../', {include: /resources/}); i18next.createInstance(); i18next.init(content, (err) => { if (err) { logger.error(err); }
1
0
0
26 27 28 29 30 31 32 33 34 35 36 37
class i18n { constructor() { if (!this.i18nInstance) { this.i18nInstance = i18Next.createInstance() } this.loaded = false this.loading = false }
0
0
1
+ 24 other calls in file
60 61 62 63 64 65 66 67 68 69
return this.i18next; } createI18nextInstance() { this.log('info', {}, 'Create i18next instacne'); const newI18next = i18next.createInstance(); this.plugins.forEach(plugin => { newI18next.use(plugin); }); return newI18next;
0
0
4
+ 3 other calls in file