Repository navigation
fix(i18n): honor the requested currency in formatCurrency - #975
Merged
thlpkee20-wq merged 2 commits intoOct 22, 2026
Merged
thlpkee20-wq merged 2 commits into
thlpkee20-wq merged 2 commits into
Conversation
|
@temisan0x Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
3 tasks
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.
Closes #920
What was broken
formatCurrency(value, currency, locale)spread the locale'scurrencysettings over the options after setting the requested currency, so the locale's own currency won.formatCurrency(100, 'USD', 'de-DE')rendered euros, and theja-JPsettings also forced 0 decimals on every currency.What this changes
currencyargument always wins. The locale'sdefaultCurrencyonly applies when no currency is passed.currencyandmaximumFractionDigitsfrom the 8 localecurrencysettings objects.defaultCurrencyalready covers the default, andIntlpicks the right decimals per currency.defaultCurrvariable toresolvedCurrency, since it holds the requested currency, not just the default.Intl's own decimals instead of the locale's: for example KWD and BHD show 3 decimals, KRW shows 0, and USD inja-JPshows 2. Each locale's default currency renders exactly as before; I compared old and new output for all 8 locales.Caller audit
Only
RevenueReportForm,RevenueReportingCalendarandI18nFormatterPreviewuse this helper. The first two pass an explicit currency with a locale, which is the path this fixes. The preview passes no currency, so it is unaffected. The otherformatCurrencyfunctions in the codebase are local to their own components and don't use this one.Tests
Added to
src/constants/i18n.test.ts:USDinde-DEshows$,EURinen-USshows€,GBPinja-JPmatchesIntl)de-DEgives EUR,ja-JPgives JPY)USDinja-JPkeeps cents)Two of these fail on current
master(100,00 €instead of a dollar amount, and$1,234.50for JPY) and pass with the fix.Notes
RevenueReportingCalendar.test.tsxandI18nFormatterPreview/index.test.tsxfail on this branch. I ran the same suites on a cleanmasterand got the same failures, so they are not caused by this change. The preview failure is aRangeErrorfromformatNumberon an invalid locale.tsc --noEmitcurrently fails onmasterbecause of parse errors inTwoFactorSetup.test.tsx. This PR adds no type errors.