Skip to content

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

Closed

Description

@khaira777

Context

Discussion: https://github.com/orgs/FreeOpenSourcePOS/discussions/239

A community member requested Persian/Farsi support and suggested adding Iran to the country profile. This issue tracks the work without treating a country entry as complete language support.

Goal

Provide a reliable first-class experience for Iranian businesses using Persian (fa-IR) and the Iran (IR) country profile.

Current status

Persian is implemented end-to-end but not yet selectable by normal users. Final user-facing enablement (Setup/Settings selectors + browser auto-detection) is gated behind Batch J, the acceptance audit. dir="rtl" and <html lang> are wired, and visual RTL is complete across all operational surfaces.

#241 is an umbrella issue. Follow-up PRs must use Refs #241 only and must not close this issue until all acceptance criteria are complete.

Scope

  • Add the Iran country profile with verified locale, currency, timezone, and dialing information.
  • Add Persian/Farsi as a supported UI language.
  • Add a complete Persian translation with the same key coverage as the existing languages.
  • Add RTL document and layout support, including setup, dashboard, POS, KDS, and settings.
  • Verify Persian date, number, currency, and text rendering.
  • Test browser receipts and thermal receipts with Persian text where the printer supports it.
  • Confirm the correct Iranian business identifier terminology (Economic Code, کد اقتصادی).

Known Native Feedback & Decisions

