feat(analysis): localize bill tooltip copy and make number formatting locale-aware - #38
Merged
Merged
Conversation
… locale-aware Claude-Session: https://claude.ai/code/session_01URDpaxhXyPLWnUQtvowNyM
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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 #12 — the formatter/tooltip half. The auth-email half landed in #37.
Two genuinely English-only surfaces in a trilingual app
1.
BILL_TOOLTIPS/NEM_TOOLTIPSwere hardcoded English inlib/formatters.ts— twelve explanatory strings about TNB tariff components and NEM credit flow, rendered through<InfoTooltip>next to labels that were translated. A Malay or Chinese user saw a localized label with an English explanation.Moved into
analysis.jsonunderbillBreakdown.tooltipsandbillBreakdown.nemTooltips, translated formsandzh, and routed throught(). OnlyBillBreakdown.tsxconsumed them, so the change is contained. Key structure verified identical across locales (305 keys each).2. Both
Intl.NumberFormats were pinned to'en-MY'— so currency and number grouping ignored the user's language entirely, even thoughLOCALE_TO_INTLalready existed for exactly this and mapszhtozh-Hans-MY.setFormatterLocale()now rebuilds them, called fromLocaleProvideron mount and on every change. A setter rather than a per-call argument because these formatters have ~100 call sites; threading a locale through all of them would be a far larger diff than the behaviour warrants.Proof it actually varies:
Incidental extraction, and why it was necessary
Importing
LOCALE_TO_INTLfromi18n.tsbrokeAnalysisPage.test.tsx:i18n.tscallsi18n.init()at module scope, so any importer drags that in, and a test that mocks i18n was suddenly loading the real one.Rather than duplicating the map and inviting drift, the locale constants (
SUPPORTED_LOCALES,SupportedLocale,DEFAULT_LOCALE,LOCALE_STORAGE_KEY,LOCALE_TO_INTL,isSupportedLocale) moved to a side-effect-freelib/locales.ts.i18n.tsre-exports them, so every existing importer is unaffected.Correction to an earlier claim
#37's description said "nothing persists
User.localeyet, so production still sends English." That was wrong.useLocale.tsx:83already callsauthClient.updateUser({ locale: next })and reads it back on mount, andconfig/auth.tspasses it to the email renderers. The localized-email chain has been live end to end since #37 merged.Verified
pnpm --filter frontend exec tsc --noEmit0 errors · 216 frontend tests pass · Prettier clean · noBILL_TOOLTIPS/NEM_TOOLTIPSreferences remain.https://claude.ai/code/session_01URDpaxhXyPLWnUQtvowNyM