2023-06-19 14:59:21 +00:00
|
|
|
import { TFunction, createInstance } from "i18next";
|
2022-10-10 10:14:19 +00:00
|
|
|
import HttpBackend from "i18next-http-backend";
|
|
|
|
import { initReactI18next } from "react-i18next";
|
|
|
|
|
|
|
|
import { environment } from "./environment";
|
2022-11-03 14:06:26 +00:00
|
|
|
import { joinPath } from "./utils/joinPath";
|
2022-10-10 10:14:19 +00:00
|
|
|
|
|
|
|
const DEFAULT_LOCALE = "en";
|
|
|
|
const DEFAULT_NAMESPACE = "translation";
|
|
|
|
|
2023-06-19 14:59:21 +00:00
|
|
|
export type TFuncKey = Parameters<TFunction>[1];
|
|
|
|
|
2022-10-10 10:14:19 +00:00
|
|
|
export const i18n = createInstance({
|
|
|
|
defaultNS: DEFAULT_NAMESPACE,
|
|
|
|
fallbackLng: DEFAULT_LOCALE,
|
|
|
|
ns: [DEFAULT_NAMESPACE],
|
|
|
|
interpolation: {
|
|
|
|
escapeValue: false,
|
|
|
|
},
|
|
|
|
backend: {
|
2022-11-03 14:06:26 +00:00
|
|
|
loadPath: joinPath(environment.resourceUrl, "locales/{{lng}}/{{ns}}.json"),
|
2022-10-10 10:14:19 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
i18n.use(HttpBackend);
|
|
|
|
i18n.use(initReactI18next);
|