Skip to content

Read the decimal separator from the system with cs_locale - #1562

Open
sneurlax wants to merge 4 commits into
stagingfrom
feat/cs-locale
Open

sneurlax wants to merge 4 commits into
stagingfrom
feat/cs-locale

Conversation

@sneurlax

@sneurlax sneurlax commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Replaces devicelocale with cs_locale, so amounts are typed and shown with the decimal separator the system uses.

Some users see . in Stack Wallet while their system writes numbers with ,. The separator came from looking devicelocale's locale name up in intl, falling back to the language alone. intl has no en_DE or en_NL, so English with a European region got .. On iOS it is broader: an app that declares only English can receive an English language tag even when the system number format uses a comma. Windows was fixed to en_US.

A probe app ran Stack Wallet's lookup next to cs_locale and a number field:

Setup Stack Wallet before cs_locale System
iOS 27 simulator, en / en_DE, en_FR, en_NL . , decimal pad shows ,
iOS, de / de_DE . , decimal pad shows ,
iOS, en_US with separators set apart . , decimal pad shows ,
Android 16 emulator and Android 12 phone, en-DE, en-NL . , Android's format writes , (Gboard shows both keys)
Android 16, system en-US with app locale en-DE . , Android's format writes ,

In every other setup tried (en-US, en-150, de-DE, fr-FR, de_CH) all three agree.

Changes

  • Util.deviceNumberFormat turns the separators the device reports into the key Util.getSymbolsFor takes: the locale itself where intl has the same separators, otherwise a key of its own. A locale requested by name, such as the canonical en_US in wallet_tools.dart, keeps intl's separators.
  • LocaleService reads the device with cs_locale on every platform and follows its change stream, including number-format changes that Flutter does not report.
  • Amount fields relocalize when the number format changes. They also normalize a single alternate . or , decimal-key insertion, covering Android numeric keyboards that do not expose the locale separator, while pasted/grouped input remains rejected.
  • Auto Backup no longer passes the synthetic number-format key to DateFormat, preventing LocaleDataException when a customized number format is active.
  • Desktop wallet fiat prices now rebuild when LocaleService.locale changes.
  • devicelocale is removed from the app templates and native project templates.
  • cs_locale is now the published ^0.1.0 package rather than a temporary Git pin.

Testing

  • 50 locale/amount tests pass, including new regressions for Auto Backup, live desktop fiat-price updates, alternate decimal keys, and IME composition.
  • 237 send-view and transaction-search tests pass.
  • Focused analysis of the changed formatter and regression tests reports no issues. The two edited legacy view files retain only pre-existing info-level diagnostics, none on changed lines.
  • Linux debug native bundle built and launched successfully in both desktop and mobile layouts; startup logs and screenshots were inspected.

Not run here: a physical Android keypad check or full iOS, macOS, and Windows app builds.

@codecov

codecov Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.45070% with 59 lines in your changes missing coverage. Please review.
✅ Project coverage is 20.81%. Comparing base (dcd2d9a) to head (b17bd97).
⚠️ Report is 11 commits behind head on staging.

Files with missing lines Patch % Lines
...p_specific/my_stack_view/wallet_summary_table.dart 23.07% 30 Missing ⚠️
...ings_view/stack_backup_views/auto_backup_view.dart 15.15% 28 Missing ⚠️
lib/services/locale_service.dart 94.44% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           staging    #1562      +/-   ##
===========================================
+ Coverage    20.67%   20.81%   +0.13%     
===========================================
  Files         1148     1148              
  Lines       114416   114505      +89     
===========================================
+ Hits         23653    23831     +178     
+ Misses       90763    90674      -89     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Util.getSymbolsFor looks a locale string up in intl, falling back to its
language. Where the device writes numbers otherwise, as English with a
German region does (intl has no en_DE, so it falls back to en and gives
"."), amounts are typed and shown with the wrong decimal separator while
the system's number keyboard offers ",".

Util.deviceNumberFormat takes the separators the device reports and
returns the key getSymbolsFor gives them by: the locale itself where intl
already has those separators, else a key of its own. A locale asked for
by name, like the canonical "en_US", keeps intl's separators.
devicelocale gives a locale name, from which the decimal separator was
looked up in intl. On iOS an app that declares only English gets English
as its language, so a German iPhone reports en_DE and amounts took "."
while the decimal pad shows ",". In an iOS 27 simulator that happened for
en_DE, en_FR, en_NL, de_DE and separators customized apart from the
region; cs_locale matched the decimal pad in each. Windows was fixed to
en_US.

LocaleService now reads the separators from the system with cs_locale on
every platform, and keys them with Util.deviceNumberFormat. It also
follows the system's announcements, so a number format changed on its
own, which Flutter doesn't report, reaches the amount fields too.

cs_locale is pinned to the 0.1.0 release commit until it is on pub.dev;
0.0.1 fails to configure under this app's Android Gradle plugin.
@sneurlax
sneurlax marked this pull request as ready for review December 3, 2026 23:00
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.

1 participant