Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
export function appInit(i18next: ITranslationService) {
return () =>
i18next
.use(i18nextXHRBackend)
.use(i18nextLanguageDetector)
.init({
whitelist: ['en', 'el'],
fallbackLng: 'en',
debug: true,
returnEmptyString: false,
ns: [
'translation'
],
interpolation: {
format: I18NextModule.interpolationFormat(defaultInterpolationFormat)
},
backend: {
loadPath: 'assets/locales/{{lng}}.{{ns}}.json',
},
// lang detection plugin options
detection: {
// order and from where user language should be detected
order: ['querystring', 'cookie'],
// keys or params to lookup language from
lookupCookie: 'lang',
lookupQuerystring: 'lng',
// cache user language on
caches: ['localStorage', 'cookie'],
// optional expire and domain for set cookie
cookieMinutes: 10080, // 7 days
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.