Created
April 5, 2019 17:21
-
-
Save theodesp/03f73edd84fe1403c3b4e38356fb30f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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