Skip to content

feat(i18n): add Iran locale display preferences and localize tax and error surfaces - #351

Merged
khaira777 merged 5 commits into
mainfrom
feat/241-iran-locale-policy
Aug 17, 2026
Merged

khaira777 merged 5 commits into
mainfrom
feat/241-iran-locale-policy

Conversation

@khaira777

Copy link
Copy Markdown
Contributor

Intent

Batch G of issue #241 (Persian/Farsi fa-IR and Iran support): make Iran-specific locale behavior explicit, consistent, and tested, and finish i18n for user-facing surfaces. Storage stays raw IRR (Rial) and is never converted. Add display-only Iran locale preferences — currency display (Rial default; opt-in Toman and Toman shorthand that divide by 10), number digits (locale/Persian default; Latin option), and calendar (Shamsi default; Gregorian option) — with a Settings UI shown only for Iran. Centralize formatting through shared formatters and the useFormatCurrency/useFormatNumber/useFormatDate hooks. Fully translate the TaxConfigurationPanel (labels, toasts, confirmations) into en/es/pt/fa, and add a shared apiErrorText/toastApiError helper so raw English backend errors are never shown to users (applied to TaxConfigurationPanel, server-standalone, WhatsApp). Preserve English, Spanish, and Portuguese behavior; do not expose Persian in normal language selectors; do not close #241 (use Refs #241).

What Changed

  • Added Iran locale preferences for currency display (Rial, Toman, Toman shorthand), digit formatting (Persian vs. Latin), and calendar system (Shamsi vs. Gregorian) with Settings controls, backend tenant settings persistence, and centralized formatting helpers.
  • Added apiErrorText and toastApiError error-translation utilities along with centralized useFormatNumber, useFormatCurrency, and useFormatDate hooks to surface localized error messages and locale-aware numbers across dashboard views.
  • Fully translated TaxConfigurationPanel controls, dialogs, and toasts across English, Spanish, Persian, and Portuguese localization files (en.json, es.json, fa.json, pt.json).

Risk Assessment

✅ Low: The change is cleanly bounded, properly keeps IRR storage intact, centralizes display formatting, achieves complete i18n parity across all supported languages, and adds robust unit tests.

Testing

Exercised focused unit suites, integration tests, backend API route validation, translation integrity checks, and browser UI rendering, generating 6 visual screenshot artifacts demonstrating the Iran settings UI and translated TaxConfigurationPanel surfaces.

  • Evidence: Settings Page - Iran Locale Preferences (Rial/Toman, Persian/Latin Digits, Shamsi/Gregorian Calendar) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M08CV7YRXNYEE35XM04YX37Y/iran-locale-preferences-settings.png)
  • Evidence: Settings Page - Non-Iran Business Profile (Iran Section Hidden) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M08CV7YRXNYEE35XM04YX37Y/settings-non-iran-locale-hidden.png)
  • Evidence: Tax Configuration Panel - English (EN) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M08CV7YRXNYEE35XM04YX37Y/tax-configuration-panel-en.png)
  • Evidence: Tax Configuration Panel - Spanish (ES) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M08CV7YRXNYEE35XM04YX37Y/tax-configuration-panel-es.png)
  • Evidence: Tax Configuration Panel - Portuguese (PT) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M08CV7YRXNYEE35XM04YX37Y/tax-configuration-panel-pt.png)
  • Evidence: Tax Configuration Panel - Persian (FA RTL) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M08CV7YRXNYEE35XM04YX37Y/tax-configuration-panel-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:currency (tests/currency.test.ts, tests/country-profile.test.ts, tests/locale-iran.test.ts)
  • npm run test:translations (tests/translations.test.ts)
  • npm run test:rtl-foundation (tests/rtl-foundation.test.ts)
  • npm run test:rtl-setup-auth-settings (tests/rtl-setup-auth-settings.test.ts)
  • npm run test:rtl-dashboard-pos-common (tests/rtl-dashboard-pos-common.test.ts)
  • npm run test:rtl-kds-server-whatsapp (tests/rtl-kds-server-whatsapp.test.ts)
  • npm run test:tax-engine && npm run test:tax-components && npm run test:tax-pack-catalog && npm run test:tax-pack-management && npm run test:manual-tax-config
  • node tests/run-electron-node-test.cjs verify-iran-intent.cjs (57 targeted assertions verifying backend API routes PUT /api/settings/business, PUT /api/settings/:key, GET /api/auth/me, raw IRR storage contract, display-only formatting modes, error sanitization, and language selector restrictions)
  • Headless browser UI execution and screenshot capture across English, Spanish, Portuguese, and Persian (RTL) views
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Add shared formatNumber/formatNumberForTenant helpers and a useFormatNumber hook so counts, points, and dates follow the tenant locale/timezone instead of the browser default. Convert hard-coded English toasts to i18n keys across products, settings, setup, POS, and KDS, and add an Iran locale regression suite.

Refs #241
Add display-only Iran locale preferences (currency_display, number_digits, calendar) with a Settings UI, thread them through the shared formatters, and keep stored amounts as raw IRR. Rial is the default; Toman and Toman shorthand are opt-in display modes that divide by 10.

Refs #241
Add useI18n to the tax configuration panel and convert all labels, toasts, confirm dialogs, entity/action labels, and audit descriptions to translation keys with full key parity across the four supported languages.

Refs #241
Add a shared apiErrorText/toastApiError helper that maps stable reason codes to translations and never shows raw English backend strings. Apply it to the TaxConfigurationPanel, server-standalone, and WhatsApp error paths.

Refs #241
@khaira777
khaira777 requested a review from itsbkm as a code owner August 17, 2026 17:57
@khaira777
khaira777 merged commit 65413d9 into main Aug 17, 2026
10 of 12 checks passed
@khaira777
khaira777 deleted the feat/241-iran-locale-policy branch August 17, 2026 18:08
@khaira777 khaira777 self-assigned this Aug 19, 2026
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.

feat(i18n): add Persian/Farsi and Iran support

1 participant