ဘယ်အခါ သုံးမလဲ
- Login၊ splash၊ rootRoute portals
- User setting store မရသော page များ
- Authenticated pages တွင် useLazyLocaleTranslation သုံးပါ
Signature
LazyLocaleType map နှင့် explicit locale ပေးပါ။
TSsignature
1function usePublicLazyLocaleTranslation(
2 locales: LazyLocaleType,
3 locale: "en-US" | "zh-CN" | "my-MM",
4): {
5 translation: {
6 get: (key: string, fallback?: string, data?: Record<string, unknown>) => string;
7 };
8 isLoading: boolean;
9 // …
10};အသုံးပြုပုံ
URL / device / public preference မှ locale ယူပြီး JSON pack ကို load လုပ်ပါ။
TSXlogin
1import { usePublicLazyLocaleTranslation } from "@quan-erp/shared-ui";
2import { LoginLocaleLazy } from "./login.locale";
3
4export function LoginPage({ locale }: { locale: "en-US" | "zh-CN" | "my-MM" }) {
5 const { translation, isLoading } = usePublicLazyLocaleTranslation(
6 LoginLocaleLazy,
7 locale,
8 );
9
10 if (isLoading) return null;
11
12 return (
13 <button type="submit">
14 {translation.get("sign-in", "Sign in")}
15 </button>
16 );
17}မှတ်ချက်များ
- Authenticated page တွင် ဤ hook မသုံးရပါ
- locale ကို မပေးလျှင် ဘာသာမှားနိုင်ပါသည်