Confirmed (native feedback — #241 comment from MaMaDTHUG82):

  • Iranian Economic Code terminology: کد اقتصادی (abbreviated EC).
  • Economic Code is the useful business identifier; no separate شناسه ملی field is required.
  • Rial and Toman are both understood; Toman is natural in daily use; large prices are often shortened in conversation (e.g. 600T / 600ت).
  • Both Persian and Latin digits are used.
  • Persian/Shamsi calendar is more natural locally; Gregorian is also understood.
  • Full RTL UI is preferred; naturally-LTR content (URLs, email addresses, code, some numbers, technical identifiers) stays explicit LTR.
  • Available thermal printer: Meva TP-UN.

Product decisions (Batch G, final):

  • Stored amounts stay raw IRR and are never converted; Toman is display-only (1 Toman = 10 Rial).
  • Currency display is configurable for Iran only: rial (default), toman, and colloquial toman_short (600T / 600ت).
  • Digit preference is configurable for Iran only: locale (Persian) or Latin.
  • Calendar preference is configurable for Iran only: locale (Shamsi default), Persian, or Gregorian.
  • These options are declared as localeOptions on the IR country profile and render through a generic LocalePreferencesPanel, so non-Iran tenants see no extra UI and EN/ES/PT behavior is unchanged.

Delivery Checklist

Completed

Still pending

  • Native translation completion/review — fa.json is machine-assisted; native linguistic review still required (Settings/WhatsApp/print-test especially).
  • Demo-data language handling audit.
  • Browser receipt support (Batch H).
  • Raw thermal receipt support/fallback (Batch I).
  • Final Persian user-facing enablement + feat(i18n): add Persian/Farsi and Iran support #241 acceptance audit (Batch J) — Setup/Settings selectors + browser auto-detection, only after all prerequisites pass.

Next batches

Batch H — Persian Browser Receipt Support

Make browser/HTML receipt printing correct and readable for Persian/Iran. This covers browser printing only (not raw ESC/POS, except shared formatters). Audit classic/compact/detailed templates, labels, amounts, dates, customer/business info, tax identifiers, payment lines, footer, print CSS, fonts, direction, and mixed bidi. Browser receipts in Persian should support translated labels, RTL content with mixed LTR islands, chosen Iran amount/number/date behavior, and readable data. URLs, phone numbers, invoice/order IDs may need explicit direction handling. Do not convert Persian browser Rial output to IRR merely because raw printers may require that fallback. Verify Persian labels, mixed Persian/Latin content, long product names, large amounts, narrow widths, totals/tax/discount/payment lines, Iran date/number behavior, and EN/ES/PT regressions.

Batch I — Persian Raw Thermal Printing and Safe Fallback

Move beyond the narrow financial-line protection in #273 and determine the correct supported behavior for full Persian thermal receipt printing. Verify the current thermal architecture, encoders, printer profiles, Unicode/code-page behavior, fallback behavior, and known Meva TP-UN capabilities. Investigate character encoding, printer code pages, Persian/Arabic glyph availability, contextual shaping, bidi ordering, raster/image fallback, unsupported-character detection, and printer capability detection. Prefer explicit capability behavior over corrupted output; fail safely or use a documented fallback when a raw printer cannot reliably render Persian. Distinguish code-level tests from real hardware verification (only a real print proves physical output).

Batch J — Final Persian User Enablement and #241 Acceptance Audit

Re-read #241, every comment, Discussion #239, all merged #241 PRs, and current main; build an acceptance matrix (PASS/BLOCKED/FAIL/NEEDS HUMAN VERIFICATION) for every criterion. Do not expose Persian unless all core requirements pass. If ready: add Persian to Setup/Settings language selection, add browser-language detection, verify server-side language persistence and standalone-KDS inheritance, verify changing back to EN/ES/PT, and confirm <html lang>/<html dir> transitions. Update documentation and this issue's checklist. Only this batch may use Fixes #241; otherwise keep #241 open.

Out of scope for the initial language/country contribution

  • This issue does not by itself promise official Iranian tax compliance or a complete Iranian tax pack. Tax rules should be added separately after they are verified.
  • Payment-provider, fiscal e-invoicing, and other Iran-specific integrations are separate work.

Contribution notes

This is broad enough to be split into smaller pull requests after someone takes ownership. A contributor who can provide or review native Persian translations and local tax terminology would be especially valuable. The initial implementation should avoid shipping a partial translation or an untested RTL layout as if support were complete.

Acceptance criteria

  • Persian can be selected during setup and in settings, persists server-side, and is inherited by the standalone KDS.
  • The main POS flows do not expose raw translation keys and render correctly in RTL.
  • Country selection for Iran supplies the expected locale, currency, timezone, and phone dial code.
  • Dates, amounts, and receipts are tested for the chosen Rial/Toman behavior.
  • Unsupported printer capabilities fail safely or use a documented fallback.
  • Existing English, Spanish, and Portuguese behavior remains unchanged.

Activity

  1. added
    enhancement
    help wanted
    on Aug 11, 2026
  2. MaMaDTHUG82 commented on Aug 12, 2026

    @MaMaDTHUG82
    Contributor

    on it

  3. khaira777 commented on Aug 12, 2026

    @khaira777
    ContributorAuthor

    on it

    @MaMaDTHUG82

    Thanks for taking this on. Issue #241 covers several areas, so feel free to break the work into smaller focused PRs if that makes sense.

    Start with the parts you can handle and verify. If you get stuck on anything or the scope feels too large, comment here and we can help split it up or take on a piece.

  4. MaMaDTHUG82 commented on Aug 12, 2026

    @MaMaDTHUG82
    Contributor

    thank you too sir to let me do it , @khaira777

    The fact is that Iranians should feel more comfortable in English ( User Friendly ), that's why we work with English in various programs most of the time.
    Because Persian has not always been in all games or programs

    I translated various parts of the program except for the settings into Persian, because it was really not understandable and even I myself can't figure it out because the meanings are complicated...

    I tried if the writing stays LTR, it won't interfere with the menus

    I want to run this program in my friend's restaurant, I'll definitely send pictures of it later

    And inside Iran, taxes are strange and considering the economy, it doesn't seem to exist at all, businesses with low sales are not taxed and people with high-profit businesses also bypass it, but I'm going to set it in the files

  5. MaMaDTHUG82 commented on Aug 12, 2026

    @MaMaDTHUG82
    Contributor

    fa.json
    i did the #267 , was terrible

  6. MaMaDTHUG82 commented on Aug 12, 2026

    @MaMaDTHUG82
    Contributor

    the dial code looks like india , but instead +91 its +98
    and if LTR with this fa.json makes problems that not so emergence we could pass it , its need alot of time to fix it surly , after that we even could add more LTR languages .
    need a icon for IRR for currency

  7. khaira777 commented on Aug 12, 2026

    @khaira777
    ContributorAuthor

    @MaMaDTHUG82 You actually did a lot of useful work here, especially for a first GitHub contribution. The Persian translation itself is a big contribution - #241 just turned out to touch much more technical plumbing than it looks like from the outside.

    I’m going to help take over the technical integration from here on this same PR so your contribution and authorship stay attached to it. We’ll split the remaining RTL, KDS, formatting and printer work into smaller follow-ups rather than asking you to solve everything at once.

    Your Persian knowledge is the part we need most. Once the technical pieces are wired up, it would be really useful if you could review the wording and eventually test it at your friend’s restaurant like you mentioned.

    Thanks for jumping into this - this is exactly how open-source contributions get built through review and collaboration.

  8. khaira777 commented on Aug 12, 2026

    @khaira777
    ContributorAuthor

    @MaMaDTHUG82 Thanks - your earlier answer about using کد اقتصادی for the Economic Code is clear, so we’ll use that.

    A few more Iran-specific UX questions would help us avoid guessing:

    For restaurant prices and receipts, what feels most natural: ﷼, ریال, or تومان?
    If people usually think in Toman, should FloCafe still store amounts in IRR/Rial and only offer Toman as an optional display?
    For prices, quantities and phone numbers, do users normally expect Persian digits like ۱۲۳۴ or Latin digits like 1234?
    For dates, would you expect the Persian/Shamsi calendar, Gregorian, or an option for both?
    Is keeping the current layout LTR temporarily still usable enough for you while we work on full RTL separately?
    If your friend’s restaurant has a thermal printer, could you tell us the printer model? That would help later with real Persian receipt testing.

    One more small question: for an Iranian restaurant receipt/settings page, is کد اقتصادی enough as the business identifier, or would شناسه ملی normally also need to appear as a separate field?

    No need to research legal rules for us - just tell us what feels normal in real use. We’ll verify tax/compliance separately.

  9. 21 remaining items

  10. khaira777 commented on Aug 17, 2026

    @khaira777
    ContributorAuthor

    Batch D — Setup, Auth, and Settings RTL completion (PR #337)

    PR #337 (Refs #241) makes Setup, the auth screens, and Settings visually usable in Persian RTL using the shared RTL/LTR foundation from PR #336.

    What changed

    • Converted physical left/right Tailwind utilities to logical (ms/me/ps/pe/start/end/text-start/text-end/border-s/border-e) across the Setup wizard, login/recover pages, the Settings page, and the Settings components (TaxConfigurationPanel, PaymentMethodsSettings, InitializeDatabaseDialog, HealthCheckDialog).
    • Flipped directional back/forward arrows with the shared .rtl-flip class so they mirror in RTL.
    • Made Settings toggles (admin/loyalty/discount) mirror in RTL via the built-in rtl: variant.
    • Isolated naturally-LTR values in <Ltr> islands so they stay readable inside RTL UI: URLs, emails, pairing codes, version strings, tax/Economic Code, phone numbers, timezone/currency codes, IP addresses, and technical identifiers (category/rule ids, invoice/order number previews). Technical inputs get dir="ltr".
    • Persian stays hidden from Setup/Settings language selectors — no enablement in this batch.

    Verification

    • tests/rtl-setup-auth-settings.test.ts (static direction-utility guard + <Ltr> polymorphic render checks) registered in npm test.
    • Playwright e2e spec asserting rendered dir=rtl/dir=ltr, LTR islands, and no horizontal overflow in RTL.
    • Root + frontend tsc --noEmit, frontend + backend lint, build:frontend (validates rtl: variant + .rtl-flip output), build, full PR CI (linux-tests, e2e-playwright, CodeQL, dependency-review) — all pass. no-mistakes pipeline: 0 findings.

    Still required before Persian enablement

    • Native Persian review of machine-assisted wording.
    • RTL work for Dashboard/POS/KDS screens (deferred to later batches).
    • Locale UX decisions (Rial/Toman display, digits, Shamsi vs Gregorian).
    • Final Persian enablement in Setup/Settings selectors + browser auto-detection (last step).
  11. khaira777 commented on Aug 17, 2026

    @khaira777
    ContributorAuthor

    Batch G — Iran locale, number, currency, and calendar policy (final)

    Policy (decided with maintainer — supersedes the earlier Rial-only draft):

    • Stored amounts stay raw IRR and are never converted. Toman is display-only (1 Toman = 10 Rial).
    • Currency display is configurable for Iran only: rial (default), toman, and colloquial toman_short (600T / 600ت).
    • Digit preference is configurable for Iran only: locale (Persian) or Latin.
    • Calendar preference is configurable for Iran only: locale (Shamsi default), Persian, or Gregorian.
    • These options are declared as localeOptions on the IR country profile and render through a generic LocalePreferencesPanel, so non-Iran tenants see no extra UI and EN/ES/PT behavior is unchanged.

    What changed:

    • Centralized formatMoney / formatNumber / formatDateForTenant in the shared country module plus useFormatCurrency / useFormatNumber hooks.
    • Removed page-specific locale forks so counts/points/dates follow the tenant locale + timezone instead of the browser default.
    • Region-driven locale preferences UI (PR feat(i18n): drive region locale preferences from country profile #352).
    • tests/locale-iran.test.ts covering IR amounts (zero/negative/large), no-Toman-conversion, digits, Shamsi dates, the Asia/Tehran midnight boundary, and unchanged non-IR tenants. Wired into test:currency.

    User-facing error i18n (fixed):

    • TaxConfigurationPanel and the standalone server app are fully localized.
    • PR fix(i18n): replace raw error string interpolation with localized fallbacks #353 swept ~50 sites so failure toasts/inline errors render localized t() fallbacks instead of raw English backend error/message strings. Backend, logs, and telemetry keep English; users never see raw English strings. Added localize-error-fallbacks.spec.ts e2e coverage (26 assertions across fa/es/pt/en).
    • web-print.ts popup toast intentionally deferred to Batch H (browser receipts).

    Verification: root + frontend tsc --noEmit, frontend + backend lint, build, build:frontend, test:currency, test:translations, and full PR CI (linux-tests, e2e-playwright, CodeQL, dependency-review) all pass. Persian wording remains machine-assisted and still needs native review.

  12. khaira777 commented on Aug 17, 2026

    @khaira777
    ContributorAuthor

    Batch I — Persian raw thermal printing & safe fallback

    Implemented and committed on feat/241-i-persian-thermal-fallback (44113e7); no-mistakes pipeline is running async (PR link to be added when it opens).

    What changed

    • Added an explicit arabicShaping capability flag to printer profiles (main/printers/profiles.ts), defaulting to off.
    • Threaded it through every raw ESC/POS encoder — receipt (classic/compact), plugin template (renderEscposLineTemplateV1), and KOT — in main/printers/thermal.ts.
    • buildEscPos now emits Arabic/Persian script only when the profile declares arabicShaping; otherwise the line is skipped with a precise warning naming the cause. Mixed Persian + other non-ASCII lines are always skipped, even with the flag.
    • fix(printer): preserve IR raw ESC/POS financial lines and layout bounds #273 financial-line safety is preserved behind the same gate: ریال → IRR ASCII fallback keeps amounts printing on generic hardware.
    • Frontend WebUSB encoder (warnings.ts) warning now names Persian/Arabic script instead of the generic "unsupported characters".

    Behavior (deterministic, tested)

    • ASCII/Latin financial fallback preserved (IRR amounts, narrow widths, large values).
    • Persian without the flag: skipped + precise warning (no corrupted/unshaped output).
    • Persian with arabicShaping: true: emitted as UTF-8.
    • Mixed-script: skipped regardless.
    • 296 printer tests + 150 tax-pack-management tests pass; tsc build and lint clean.

    Hardware boundary (needs human verification)

    • No Meva TP-UN capability info exists in the repo. Generic ESC/POS firmware does not shape Arabic/Persian, so the safe default stays "skip Arabic + ASCII currency." Only set arabicShaping: true on a profile after a real print on that hardware proves shaped Persian output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementhelp wanted

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions