excalidraw/src/i18n.ts
Marco Kaul 5fd6c4d853 Add german translation (#550)
* Add german translation

* Add german language option

* Fix missing german translation

* Alphabetical order for languages

* Sort

Co-authored-by: Lipis <lipiridis@gmail.com>
2020-01-25 09:47:02 -08:00

36 lines
794 B
TypeScript

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" },
{ lng: "pt", label: "Português" },
];
i18n
.use(Backend)
.use(LanguageDetector)
.use(initReactI18next)
.init({
fallbackLng,
react: { useSuspense: false },
load: "languageOnly",
});
export default i18n;