// or fix the namespace to anotherNamespace const anotherNamespace = i18next.getFixedT(null, 'anotherNamespace'); const x: string = anotherNamespace('anotherNamespaceKey'); // no need to prefix ns i18n.t('anotherNamespace:anotherNamespaceKey'); i18next.changeLanguage('en', (err: any, t: i18next.TranslationFunction) => { if (err) { console.log('something went wrong loading', err); return; } t('key'); // -> same as i18next.t }); i18next.loadNamespaces('myNamespace', (err: any, t: i18next.TranslationFunction) => { /* resources have been loaded */ }); i18next.loadNamespaces(['myNamespace1', 'myNamespace2'], (err: any, t: i18next.TranslationFunction) => { /* resources have been loaded */ }); i18next.loadLanguages('de', (err: any, t: i18next.TranslationFunction) => { /* resources have been loaded */ }); i18next.loadLanguages(['de', 'fr'], (err: any, t: i18next.TranslationFunction) => { /* resources have been loaded */ }); // reload all i18next.reloadResources(); // reload languages i18next.reloadResources(['de', 'fr']); // reload namespaces for all languages i18next.reloadResources(null, ['ns1', 'ns2']); // reload namespaces in languages i18next.reloadResources(['de', 'fr'], ['ns1', 'ns2']); // for current language
if (err) { console.log('something went wrong loading', err); return; } t('key'); // -> same as i18next.t }); i18next.loadNamespaces('myNamespace', (err, t) => { /* resources have been loaded */ }); i18next.loadNamespaces(['myNamespace1', 'myNamespace2'], (err, t) => { /* resources have been loaded */ }); i18next.loadLanguages('de', (err, t) => { /* resources have been loaded */ }); i18next.loadLanguages(['de', 'fr'], (err, t) => { /* resources have been loaded */ }); // reload all i18next.reloadResources(); // reload languages i18next.reloadResources(['de', 'fr']); // reload namespaces for all languages i18next.reloadResources(null, ['ns1', 'ns2']); // reload namespaces in languages