Skip to content

Instantly share code, notes, and snippets.

@theodesp
Created April 5, 2019 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theodesp/03f73edd84fe1403c3b4e38356fb30f5 to your computer and use it in GitHub Desktop.
Save theodesp/03f73edd84fe1403c3b4e38356fb30f5 to your computer and use it in GitHub Desktop.
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