Repository navigation
Closed
Labels
Description
Refs: #372
Depends on: #375
Can parallel with: #376, #377, #379, #380
Context
Migrate order management, table management, customer management, and dashboard summary views from legacy useI18n() to useTranslations() from use-intl.
Global Component Migration Rules
- Use
const t = useTranslations('namespace')fromuse-intl. - Access keys via namespaced identifiers (e.g.
useTranslations('orders')->t('pending')). - 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.
- Do NOT alter translation wording or domain logic.
Files to Migrate (5 files)
frontend/src/app/(dashboard)/orders/page.tsxfrontend/src/app/(dashboard)/tables/page.tsxfrontend/src/app/(dashboard)/customers/page.tsxfrontend/src/app/(dashboard)/dashboard/page.tsxfrontend/src/components/orders/OrderHistoryGrid.tsx
Dynamic Key Handling
dashboard/page.tsx
Currently uses a type assertion on dynamic status interpolation:
t(`orders.${order.status}` as 'orders.pending' | ...)Replace with exhaustively typed lookup mappings using the domain mappings from frontend/src/lib/i18n-enums.ts (ORDER_STATUS_LABEL_KEYS, TABLE_STATUS_LABEL_KEYS).
Ensure enum mappings in i18n-enums.ts are exhaustively typed against actual domain status types (e.g. satisfies Record<OrderStatus, OrderMessageKey>) rather than generic Record<string, string>.
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 content or wording.
- Do NOT replace application enum mappings with ICU
select(domain enum lookups belong in typed TypeScript mappings).
Acceptance Criteria
- All 5 files migrated to
useTranslations(). - Dynamic order/table status lookups use exhaustively typed mappings.
- No unchecked string assertions or template-literal translation calls.
- Compatibility bridge remains operational for unmigrated batches.
Verification
npm run lint
npm run build:frontend
npm test
npm run test:rtl-dashboard-pos-common
Activity
refactor(i18n): migrate orders, tables, customers, and dashboard to u…
khaira777 commentedon Aug 19, 2026
Migrated and merged via #401.
Confirmed: all 5 in-scope pages/components still used the legacy
useI18n()/t()flat-key API.Changed:
orders/page.tsx,tables/page.tsx,customers/page.tsx,dashboard/page.tsx, andcomponents/orders/OrderHistoryGrid.tsx→useTranslations('<namespace>')with typed leaf keys (multi-namespace files split into per-namespace translators).lib/i18n-enums.ts→ORDER_STATUS_LABEL_KEYS,TABLE_STATUS_LABEL_KEYS, andITEM_STATUS_LABEL_KEYSare now exhaustively typed (satisfies Record<…, MessageKey>); the other maps stay dotted until the settings batch (5E) migrates their consumers.dashboard/page.tsxdynamict(\orders.${order.status}`)interpolation replaced with the typedORDER_STATUS_LABEL_KEYSlookup (raw-status fallback preserved); the redundantlocalizeTemplate` helper was removed in favor of direct ICU params.orders/page.tsxandOrderHistoryGriduse local typedORDER_TYPE_KEYSmaps; thesendBillViaFlodotted-key callback is bridged with a typedwhatsapp.sendadapter.Tests/verification: lint 0 errors,
tsc --noEmitclean, static export 25/25 routes,test:translations,test:locale-chunks, andtest:rtl-dashboard-pos-commonall green; No Mistakes pipeline review 0 findings, CI green. The pipeline also addedfrontend/e2e/i18n-batch-5c.spec.tscovering English (LTR) and Persian (RTL) rendering of all five pages.Acceptance criteria: all 4 items satisfied — no unchecked string assertions or template-literal translation calls remain, and the legacy compatibility bridge is left operational for the remaining batches.
Remaining: legacy bridge removal is owned by #381; batches 5D (#379) and 5E (#380) are still open.