excalidraw/src/i18n.ts

37 lines
836 B
TypeScript
Raw Normal View History

import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import Backend from "i18next-xhr-backend";
import LanguageDetector from "i18next-browser-languagedetector";
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: "de", label: "Deutsch" },
{ lng: "en", label: "English" },
{ lng: "es", label: "Español" },
{ lng: "fr", label: "Français" },
2020-01-24 12:04:54 +02:00
{ lng: "pt", label: "Português" },
2020-01-29 14:00:47 +00:00
{ lng: "ru", label: "Русский" },
];
i18n
.use(Backend)
.use(LanguageDetector)
.use(initReactI18next)
.init({
fallbackLng,
react: { useSuspense: false },
2020-01-24 12:04:54 +02:00
load: "languageOnly",
});
export default i18n;