mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-03 04:11:34 -06:00
Co-authored-by: Piyush Gupta <piyushguptaa2z123@gmail.com> Co-authored-by: Piyush Gupta <56182734+gupta-piyush19@users.noreply.github.com> Co-authored-by: Victor Hugo dos Santos <115753265+victorvhs017@users.noreply.github.com> Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com> Co-authored-by: Matti Nannt <matti@formbricks.com> Co-authored-by: Matti Nannt <mail@matthiasnannt.com> Co-authored-by: Johannes <johannes@formbricks.com> Co-authored-by: Johannes <72809645+jobenjada@users.noreply.github.com>
30 lines
872 B
TypeScript
30 lines
872 B
TypeScript
import { createInstance } from "i18next";
|
|
import ICU from "i18next-icu";
|
|
import resourcesToBackend from "i18next-resources-to-backend";
|
|
import { initReactI18next } from "react-i18next/initReactI18next";
|
|
import { DEFAULT_LOCALE } from "@/lib/constants";
|
|
import { getLocale } from "@/lingodotdev/language";
|
|
|
|
const initI18next = async (lng: string) => {
|
|
const i18nInstance = createInstance();
|
|
await i18nInstance
|
|
.use(ICU)
|
|
.use(initReactI18next)
|
|
.use(resourcesToBackend((language: string) => import(`../locales/${language}.json`)))
|
|
.init({
|
|
lng,
|
|
fallbackLng: DEFAULT_LOCALE,
|
|
interpolation: {
|
|
escapeValue: false,
|
|
},
|
|
});
|
|
return i18nInstance;
|
|
};
|
|
|
|
export async function getTranslate() {
|
|
const locale = await getLocale();
|
|
|
|
const i18nextInstance = await initI18next(locale);
|
|
return i18nextInstance.getFixedT(locale);
|
|
}
|