Skip to content

feat(presentation): add locale-aware number and currency formatting - #329

Merged
DennisBauer merged 4 commits into
mainfrom
feat/locale-aware-number-formatting
Aug 3, 2026
Merged

feat(presentation): add locale-aware number and currency formatting#329
DennisBauer merged 4 commits into
mainfrom
feat/locale-aware-number-formatting

Conversation

@DennisBauer

Copy link
Copy Markdown
Contributor

fixes: #313

Compose Resources does no Android-style escaping, so the %% in the
string rendered literally as 100%%.
Amounts were built by hand with a fixed '.' separator, no grouping and
the symbol always leading. Each platform now supplies only locale data
(separators, grouping sizes, symbol and percent affixes) derived from
formatter probes; the grouping and assembly stay in commonMain so every
target renders identically and the logic is unit-testable.

Currency symbol and fraction digits keep coming from the server's
Currency, not from the locale, so a currency looks the same everywhere.

Ties round half-up rather than half-to-even as kotlin.math.round does,
which would render 0.125 as 0.12.

Web must pass navigator.languages explicitly: an empty locale list makes
Intl use the browser's UI language, not the content-language preference
the rest of the app follows.
Replaces MoneyFormat, RateFormat and the private formatPercent, epsilon,
roundTo and parseAmount copies, plus three DEFAULT_DECIMALS constants.

Screens read the locale off a CompositionLocal through thin composable
shims, so most call sites keep their shape; ViewModels that seed amount
fields take NumberSymbols as a dependency, which also keeps their tests
off the host locale.

Balance signs move to formatSignedMoney instead of prefixing '+'/'−' by
hand, the add-entry hero puts the symbol on whichever side the locale
wants, and amount fields filter input and accept a pasted grouped
amount.
@DennisBauer DennisBauer added the feature New feature or request label Aug 3, 2026
@DennisBauer
DennisBauer enabled auto-merge August 3, 2026 19:31
@DennisBauer
DennisBauer merged commit b3907d0 into main Aug 3, 2026
3 checks passed
@DennisBauer
DennisBauer deleted the feat/locale-aware-number-formatting branch August 3, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move currency symbol before or after value depending on regional formatting

1 participant