Repository navigation
feat(i18n): add Iran locale display preferences and localize tax and error surfaces - #351
Merged
Merged
Conversation
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
18 tasks done
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
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
apiErrorTextandtoastApiErrorerror-translation utilities along with centralizeduseFormatNumber,useFormatCurrency, anduseFormatDatehooks to surface localized error messages and locale-aware numbers across dashboard views.TaxConfigurationPanelcontrols, 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.
/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M08CV7YRXNYEE35XM04YX37Y/iran-locale-preferences-settings.png)/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M08CV7YRXNYEE35XM04YX37Y/settings-non-iran-locale-hidden.png)/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M08CV7YRXNYEE35XM04YX37Y/tax-configuration-panel-en.png)/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M08CV7YRXNYEE35XM04YX37Y/tax-configuration-panel-es.png)/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M08CV7YRXNYEE35XM04YX37Y/tax-configuration-panel-pt.png)/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-confignode tests/run-electron-node-test.cjs verify-iran-intent.cjs(57 targeted assertions verifying backend API routesPUT /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.