SME_V1Client/src/i18n.js

51 lines
1.1 KiB
JavaScript

import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import Backend from "i18next-http-backend";
import { languageSupport } from "./constant/language";
const supportedLngs = languageSupport.map((lang) => lang.value);
// RTL languages
const rtlLanguages = ["he"];
i18n
.use(Backend)
.use(initReactI18next)
.init({
backend: {
loadPath: `${window.location.origin}/locales/{{lng}}/translation.json`,
//prevent mobile browser caching stale bundles
requestOptions: {
cache: "no-store",
},
},
lng: "en",
fallbackLng: "en",
supportedLngs: supportedLngs,
// force reload even if namespace was previously loaded
load: "currentOnly",
// don't reuse cached resources across language switches
reloadOnLanguageChange: true,
interpolation: {
escapeValue: false,
},
react: {
useSuspense: true,
},
});
// Helper function to check if a language is RTL
export const isRtlLanguage = (lang) => {
return rtlLanguages.includes(lang);
};
export default i18n;