Skip to content

ui: show numbers and dates in the system region's formats - #7

Closed
pick2510 wants to merge 4 commits into
mainfrom
feat/regional-display-formats
Closed

pick2510 wants to merge 4 commits into
mainfrom
feat/regional-display-formats

Conversation

@pick2510

Copy link
Copy Markdown
Owner

Summary

The grid showed every number and date in en-US conventions, 1,169.00 and 1/1/2024, where Excel on a Swiss Mac shows 1'169.00 and 01.01.2024. In a private corpus of real workbooks (not committed), every amount and date differed from Excel because of this.

  • numfmt::Locale holds the decimal and digit-group separators and the short-date code. Locale::from_tag reads a tag such as de-CH, en_CH or fr_FR.UTF-8, and matches by region first: macOS reports en-CH for English with Swiss formats. Regions covered: CH/LI, DE/AT/LU, FR, GB/IE, IT/ES/BR, NL, JP, CN; anything else is en-US.
  • format_value_in shows a format's . and , with the region's separators (number, General, scientific and fraction sections; quoted literals untouched), and the built-in short date (m/d/yyyy, number format 14, and m/d/yyyy h:mm, 22) as the region's short date. format_value stays en-US.
  • Only the grid uses it, through GridState::number_locale. The app and the snapshot example take the system's region, and snapshot also accepts --locale. Input, the cell editor, files, commands/MCP, CSV and TEXT() stay en-US, so agents and scripts see the same text on every machine. Localized input is a separate step (Feature request: Spanish-localized formula function names and separators storytold/gridcraft#45).
  • docs/localization-parity.md: the stale "en-US only formats" line is corrected (PR de-DE language support: German interface, numbers and formulas storytold/gridcraft#163 was closed).

Tests (built in code)

  • numfmt::tests::regional_display_formats covers:
    • de-CH: 1'169.00, 01.01.2024, the date with time, and the Accounting format;
    • de-DE: 1.234,50, a quoted . kept as a point, General 0,5, scientific 1,23E+06, a fraction with a grouped whole part;
    • fr-FR: narrow no-break-space groups;
    • a custom date code left as written;
    • en-US and unknown regions unchanged;
    • region-first matching (en_CH equals de-CH);
    • format_value still en-US.
  • ui-egui/tests/regional_formats.rs: a grid in en_CH paints 1'169.50 and 01.01.2024 (with the stored code still m/d/yyyy), de-DE paints 1.169,50 and 0,25, and the default paints en-US.

CI

cargo xtask ci: fmt, clippy, assets, layers, wasm, parity and keytips pass, and every test passes except the pre-existing header_autofit::table_filter_autofit_works_through_command_and_header_double_click. That test fails identically on main on this machine with Carlito installed (see #1).

🤖 Generated with Claude Code

bflatastic and others added 3 commits October 22, 2026 17:57
The grid showed every number and date in en-US conventions: 1,169.00
and 1/1/2024 where Excel on a Swiss Mac shows 1'169.00 and 01.01.2024.

numfmt gets a Locale (decimal and digit-group separators, the short
date) from a language tag, matched by region first so macOS's en-CH
gets Swiss formats. format_value_in renders a format's `.` and `,` in
the region's separators and the built-in short date (m/d/yyyy, 14; with
time, 22) as the region's; format_value stays en-US.

Only the grid uses it (GridState::number_locale; the app and the
snapshot example take the system's, snapshot also --locale). Input, the
editor, files, commands, CSV and TEXT() stay en-US.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pick2510
pick2510 force-pushed the feat/regional-display-formats branch from 910c4f1 to b30ca72 Compare October 22, 2026 13:00
The grid shows built-in dates and separators in the system region, but
AutoFit measured the en-US text, so a wider regional date (01.01.2024
vs 1/1/2024) could still show ####. The display region now lives on the
session (Session::display_locale, replacing GridState::number_locale);
the grid draws with it and AutoFit measures with it
(display::cell_text_in). Commands, files and agents stay en-US.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pick2510

Copy link
Copy Markdown
Owner Author

Superseded by storytold#2263 (same branch, opened upstream).

@pick2510 pick2510 closed this Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants