Internationalization (i18n) (#627)
* `feat: added internationalization lib, added english labels` * `fixes from code review` * `feat: add crowdin github actions` * `fix: added support for i18n in testing. Fixed broken tests` * `fix: missing translations` * `removed unneded import` * `more components updated with missing translations` * `fixed lint issue` * `Refactor: updated how translations are scoped, updated all references` * `fixing broken tests` * `feat: added language switcher, updated some translations` * `fixed linting issues` * `reverting vite config` * `add english group id's to command palette` * `updated PR template for i18n`
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import i18next from "i18next";
|
||||
import { initReactI18next } from "react-i18next";
|
||||
import Backend from "i18next-http-backend";
|
||||
import LanguageDetector from "i18next-browser-languagedetector";
|
||||
|
||||
export type Lang = { code: string; name: string; flag: string };
|
||||
export type LangCode = Lang["code"];
|
||||
|
||||
export const supportedLanguages: Lang[] = [
|
||||
// { code: "de", name: "Deutsch", flag: "🇩🇪" },
|
||||
{ code: "en", name: "English", flag: "🇺🇸" },
|
||||
// { code: "es", name: "Español", flag: "🇪🇸" },
|
||||
// { code: "fr", name: "Français", flag: "🇫🇷" },
|
||||
// { code: "zh", name: "中文", flag: "🇨🇳" },
|
||||
];
|
||||
|
||||
i18next
|
||||
.use(Backend)
|
||||
.use(initReactI18next)
|
||||
.use(LanguageDetector)
|
||||
.init({
|
||||
backend: {
|
||||
// this will lazy load resources from the i8n folder
|
||||
loadPath: "/src/i18n/locales/{{lng}}/{{ns}}.json",
|
||||
},
|
||||
react: {
|
||||
useSuspense: true,
|
||||
},
|
||||
detection: {
|
||||
order: ["navigator", "localStorage"],
|
||||
},
|
||||
fallbackLng: {
|
||||
"en-US": ["en"],
|
||||
"en-CA": ["en-US", "en"],
|
||||
"default": ["en"],
|
||||
},
|
||||
fallbackNS: ["common", "ui", "dialog"],
|
||||
debug: import.meta.env.DEV,
|
||||
supportedLngs: supportedLanguages?.map((lang) => lang.code),
|
||||
ns: [
|
||||
"channels",
|
||||
"commandPalette",
|
||||
"common",
|
||||
"deviceConfig",
|
||||
"configModules",
|
||||
"dashboard",
|
||||
"dialog",
|
||||
"messages",
|
||||
"nodes",
|
||||
"ui",
|
||||
],
|
||||
});
|
||||
Reference in New Issue
Block a user