You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
917 B
34 lines
917 B
import i18n from "i18next"; |
|
import { initReactI18next } from "react-i18next"; |
|
import LanguageDetector from "i18next-browser-languagedetector"; |
|
|
|
// Languages |
|
import en from "./locales/en/translation.json"; |
|
import { captionLanguages } from "./iso6391"; |
|
|
|
const locales = { |
|
en: { |
|
translation: en, |
|
}, |
|
}; |
|
i18n |
|
// detect user language |
|
// learn more: https://github.com/i18next/i18next-browser-languageDetector |
|
.use(LanguageDetector) |
|
// pass the i18n instance to react-i18next. |
|
.use(initReactI18next) |
|
// init i18next |
|
// for all options read: https://www.i18next.com/overview/configuration-options |
|
.init({ |
|
fallbackLng: "en", |
|
resources: locales, |
|
interpolation: { |
|
escapeValue: false, // not needed for react as it escapes by default |
|
}, |
|
}); |
|
|
|
export const appLanguageOptions = captionLanguages.filter((x) => { |
|
return Object.keys(locales).includes(x.id); |
|
}); |
|
|
|
export default i18n;
|
|
|