feat(i18n): make Pulse Finances currency-configurable - #1777
Open
takanorinishida wants to merge 1 commit into
Open
feat(i18n): make Pulse Finances currency-configurable#1777takanorinishida wants to merge 1 commit into
takanorinishida wants to merge 1 commit into
Conversation
Finances tab hardcoded $ everywhere, so a non-USD install renders its own currency's amounts as if they were dollars (e.g. an outbound total of ¥2,120,000 shows as "$2.1M" — a 1000x misread, not just a symbol mismatch). - LifeosPrincipal gains an optional `currency` field (ISO 4217), mirrored in the LIFEOS_CONFIG.toml scaffold. Unset defaults to USD, same pattern as the existing optional principal fields. - observability.ts's /api/life/finances envelope now reports the resolved currency (fail-open to "USD" on any config error, matching loadYaml()'s existing contract). - finances/page.tsx resolves a display symbol from that code (a small static table for the four currencies LifeOS ships sample data for, Intl.NumberFormat as best-effort fallback for anything else) and threads it through fmtHero/fmtExact and the trend chart's Y axis, replacing every hardcoded $. - parseCurrencyCell() (INCOME.md/EXPENSES.md table parsing) now strips ¥/€/£/₩/₹ and the word "円" in addition to $, and recognizes 万/億 magnitude suffixes alongside the existing K/M — data additions to an existing table, not new branches. The obligations.yaml legacy-amount parser now reuses this same function instead of a narrower ad hoc regex that silently ignored magnitude suffixes. Currency unset (or explicitly "USD") renders byte-identical to before: the fallback table is checked before Intl, so the default symbol is the same "$" literal this page has always rendered, independent of the server's locale environment. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NVzLJHrJPj5Phmh1vaLUBV
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.
Finances tab hardcoded
$everywhere, so a non-USD install renders its own currency's amounts as if they were dollars (e.g. an outbound total of ¥2,120,000 shows as "$2.1M" — a 1000x misread, not just a symbol mismatch).Changes
LifeosPrincipalgains an optionalcurrencyfield (ISO 4217), mirrored in theLIFEOS_CONFIG.tomlscaffold. Unset defaults to USD, same pattern as the existing optional principal fields.observability.ts's/api/life/financesenvelope now reports the resolved currency (fail-open to"USD"on any config error, matchingloadYaml()'s existing contract).finances/page.tsxresolves a display symbol from that code (a small static table for the four currencies LifeOS ships sample data for,Intl.NumberFormatas best-effort fallback for anything else) and threads it throughfmtHero/fmtExactand the trend chart's Y axis, replacing every hardcoded$.parseCurrencyCell()(INCOME.md/EXPENSES.md table parsing) now strips ¥/€/£/₩/₹ and the word "円" in addition to$, and recognizes 万/億 magnitude suffixes alongside the existing K/M — data additions to an existing table, not new branches. The obligations.yaml legacy-amount parser now reuses this same function instead of a narrower ad hoc regex that silently ignored magnitude suffixes.Non-destructive
Currency unset (or explicitly "USD") renders byte-identical to before: the fallback table is checked before Intl, so the default symbol is the same
"$"literal this page has always rendered, independent of the server's locale environment.Every removed line is either a doc comment or the same original
$-literal line now dispatching throughcurrencySymbol/parseCurrencyCell— same original functions, no removed capability.Verification
[principal] currency = "JPY"set;/api/life/financesreturnscurrency: "JPY", and the tab renders¥2.1Metc. instead of$2.1M.parseCurrencyCell($12,000,~$40K,¥100,000,¥1万,1.2億, ...) all match expected values.🤖 Generated with Claude Code