2020-01-21 01:14:10 +02:00
|
|
|
import i18n from "i18next";
|
|
|
|
import { initReactI18next } from "react-i18next";
|
|
|
|
|
|
|
|
import Backend from "i18next-xhr-backend";
|
|
|
|
import LanguageDetector from "i18next-browser-languagedetector";
|
|
|
|
|
2020-01-22 16:25:04 +02:00
|
|
|
export const fallbackLng = "en";
|
|
|
|
|
|
|
|
export function parseDetectedLang(lng: string | undefined): string {
|
|
|
|
if (lng) {
|
|
|
|
const [lang] = i18n.language.split("-");
|
|
|
|
return lang;
|
|
|
|
}
|
|
|
|
return fallbackLng;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const languages = [
|
|
|
|
{ lng: "en", label: "English" },
|
|
|
|
{ lng: "es", label: "Español" }
|
|
|
|
];
|
|
|
|
|
2020-01-21 01:14:10 +02:00
|
|
|
i18n
|
|
|
|
.use(Backend)
|
|
|
|
.use(LanguageDetector)
|
|
|
|
.use(initReactI18next)
|
|
|
|
.init({
|
2020-01-22 16:25:04 +02:00
|
|
|
fallbackLng,
|
|
|
|
react: { useSuspense: false },
|
|
|
|
load: "languageOnly"
|
2020-01-21 01:14:10 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
export default i18n;
|