add base front
This commit is contained in:
4
frontend/src/config/config.tsx
Normal file
4
frontend/src/config/config.tsx
Normal file
@@ -0,0 +1,4 @@
|
||||
export const Config = {
|
||||
backend_uri: import.meta.env.VITE_API_URL,
|
||||
debug: import.meta.env.NODE_ENV === "development"
|
||||
}
|
||||
41
frontend/src/config/i18n.tsx
Normal file
41
frontend/src/config/i18n.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
/* eslint-disable @typescript-eslint/no-restricted-imports */
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import i18next from "i18next";
|
||||
import LanguageDetector from "i18next-browser-languagedetector";
|
||||
import { Settings } from "luxon";
|
||||
import { initReactI18next } from "react-i18next";
|
||||
|
||||
import en from "../../locales/en.json";
|
||||
import fr from "../../locales/fr.json";
|
||||
import { Config } from "./config";
|
||||
|
||||
const resources = {
|
||||
en: { translation: en },
|
||||
fr: { translation: fr },
|
||||
};
|
||||
|
||||
i18next
|
||||
.use(LanguageDetector)
|
||||
.use(initReactI18next)
|
||||
.init({
|
||||
resources: resources,
|
||||
fallbackLng: "en",
|
||||
debug: Config.debug,
|
||||
detection: {
|
||||
caches: [],
|
||||
},
|
||||
interpolation: {
|
||||
escapeValue: false,
|
||||
},
|
||||
ns: ["translation"],
|
||||
defaultNS: "translation",
|
||||
})
|
||||
.then(() => {
|
||||
[Settings.defaultLocale] = i18next.language.split("-");
|
||||
});
|
||||
|
||||
export function t(message: string, params?: Record<string, any>) {
|
||||
return i18next.t(message, params);
|
||||
}
|
||||
|
||||
export default i18next;
|
||||
Reference in New Issue
Block a user