Repository navigation
refactor(i18n): migrate POS components and web-print to use-intl - #400
Merged
Merged
Conversation
Phase 3 batch 5B (issue #377). Replace the legacy useI18n()/t() flat-key API with useTranslations()/createTranslator across the POS page, its 14 components, and the web-print helper. Typed leaf-key maps handle the two dynamic-key cases (dietary tags, order-type suffixes); payment-method labels use a local BUILT_IN_PAYMENT_KEYS map while PAYMENT_METHODS.labelKey stays dotted for the unmigrated dashboard; web-print keeps its synchronous API via createTranslator with cached messages. No wording, logic, or behavior changes; the legacy bridge remains for later batches.
This was referenced Aug 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Migrate the POS page, its 14 components, and the web-print helper from the legacy useI18n()/t() flat-key API to use-intl useTranslations()/createTranslator, completing Phase 3 batch 5B (issue #377) of the i18n migration epic (#372).
Scope is exactly 16 files: pos/page.tsx plus the 14 POS components (AddonModal, CartPanel, CustomerSearch, DietaryBadge, EditCustomerModal, PaymentModal, PosTopbar, PrepaidCheckoutModal, PrinterStatus, ProductGrid, SplitCheckModal, TableCheckoutModal, TablePickerModal, TaxBreakdown) and lib/printer/web-print.ts.
Key decisions: React components use useTranslations(namespace) with typed leaf keys; multi-namespace files split into t / tCommon / tSupport / tOrders / tWhatsappSend as needed. DietaryBadge uses a typed KnownDietaryTag plus DIETARY_TAG_KEYS map for known tags while custom tags render the canonical name directly, and its existing tagLabel() helper must keep returning dotted keys because the unmigrated products page (batch 5E) still consumes it. PrepaidCheckoutModal uses a typed OrderType plus ORDER_TYPE_SUFFIX_KEYS map to replace the pos.orderTypeSuffix template-literal cast. Payment-method labels: PAYMENT_METHODS.labelKey stays dotted (dashboard batch 5C still consumes it), so both payment modals use a local typed BUILT_IN_PAYMENT_KEYS map. PaymentModal sendBillViaFlo is shared with the unmigrated orders page and still takes a dotted-key callback, bridged with a typed whatsapp.send adapter rather than reintroducing legacy t(). web-print.ts (non-React) uses createTranslator from use-intl/core with cached messages, keeping generateBillHtml/printWebBill synchronous so the receipt-printing and browser-receipts tests stay intact.
Constraints: no wording, logic, or behavior changes beyond the mechanical i18n API migration; no new dependencies, migrations, or schema changes; the legacy useI18n bridge must remain for other unmigrated batches (its removal is owned by #381); PaymentModal recently gained a dynamic currency-unit adapter (#387) whose behavior must be preserved.
What Changed
useI18nflat-key API touseTranslationswith scoped namespace lookups.DIETARY_TAG_KEYS,ORDER_TYPE_SUFFIX_KEYS, andBUILT_IN_PAYMENT_KEYS) while preserving compatibility interfaces for unmigrated modules.web-print.tstocreateTranslatorfromuse-intl/corebacked by cached locale messages for synchronous receipt label translation.Risk Assessment
✅ Low: The mechanical migration of POS components and web-print to use-intl is clean, type-safe, preserves backward-compatibility bridges, and introduces no regressions or missing translation keys.
Testing
Validated Phase 3 Batch 5B i18n migration across all 16 scoped files: translation integrity checks confirmed 100% key and ICU parity without untranslated leaves; Next.js frontend export compiled successfully; browser web receipt generation verified synchronous translations in EN, ES, PT, and Persian RTL; Playwright e2e validated rendered POS UI in both English LTR and Persian RTL; and currency/payment split test suites passed with zero failures. Captured rendered UI screenshots and receipt HTML/PNG evidence in the designated evidence directory.
/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0D3DF5HBETVQHFX32CEADPS/pos-ltr-en.png)/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0D3DF5HBETVQHFX32CEADPS/pos-rtl-fa.png)/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0D3DF5HBETVQHFX32CEADPS/01_persian_receipt_rial_persian_digits.png)Evidence: Persian RTL Web Receipt HTML (Rial)
/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0D3DF5HBETVQHFX32CEADPS/02_persian_receipt_toman_persian_digits.png) - Evidence: Persian RTL Web Receipt (Toman Short & Latin Digits) (local file:/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0D3DF5HBETVQHFX32CEADPS/03_persian_receipt_toman_short_latin_digits.png) - Evidence: English Baseline Web Receipt (local file:/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0D3DF5HBETVQHFX32CEADPS/05_english_receipt_baseline.png) - Evidence: Spanish Reprint Web Receipt (local file:/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0D3DF5HBETVQHFX32CEADPS/06_spanish_receipt_reprint.png) - Evidence: Portuguese Brazil Web Receipt (local file:/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0D3DF5HBETVQHFX32CEADPS/07_portuguese_receipt_brazil.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:translationsnpm run test:locale-chunksnpm run test:rtl-dashboard-pos-commonnpm run test:receipt-printingnpm run test:bills-print-apinpm run test:currencynpm run test:payment-methods-splitnpm run build:frontendnpm run buildnpx ts-node --transpile-only -P tests/tsconfig.json tests/browser-receipts.test.tscd frontend && EVIDENCE_DIR=/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0D3DF5HBETVQHFX32CEADPS npx playwright test e2e/rtl-dashboard-pos-common.spec.ts✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.