mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Internationalization followup (#500)
* add translations in data.ts * add language list add spanish version * fixes pr review * add more translations * remove unused label Co-authored-by: David Luzar <luzar.david@gmail.com>
This commit is contained in:
parent
362cd74a9b
commit
a436e70764
9 changed files with 206 additions and 32 deletions
25
src/i18n.ts
25
src/i18n.ts
|
@ -4,18 +4,29 @@ 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: "en", label: "English" },
|
||||
{ lng: "es", label: "Español" }
|
||||
];
|
||||
|
||||
i18n
|
||||
.use(Backend)
|
||||
.use(LanguageDetector)
|
||||
.use(initReactI18next)
|
||||
.init({
|
||||
backend: {
|
||||
loadPath: "./locales/{{lng}}/translation.json"
|
||||
},
|
||||
lng: "en",
|
||||
fallbackLng: "en",
|
||||
debug: false,
|
||||
react: { useSuspense: false }
|
||||
fallbackLng,
|
||||
react: { useSuspense: false },
|
||||
load: "languageOnly"
|
||||
});
|
||||
|
||||
export default i18n;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue