Repository navigation
Closed
Labels
Description
Refs: #372
Depends on: #375
Can parallel with: #377, #378, #379, #380
Context
This is the first of 5 component migration batches. Migrate shared layout components, confirmation dialogs, authentication pages, and the initial setup wizard from the legacy useI18n() hook to useTranslations() from use-intl.
Global Component Migration Rules
- Use
const t = useTranslations('namespace')fromuse-intl. - Access leaf keys directly:
t('signIn')instead oft('auth.signIn'). - Use compile-time type-safe keys verified against
AppConfig. - Eliminate template-literal dynamic key construction; use exhaustively typed lookup mappings.
- Do NOT remove the compatibility adapter or legacy hook in this PR. Issue refactor(i18n): remove legacy custom i18n implementation #381 owns final removal after all 5 batches are complete.
- Do NOT alter translation wording, layout structure, or product behavior.
Files to Migrate (12 files)
Layout & Shared Components (9 files)
frontend/src/components/layout/AuthGuard.tsxfrontend/src/components/layout/Sidebar.tsxfrontend/src/components/layout/StatusBar.tsxfrontend/src/components/layout/GlobalNotifications.tsxfrontend/src/components/layout/MenuActionHandler.tsxfrontend/src/components/layout/UpdateBadge.tsxfrontend/src/components/layout/HtmlLangSync.tsx(uses active loaded direction from i18n context)frontend/src/components/layout/DirectionalToaster.tsx(uses active loaded direction from i18n context)frontend/src/hooks/use-confirm.tsx(confirmation dialog hook)
Authentication Pages (2 files)
frontend/src/app/auth/login/page.tsxfrontend/src/app/auth/recover/page.tsx
Initial Setup Wizard (1 file)
frontend/src/app/setup/page.tsx
Dynamic Key Handling in setup/page.tsx
setup/page.tsx currently constructs dynamic keys for setup profiles and service models (e.g. t(setup.${item.value}Label), t(setup.${item.value}Desc), t(setup.${item.value}Details)).
Replace with exhaustively typed mapping objects:
type SetupProfile = 'empty' | 'express' | 'demo';
const SETUP_PROFILE_KEYS = {
empty: { label: 'emptyLabel', desc: 'emptyDesc', details: 'emptyDetails' },
express: { label: 'expressLabel', desc: 'expressDesc', details: 'expressDetails' },
demo: { label: 'demoLabel', desc: 'demoDesc', details: 'demoDetails' },
} as const satisfies Record<SetupProfile, { label: string; desc: string; details: string }>;
type ServiceModel = 'qsr' | 'finedine';
const SERVICE_MODEL_KEYS = {
qsr: { label: 'qsrLabel', desc: 'qsrDesc', details: 'qsrDetails' },
finedine: { label: 'finedineLabel', desc: 'finedineDesc', details: 'finedineDetails' },
} as const satisfies Record<ServiceModel, { label: string; desc: string; details: string }>;Also update language selector options in setup/page.tsx to derive selectable languages from the central LANGUAGES registry (frontend/src/lib/i18n/languages.ts) rather than hardcoded language arrays.
What NOT to do
- Do NOT remove
frontend/src/hooks/useI18n.tsor the compatibility bridge infrontend/src/lib/i18n.ts. - Do NOT change any translation strings or keys.
- Do NOT rewrite ICU plural rules.
- Do NOT modify setup logic or API payloads.
Acceptance Criteria
- All 12 files in scope migrated to
useTranslations()/ registry helpers. - No unchecked template-literal translation calls remain in these files.
- Language selection in setup wizard derives from
LANGUAGESregistry (selectable: true). -
HtmlLangSyncandDirectionalToastersynchronize with active loaded locale state. - Backward-compatibility layer remains untouched and operational for unmigrated batches.
- Auth, setup, and layout RTL behavior verified unchanged.
Verification
npm run lint
npm run build:frontend
npm test
npm run test:rtl-setup-auth-settings
npm run test:first-run
npm run test:auth-ui-deterministic
Activity
khaira777 commentedon Aug 19, 2026
Folded-in carried-forward item (from #373, Phase 2 handoff):
getBrowserLanguage()infrontend/src/lib/i18n.tsstill uses string-prefix matching. Update it to parsenavigator.languageviaIntl.Localeand match the language subtag against theLANGUAGESregistry (selectable languages).setup/page.tsxis in both scopes, so it fits naturally here.khaira777 commentedon Aug 19, 2026
Status: implementation complete, pipeline running
What was done (Phase 3 batch 5A — 12 files):
AuthGuard,Sidebar,StatusBar,GlobalNotifications,MenuActionHandler,UpdateBadge,HtmlLangSync,DirectionalToaster,use-confirm— all migrated fromuseI18n()touseTranslations('namespace')with namespace-scoped leaf keys.auth/login,auth/recovermigrated; the tenant picker now uses typed leaf-key maps for backend role/business-type enums (mirrors ofi18n-enumsfor the use-intl namespace scope).useTranslations('setup'); profile/service-model cards use exhaustively typed key mappings (SETUP_PROFILE_KEYS/SERVICE_MODEL_KEYS) — no template-literal dynamic keys remain; the language selector now derives options from the centralLANGUAGESregistry (selectable: true), and the wizard's language follows the shared store so the atomic provider renders it immediately (the perf(i18n): lazy load active locale translation bundle #375 manualloadedLanguagegate is gone).HtmlLangSyncandDirectionalToasternow read the active loaded locale from the i18n context (useLocale()+ registry reverse lookup) instead of the store request — documentlang/dirand toast placement only flip after the locale bundle has actually loaded. This also fixes the toaster briefly following the store during a switch.getBrowserLanguage()now parsesnavigator.languagewithIntl.Localeand matches the language subtag against the registry (replaces string-prefix matching). Behavior preserved:fa-IR/fa/fa-AF→ fa,es-ES→ es,pt-BR→ pt,en-US→ en, unsupported/absent → en.Untouched by design: legacy bridge (
lib/i18n.ts) anduseI18nhook remain operational for unmigrated batches — #381 owns their removal.Verification: lint 0 errors; frontend typecheck, backend build, and static export pass; all focused suites pass (
test:rtl-setup-auth-settings,test:rtl-dashboard-pos-common,test:rtl-kds-server-whatsapp,test:translations,test:locale-chunks,test:first-run,test:auth-ui-deterministic); fullnpm testgreen. RTL evidence tests now wrap the context-driven components inIntlProvider.Note: local full-suite runs occasionally hit pre-existing flaky backend suites (
kds-contract,bills-print-api) — they fail with varying assertions on unmodified main too and pass on retry; CI results are the source of truth.refactor(i18n): migrate shared, auth, and setup components to use-intl (
khaira777 commentedon Aug 19, 2026
✅ Done — merged
Acceptance criteria — all met:
useTranslations()/ registry helpersSETUP_PROFILE_KEYS/SERVICE_MODEL_KEYS, typed navlabelKeys)LANGUAGESregistry (selectable: true), with Persian offered browser-relative for fa users (existing e2e contract, feat(i18n): add Persian/Farsi and Iran support #241)HtmlLangSyncandDirectionalToastersynchronize with the active loaded locale from the i18n context (useLocale+ registry reverse lookup) — lang/dir and toast placement only flip after the bundle loadsuseI18n) untouched and operational — refactor(i18n): remove legacy custom i18n implementation #381 owns removalAlso folded in (deferred BCP-47 item):
getBrowserLanguage()now parsesnavigator.languagewithIntl.Localeand matches the language subtag against the registry (replaces string-prefix matching). Behavior preserved for all tested locales.Verification: lint clean; frontend typecheck, backend build, static export pass; focused suites green (
test:rtl-setup-auth-settings,test:rtl-dashboard-pos-common,test:rtl-kds-server-whatsapp,test:translations,test:locale-chunks,test:first-run,test:auth-ui-deterministic); fullnpm testgreen; full Playwright e2e green in CI (including the setup fa-browser and settings-RTL specs).Notes for the next batch:
resolveInitialLanguagenow honors a fa browser locale (and reads the persisted language directly), consistent with the e2e contract.loadedLanguagegate was removed as redundant.