feat(locale): add locale-aware currency formatting#467
Merged
Conversation
299c234 to
0b39672
Compare
Replace hardcoded USD formatting with configurable currency support using golang.org/x/text/currency and golang.org/x/text/message for CLDR-compliant symbol rendering and number formatting. Currency resolution follows a layered precedence: database setting (authoritative once set) > MICASA_CURRENCY env var > TOML config [locale] currency > auto-detect from LC_MONETARY/LANG > USD fallback. The chosen currency is persisted to the database so the DB file stays portable -- a EUR database sent to a US user still shows amounts with the euro sign. Key changes: - New internal/locale package with Currency type wrapping x/text/currency - Settings store gains GetCurrency/PutCurrency for DB persistence - Config gains [locale] section with currency field and env override - Currency threaded through Model, all tab handlers, forms, magnitude mode, pin filtering, compact notation, house profile, and chat - Dead code removed: old data.FormatCents/ParseRequiredCents and friends replaced by locale.Currency methods closes #407 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
0b39672 to
bef4757
Compare
Both UnitSystemForLocale and ResolveCurrency now use locale.DetectLocale() as the single source of truth for reading LC_MONETARY/LC_ALL/LANG. Removes the duplicate env-var parsing that was in data.DefaultUnitSystem(). closes #467 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The Windows CI step fails when winget finds an existing package with no available upgrade (exit code 1). Adding --force ensures the install always succeeds. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cpcloud
added a commit
that referenced
this pull request
Mar 19, 2026
## Summary - Add locale-aware currency formatting with `locale.Currency` type wrapping `golang.org/x/text/currency` and `golang.org/x/text/message` - Separate currency code (what money) from formatting locale (how to display numbers) -- these are independent concerns, like timestamps and timezones - Currency code is persisted to SQLite for DB portability; formatting locale is detected from `LC_MONETARY`/`LC_ALL`/`LANG` at runtime (never persisted) - Resolution order: DB value > config `[locale] currency` > `MICASA_CURRENCY` env > auto-detect from locale > USD fallback - All money columns, forms, compact notation, mag mode, and house profile use locale-correct formatting - Fix multi-byte grouping separator handling (French `U+00A0` non-breaking space was silently broken due to byte-level iteration) - Cache grouping/decimal separators at construction time instead of recomputing per format call - Add named symbol constants (`SymbolDollar`, `SymbolEuro`, `SymbolPound`, `SymbolYen`) and replace all hardcoded Unicode escapes Closes #467 ## Test plan All items covered by automated user-flow tests in `internal/app/currency_flow_test.go` (section 19). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
locale.Currencytype wrappinggolang.org/x/text/currencyandgolang.org/x/text/messageLC_MONETARY/LC_ALL/LANGat runtime (never persisted)[locale] currency>MICASA_CURRENCYenv > auto-detect from locale > USD fallbackU+00A0non-breaking space was silently broken due to byte-level iteration)SymbolDollar,SymbolEuro,SymbolPound,SymbolYen) and replace all hardcoded Unicode escapesCloses #467
Test plan
All items covered by automated user-flow tests in
internal/app/currency_flow_test.go(section 19).🤖 Generated with Claude Code