You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add locale-aware currency and date/time formatting #22
Hey @khaira777, ran a quick comparison for the formatCurrency swap in this issue. Note: main/countries.json is the current shared config I'm working on so we keep one implementation for both back and front.
For each country I formatted a sample amount using the standard Intl call:
newIntl.NumberFormat(country.locale,{style: 'currency',currency: country.currency,// ISO code, e.g. 'INR'}).format(amount)
Then compared the resulting symbol against country.currencyCode from main/countries.json. 19 of 36 match, 17 differ.
CODE | NAME | LOCALE | ISO | STORED | INTL | STATUS
-----+----------------------+----------+-------+----------+----------+-------
IN | India | en-IN | INR | ₹ | ₹ | OK
AR | Argentina | es-AR | ARS | AR$ | $ | DIFF
US | United States | en-US | USD | $ | $ | OK
CA | Canada | en-CA | CAD | C$ | $ | DIFF
GB | United Kingdom | en-GB | GBP | £ | £ | OK
EU | European Union | fr-FR | EUR | € | € | OK
TH | Thailand | th-TH | THB | ฿ | ฿ | OK
SG | Singapore | en-SG | SGD | S$ | $ | DIFF
MY | Malaysia | ms-MY | MYR | RM | RM | OK
ID | Indonesia | id-ID | IDR | Rp | Rp | OK
PH | Philippines | en-PH | PHP | ₱ | ₱ | OK
VN | Vietnam | vi-VN | VND | ₫ | ₫ | OK
AU | Australia | en-AU | AUD | A$ | $ | DIFF
NZ | New Zealand | en-NZ | NZD | NZ$ | $ | DIFF
AE | United Arab Emirates | ar-AE | AED | د.إ | د.إ. | DIFF
SA | Saudi Arabia | ar-SA | SAR | ﷼ | ر.س. | DIFF
ZA | South Africa | en-ZA | ZAR | R | R | OK
KE | Kenya | en-KE | KES | KSh | Ksh | DIFF
NG | Nigeria | en-NG | NGN | ₦ | ₦ | OK
BR | Brazil | pt-BR | BRL | R$ | R$ | OK
MX | Mexico | es-MX | MXN | MX$ | $ | DIFF
CL | Chile | es-CL | CLP | CLP$ | $ | DIFF
UY | Uruguay | es-UY | UYU | UYU$ | $ | DIFF
PY | Paraguay | es-PY | PYG | ₲ | Gs. | DIFF
JP | Japan | ja-JP | JPY | ¥ | ¥ | DIFF
KR | South Korea | ko-KR | KRW | ₩ | ₩ | OK
CN | China | zh-CN | CNY | ¥ | ¥ | OK
HK | Hong Kong | zh-HK | HKD | HK$ | HK$ | OK
TW | Taiwan | zh-TW | TWD | NT$ | $ | DIFF
PK | Pakistan | en-PK | PKR | Rs | Rs | OK
BD | Bangladesh | bn-BD | BDT | ৳ | ৳ | OK
LK | Sri Lanka | en-LK | LKR | Rs | LKR | DIFF
NP | Nepal | ne-NP | NPR | Rs | नेरू | DIFF
EG | Egypt | ar-EG | EGP | E£ | ج.م. | DIFF
IL | Israel | he-IL | ILS | ₪ | ₪ | OK
TR | Turkey | tr-TR | TRY | ₺ | ₺ | OK
Diffs cluster into a few patterns:
Multi-$ loses prefix in en-locales: 9 currencies drop to plain $. For the American countries (AR, MX, CL, UY) using plain $ is fine: a receipt for a customer in Buenos Aires, Mexico City, Santiago, or Montevideo already reads as local currency because of the locale and grouping, and the disambiguation prefix only matters when receipts sit side-by-side across countries.
PY uses Gs. not ₲: Intl drops the dedicated guaraní sign (U+20B2) and uses the Gs. abbreviation instead. Customers in Asunción read Gs. as guaraní the same way Swedes read kr for krona, so this is fine.
Symbol drift in JSON: LK Rs → LKR, NP Rs → नेरू (Intl fixes these)
The grouping and decimal separators are nice side effects: IN uses lakh style (₹12,34,567.89), AE/SA/EG use Arabic-Indic digits, BR flips to . and ,, PY drops decimals because PYG is conventionally shown without them.
Net breakdown if we accept the LatAm trade-off: 5 LatAm rows OK as-is (AR, MX, CL, UY with plain $, PY with Gs.), 5 multi-$ still to discuss (CA, SG, AU, NZ, TW), 3 Arabic, 2 case/width, 2 fixed-by-Intl.
About the American countries (AR, MX, CL, UY, PY): it is fine to use Intl's output there. For AR/MX/CL/UY that means plain $ instead of AR$, MX$, CLP$, UYU$; for PY it means Gs. instead of ₲. Customers in those markets already read these as their local currency thanks to the locale (es-AR, es-MX, es-CL, es-UY, es-PY) and the grouping ($ 1.234.567,89 for AR/UY, $1,234,567.89 for MX/CL, Gs. 1.234.568 for PY). The prefixes and the dedicated ₲ glyph are only useful when receipts sit side-by-side across countries or against a reference document, which is not a real scenario for a single-tenant POS. So those 5 rows can drop the custom symbol without losing meaning.
Before I swap the implementation: are the remaining 12 symbol differences (CA, SG, AU, NZ, TW, AE, SA, EG, KE, JP, LK, NP) acceptable, or do you want a hybrid that uses Intl for grouping/decimals but falls back to the stored currencyCode for those rows?
Hey @carvalab, your analysis is spot on. I agree that cross-country disambiguation isn't really a concern for local in-person receipts. Feel free to proceed with the pure Intl.NumberFormat implementation. Thanks again with your incredible contribution!
Activity
khaira777 commentedon Jul 6, 2026
Part of epic #18 — Internationalization
feat(i18n): country profiles, language-first wizard, Argentina IVA
feat(i18n): country profiles, language-first wizard, Argentina IVA
carvalab commentedon Jul 15, 2026
Hey @khaira777, ran a quick comparison for the
formatCurrencyswap in this issue. Note:main/countries.jsonis the current shared config I'm working on so we keep one implementation for both back and front.For each country I formatted a sample amount using the standard Intl call:
Then compared the resulting symbol against
country.currencyCodefrommain/countries.json. 19 of 36 match, 17 differ.Diffs cluster into a few patterns:
$loses prefix in en-locales: 9 currencies drop to plain$. For the American countries (AR, MX, CL, UY) using plain$is fine: a receipt for a customer in Buenos Aires, Mexico City, Santiago, or Montevideo already reads as local currency because of the locale and grouping, and the disambiguation prefix only matters when receipts sit side-by-side across countries.Gs.not₲: Intl drops the dedicated guaraní sign (U+20B2) and uses theGs.abbreviation instead. Customers in Asunción readGs.as guaraní the same way Swedes readkrfor krona, so this is fine.د.إ→د.إ., SA﷼→ر.س., EGE£→ج.م.KSh→Ksh, JP¥→¥Rs→LKR, NPRs→नेरू(Intl fixes these)The grouping and decimal separators are nice side effects: IN uses lakh style (
₹12,34,567.89), AE/SA/EG use Arabic-Indic digits, BR flips to.and,, PY drops decimals because PYG is conventionally shown without them.Net breakdown if we accept the LatAm trade-off: 5 LatAm rows OK as-is (AR, MX, CL, UY with plain
$, PY withGs.), 5 multi-$still to discuss (CA, SG, AU, NZ, TW), 3 Arabic, 2 case/width, 2 fixed-by-Intl.About the American countries (AR, MX, CL, UY, PY): it is fine to use Intl's output there. For AR/MX/CL/UY that means plain
$instead ofAR$,MX$,CLP$,UYU$; for PY it meansGs.instead of₲. Customers in those markets already read these as their local currency thanks to the locale (es-AR, es-MX, es-CL, es-UY, es-PY) and the grouping ($ 1.234.567,89for AR/UY,$1,234,567.89for MX/CL,Gs. 1.234.568for PY). The prefixes and the dedicated₲glyph are only useful when receipts sit side-by-side across countries or against a reference document, which is not a real scenario for a single-tenant POS. So those 5 rows can drop the custom symbol without losing meaning.Before I swap the implementation: are the remaining 12 symbol differences (CA, SG, AU, NZ, TW, AE, SA, EG, KE, JP, LK, NP) acceptable, or do you want a hybrid that uses Intl for grouping/decimals but falls back to the stored
currencyCodefor those rows?khaira777 commentedon Jul 15, 2026
Hey @carvalab, your analysis is spot on. I agree that cross-country disambiguation isn't really a concern for local in-person receipts. Feel free to proceed with the pure
Intl.NumberFormatimplementation. Thanks again with your incredible contribution!fix(printer): use locale for all date formatting and add useFormatDat…
khaira777 commentedon Jul 18, 2026