Skip to content

refactor(i18n): component migration 5E — settings, admin, remaining #380

Closed

Description

@khaira777

Refs: #372
Depends on: #375
Can parallel with: #376, #377, #378, #379

Context

Migrate settings management, administrative dialogs, catalog management (products, categories, addon groups), staff management, support, WhatsApp integration, and print-test pages from legacy useI18n() to useTranslations() from use-intl.

Global Component Migration Rules

  • Use const t = useTranslations('namespace') from use-intl.
  • Access keys via namespaced identifiers (e.g. useTranslations('settings'), useTranslations('products'), useTranslations('whatsapp')).
  • Use compile-time type-safe keys verified against AppConfig.
  • Eliminate template-literal dynamic key construction; use exhaustively typed lookup mappings.
  • Regional formatting guardrail: This issue changes translation access only. Do not replace FloCafe's tenant-aware money, number, date, or time formatting helpers with IntlProvider's default UI-locale formatting. Business values remain governed by tenant country, currency, timezone, calendar, digit, and display preferences. useFormatter() may only be used where formatting intentionally follows UI language and no tenant-regional business semantics apply.
  • Do NOT remove the compatibility adapter or legacy hook in this PR. Issue refactor(i18n): remove legacy custom i18n implementation #381 owns final removal once all batches are complete.
  • Do NOT alter translation wording or settings storage contracts.

Files to Migrate (15 files)

Settings & Administrative Dialogs (8 files)

  • frontend/src/app/(dashboard)/settings/page.tsx
  • frontend/src/components/settings/HealthCheckDialog.tsx
  • frontend/src/components/settings/InitializeDatabaseDialog.tsx
  • frontend/src/components/settings/LocalePreferencesPanel.tsx
  • frontend/src/components/settings/MasterPinPrompt.tsx
  • frontend/src/components/settings/PaymentMethodsSettings.tsx
  • frontend/src/components/settings/TaxConfigurationPanel.tsx
  • frontend/src/components/settings/WhatsAppEnableCard.tsx

Catalog, Staff, Support & Admin Pages (7 files)

  • frontend/src/app/(dashboard)/products/page.tsx
  • frontend/src/app/(dashboard)/addon-groups/page.tsx
  • frontend/src/app/(dashboard)/staff/page.tsx
  • frontend/src/app/(dashboard)/support/page.tsx
  • frontend/src/app/(dashboard)/whatsapp/page.tsx
  • frontend/src/app/(dashboard)/print-test/page.tsx
  • frontend/src/components/products/ImageUploader.tsx

Dynamic Key Handling

whatsapp/page.tsx

Currently uses template literals for message statuses and message kinds:

t(`whatsapp.status.${status}`)
t(`whatsapp.kind.${m.kind}`)

Replace with exhaustively typed mapping objects:

type WhatsAppStatus = 'queued' | 'typing' | 'sent' | 'delivered' | 'read' | 'failed';

const WHATSAPP_STATUS_KEYS = {
  queued: 'status.queued',
  typing: 'status.typing',
  sent: 'status.sent',
  delivered: 'status.delivered',
  read: 'status.read',
  failed: 'status.failed',
} as const satisfies Record<WhatsAppStatus, string>;

type WhatsAppMessageKind = 'text' | 'image' | 'document' | 'template';

const WHATSAPP_KIND_KEYS = {
  text: 'kind.text',
  image: 'kind.image',
  document: 'kind.document',
  template: 'kind.template',
} as const satisfies Record<WhatsAppMessageKind, string>;

Settings Language Selector

Update the UI language selector in settings/page.tsx to derive options from LANGUAGES in frontend/src/lib/i18n/languages.ts (filtering for selectable: true) instead of maintaining hardcoded arrays.

Note: LocalePreferencesPanel.tsx manages regional country profiles and tax formatting preferences; keep UI translation language and country locale preferences as distinct, clean concerns.

What NOT to do

  • Do NOT remove frontend/src/hooks/useI18n.ts or the compatibility bridge in frontend/src/lib/i18n.ts (reserved for refactor(i18n): remove legacy custom i18n implementation #381).
  • Do NOT change any translation content or wording.
  • Do NOT merge UI language support with country/tax pack configurations.
  • Do NOT replace FloCafe's tenant-aware money, number, date, or time formatting helpers with IntlProvider default formatting for business data.

Acceptance Criteria

  • All 15 settings, admin, catalog, and WhatsApp files migrated to useTranslations().
  • No unchecked template-literal translation calls remain.
  • Settings language selector dynamically renders options from the central registry.
  • Compatibility bridge remains operational for unmigrated batches.
  • Regional formatting guardrail observed: tenant-aware formatting helpers preserved for business values.

Verification

npm run lint
npm run build:frontend
npm test
npm run test:rtl-setup-auth-settings

Activity

  1. added
    enhancement
    area:frontend
    on Aug 17, 2026
  2. self-assigned this
    on Aug 19, 2026
  3. khaira777 commented on Aug 19, 2026

    @khaira777
    ContributorAuthor

    Migrated and merged via #404.

    What changed

    • Settings, admin, catalog, staff, support, WhatsApp, and print-test migrated from legacy useI18n()/t() to useTranslations(): settings, products, addon-groups, staff, support, whatsapp, print-test pages; settings components (HealthCheckDialog, InitializeDatabaseDialog, LocalePreferencesPanel, MasterPinPrompt, PaymentMethodsSettings, TaxConfigurationPanel, WhatsAppEnableCard); and products/ImageUploader.
    • i18n-enums.ts remaining maps (ROLE_LABEL_KEYS, TENANT_STATUS_LABEL_KEYS, BUSINESS_TYPE_LABEL_KEYS, PAYMENT_STATUS_LABEL_KEYS) are now exhaustively typed against use-intl leaf keys.
    • WhatsApp dynamic keys replaced with typed WHATSAPP_STATUS_KEYS / WHATSAPP_KIND_KEYS; whatsapp.apiError.* resolved via a typed namespace guard.
    • Settings language selector now derives its options from the LANGUAGES registry (selectable: true) instead of hardcoded arrays.
    • Tenant money/number/date/time business formatting stays governed by country/currency/timezone (not routed through useFormatter()); legacy bridge left in place for refactor(i18n): remove legacy custom i18n implementation #381.

    Verification

    • npm run lint 0 errors; tsc --noEmit clean; npm run build:frontend static export passed.
    • npm run test:translations, npm run test:locale-chunks, npm run test:rtl-setup-auth-settings, npm run test:rtl-kds-server-whatsapp, and the 5E e2e specs — green.
    • CI green on merge.

    Acceptance criteria — all met. Epic #372 updated (5E checked).

  4. khaira777 commented on Aug 19, 2026

    @khaira777
    ContributorAuthor

    Closed — acceptance criteria met and merged in #404. Epic #372 updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:frontendenhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions