Skip to content

refactor(i18n): install use-intl and establish language registry and provider - #395

Merged
khaira777 merged 1 commit into
mainfrom
refactor/372-i18n-use-intl-foundation
Aug 19, 2026
Merged

khaira777 merged 1 commit into
mainfrom
refactor/372-i18n-use-intl-foundation

Conversation

@khaira777

Copy link
Copy Markdown
Contributor

Intent

Implement FloCafe issue #373, the first sub-issue of epic #372 (migrate the hand-rolled i18n system to use-intl v4). Install use-intl v4 in the frontend; create the centralized language registry (frontend/src/lib/i18n/languages.ts) with derived Language/Locale types plus per-language locale/direction/selectability metadata; relocate the four translation JSON files into frontend/src/lib/i18n/messages/; add the use-intl v4 AppConfig module augmentation (messages.d.ts) for compile-time message/locale typing; create and mount an I18nProvider in the root layout; and keep every existing t()/useI18n() consumer working through backward-compatible re-exports in frontend/src/lib/i18n.ts. Hard scope exclusions for this change: no async lazy loading (#375), no flat-to-nested key conversion (#374), no component migration to useTranslations (#376-380), no removal of the legacy t()/useI18n engine (#381), no translation copy/wording changes, and Persian stays selectable:false (user-facing enablement remains governed by #241). Also updated the two tests that read translation JSON paths (tests/translations.test.ts, tests/e2e-argentina-flow.test.ts) to the new messages/ directory.

What Changed

  • Installed use-intl and mounted a new I18nProvider in the frontend root layout to provide active locale and translation context.
  • Created frontend/src/lib/i18n/languages.ts as a central registry for supported languages and metadata, added use-intl type declarations in frontend/src/lib/i18n/messages.d.ts, and preserved backward-compatible re-exports in frontend/src/lib/i18n.ts.
  • Relocated translation JSON files to frontend/src/lib/i18n/messages/ and updated test references in tests/translations.test.ts and tests/e2e-argentina-flow.test.ts.

Risk Assessment

✅ Low: The changes cleanly introduce use-intl and the centralized language registry while maintaining full backward compatibility with existing i18n callers without regressions.

Testing

Executed targeted backend compilation, Next.js static build, i18n translation integrity tests, RTL regression suites, and Playwright end-to-end browser tests across auth, setup, POS, dashboard, orders, products, and settings screens in English, Spanish, Portuguese, and Persian, capturing 28 visual screenshots into the designated evidence directory; all checks and tests passed with 0 failures.

  • Evidence: Login Screen (LTR English) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/auth-login-ltr-en.png)
  • Evidence: Login Screen (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/auth-login-rtl-fa.png)
  • Evidence: Password Recovery Screen (LTR English) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/auth-recover-ltr-en.png)
  • Evidence: Password Recovery Screen (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/auth-recover-rtl-fa.png)
  • Evidence: POS Screen (LTR English) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/pos-ltr-en.png)
  • Evidence: POS Screen (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/pos-rtl-fa.png)
  • Evidence: Dashboard Screen (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/dashboard-rtl-fa.png)
  • Evidence: Settings Store Screen (LTR English) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/settings-store-ltr-en.png)
  • Evidence: Settings Store Screen (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/settings-store-rtl-fa.png)
  • Evidence: Settings Account Tab (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/settings-account-rtl-fa.png)
  • Evidence: Settings Taxes Tab (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/settings-taxes-rtl-fa.png)
  • Evidence: Settings Health Check Dialog (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/settings-health-check-dialog-rtl-fa.png)
  • Evidence: Setup Wizard Step 1 (LTR English) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/setup-step1-ltr-en.png)
  • Evidence: Setup Wizard Step 1 (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/setup-step1-rtl-fa.png)
  • Evidence: Setup Wizard Step 1 Persian Browser Locale Option (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/setup-step1-fa-locale-fa-option.png)
  • Evidence: Setup Wizard Step 2 Master PIN (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/setup-step2-master-pin-rtl-fa.png)
  • Evidence: Setup Wizard Step 3 Owner Account (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/setup-step3-owner-account-rtl-fa.png)
  • Evidence: Orders Screen (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/orders-rtl-fa.png)
  • Evidence: Products Catalog Screen (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/products-rtl-fa.png)
  • Evidence: Addon Groups Screen (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/addon-groups-rtl-fa.png)
  • Evidence: Customers Screen (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/customers-rtl-fa.png)
  • Evidence: Customer Display Screen (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/customer-display-rtl-fa.png)
  • Evidence: Tables Screen (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/tables-rtl-fa.png)
  • Evidence: Staff Management Modal (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/staff-modal-rtl-fa.png)
  • Evidence: Support Ticket Screen (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/support-rtl-fa.png)
  • Evidence: Thermal Print Test Screen (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/print-test-rtl-fa.png)
  • Evidence: Mobile Dashboard App Bar (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/mobile-dashboard-appbar-rtl-fa.png)
  • Evidence: Mobile Sidebar Drawer Sheet (RTL Persian) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9/mobile-sidebar-sheet-rtl-fa.png)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • npm run test:translations
  • npm run test:e2e-argentina-flow
  • npm run test:rtl-foundation
  • npm run test:rtl-setup-auth-settings
  • npm run test:rtl-dashboard-pos-common
  • npm run test:rtl-kds-server-whatsapp
  • npm run build
  • cd frontend && npx cross-env NEXT_BUILD_MODE=desktop npm run build
  • cd frontend && EVIDENCE_DIR=/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9 npx playwright test e2e/rtl-setup-auth-settings.spec.ts
  • cd frontend && EVIDENCE_DIR=/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0BMX544WJWEKZT88B3623A9 npx playwright test e2e/rtl-dashboard-pos-common.spec.ts
  • Targeted runtime validation of LANGUAGES registry metadata, BCP-47 locales (en, es, pt-BR, fa-IR), text directions (ltr/rtl), selectable: false for Persian per #241, backward-compatible re-exports from frontend/src/lib/i18n.ts, and I18nProvider React root rendering
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…ider foundation

- Install use-intl v4 in the frontend
- Add centralized language registry (frontend/src/lib/i18n/languages.ts)
  with derived Language/Locale types and locale/direction/selectability metadata
- Relocate translation JSON files to frontend/src/lib/i18n/messages/
- Add use-intl AppConfig module augmentation (messages.d.ts)
- Add and mount I18nProvider in the root layout
- Preserve legacy t()/useI18n() consumers via backward-compatible re-exports

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant