feat(i18n): implement localization using LinguiJS

This commit is contained in:
Amruth Pillai
2023-11-10 09:07:47 +01:00
parent 13d91411e3
commit 6ad4358d70
108 changed files with 4631 additions and 798 deletions

View File

@ -0,0 +1,27 @@
import "@/client/libs/dayjs";
import { i18n } from "@lingui/core";
import { detect, fromNavigator, fromStorage, fromUrl } from "@lingui/detect-locale";
import { I18nProvider } from "@lingui/react";
import { useEffect } from "react";
import { defaultLocale, dynamicActivate } from "../libs/lingui";
type Props = {
children: React.ReactNode;
};
export const LocaleProvider = ({ children }: Props) => {
useEffect(() => {
const detectedLocale = detect(
fromUrl("lang"),
fromStorage("lang"),
fromNavigator(),
defaultLocale,
)!;
dynamicActivate(detectedLocale);
}, []);
return <I18nProvider i18n={i18n}>{children}</I18nProvider>;
};