japanese yen symbol wrong order before amount bug
Covers yen symbol ordering bugs: use Intl.NumberFormat and drop manual placement. Use it when currency symbols sit wrong for the locale. Not for wrong amounts.
Fix Japanese yen symbol in the wrong order before the amount
TL;DR
Do not hand-place the yen sign, let Intl.NumberFormat position it per ja-JP conventions. Japanese puts the yen mark before the amount with no space, and hand-rolled templates get this wrong for some locales. Use the formatter with currency JPY and the locale, and delete the manual symbol placement.
The error
Template renders "$ 1,000" style output for yen: "Y 1000" or "1000 Y"
expected the Japanese convention for yen amountsFix it
Step 1: See what the formatter produces for ja-JP
node -e "console.log(new Intl.NumberFormat('ja-JP',{style:'currency',currency:'JPY'}).format(1000))"Expected: You see the correct conventional rendering.
Step 2: Find the hand-rolled templates
grep -rn "JPY\|yen" src/utils/money.js | head -8Expected: You see where the symbol is placed manually.
Step 3: Replace manual placement with the formatter
node -e "console.log('delete the template, call the formatter with the order locale and JPY')"Expected: One code path formats every currency.
Step 4: Spot-check a few currencies and locales
node -e "for(const [l,c] of [['ja-JP','JPY'],['en-US','JPY'],['de-DE','EUR']]) console.log(l, new Intl.NumberFormat(l,{style:'currency',currency:c}).format(1000))"Expected: Each renders per its locale convention.
When to use this
- Yen amounts show the symbol in the wrong place
- Currency symbols are placed by hand-rolled templates
When NOT to use this
- The symbol is right but the amount is wrong, check the amount
- You need the symbol after the amount deliberately, that is a design choice not a bug
Tool and version compatibility
- Intl.NumberFormat style currency, JPY
- CLDR currency formatting data
Variant phrasings
same issue with euro placement
Identical fix. de-DE puts the euro sign after the amount, hand templates usually put it before.
accounting format needed
Add currencySign: 'accounting'. Placement still comes from the locale.
Why it happens
Currency symbol position is locale data, not a universal rule. Japanese puts the yen sign before the amount, German puts the euro sign after. Templates written for one locale's convention break the others.
Edge cases
- Narrow vs wide yen sign forms exist, the formatter picks per locale
- Do not parse formatted currency back into numbers, keep the raw amount
- JPY has no minor units, the formatter handles that, templates often add .00 wrongly
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_Wa1WX7Y8LNZ5UwL1NEcLYw