mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-19 03:01:53 +10:00
feat(i18n): implement localization using LinguiJS
This commit is contained in:
27
apps/client/src/providers/locale.tsx
Normal file
27
apps/client/src/providers/locale.tsx
Normal 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>;
|
||||
};
|
||||
Reference in New Issue
Block a user