webui/src/i18n/i18n.ts

41 lines
1001 B
TypeScript

// /src/i18n.ts
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import HttpBackend from "i18next-http-backend";
import { determineInitialLocale } from "../modules/frame/services/lanugageService";
import { fallbackLng } from "./generatedLocales";
export const Namespaces = {
Common: "common",
MailTypes: "mailTypes",
HtmlIsland: "htmlIsland",
TaskTypes: "taskTypes",
Raci: "raci",
} as const;
export type Namespace = (typeof Namespaces)[keyof typeof Namespaces];
i18n
.use(HttpBackend) // load translations from /public/locales
.use(initReactI18next)
.init({
lng: determineInitialLocale(),
fallbackLng: {
...fallbackLng,
default: ["en"],
},
defaultNS: "common",
interpolation: {
escapeValue: false,
},
backend: {
loadPath: "/locales/{{lng}}/{{ns}}.json",
},
react: {
useSuspense: false,
returnNull: false,
},
});
export default i18n;