i18next#InitOptions TypeScript Examples
The following examples show how to use
i18next#InitOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: i18n.ts From clearflask with Apache License 2.0 | 6 votes |
getI18n = (
prepare: (i: typeof i18n) => typeof i18n,
opts?: InitOptions,
) => {
prepare(i18n).use(
initReactI18next
).use(resourcesToBackend((language, namespace, callback) => {
if (!supportedLanguagesSet.has(language)) {
return callback({ name: 'unsupported', message: `Language ${language} not supported` }, null);
}
import(/* webpackChunkName: "[request]" */ `./locales/${language}/${namespace}.json`)
.then(({ default: resources }) => callback(null, resources))
.catch((error) => callback(error, null))
})).init({ // Docs: https://www.i18next.com/overview/configuration-options
initImmediate: false,
fallbackLng: defaultLanguage,
supportedLngs: [...supportedLanguagesSet],
debug: !isProd(),
missingKeyNoValueFallbackToKey: false,
ns: ['app', 'site'],
defaultNS: 'app',
...opts,
interpolation: {
escapeValue: false, // not needed for react as it escapes by default
...opts?.interpolation,
},
react: {
useSuspense: false,
wait: true,
transWrapTextNodes: 'span',
...opts?.react,
},
});
return i18n;
}
Example #2
Source File: index.ts From lightning-terminal with MIT License | 6 votes |
config: InitOptions = {
lng: defaultLanguage,
resources,
whitelist,
fallbackLng: defaultLanguage,
keySeparator: false,
interpolation: {
escapeValue: false,
},
detection: {
lookupLocalStorage: 'lang',
},
}