When to use
- Login, splash, rootRoute portals, and other unauthenticated screens
- Any page that cannot read the user setting store
- Authenticated pages should use useLazyLocaleTranslation instead
Signature
Same LazyLocaleType map as the authenticated lazy hook, plus an explicit locale argument.
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};Usage
Resolve locale from URL, device, or a public preference, then load the matching JSON pack.
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}Notes
- See Core → Localization for LazyLocaleType file layout
- Sync usePublicLocaleTranslation is legacy — prefer this lazy variant
- Keep public dictionaries small; only strings needed before login