0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-20 21:32:31 -05:00
logto/packages/console/src/i18n/init.ts

25 lines
650 B
TypeScript
Raw Normal View History

import { LanguageTag } from '@logto/language-kit';
import resources from '@logto/phrases';
2022-02-28 22:18:01 +08:00
import i18next from 'i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import { initReactI18next } from 'react-i18next';
const initI18n = async (language?: LanguageTag) =>
2022-02-28 22:18:01 +08:00
i18next
.use(initReactI18next)
.use(LanguageDetector)
.init({
resources,
fallbackLng: 'en',
interpolation: {
escapeValue: false,
},
lng: language,
detection: {
lookupLocalStorage: 'i18nextLogtoAcLng',
lookupSessionStorage: 'i18nextLogtoAcLng',
},
2022-02-28 22:18:01 +08:00
});
export default initI18n;