[PR #5797] [MERGED] feat(currency): Currency-influenced initial number formats #6126

Closed
opened 2026-02-28 21:24:19 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/5797
Author: @StephenBrown2
Created: 9/26/2025
Status: Merged
Merged: 10/7/2025
Merged by: @matt-fidd

Base: masterHead: currency-number-formats


📝 Commits (10+)

  • 01b4ae0 Adds numberFormat and symbolFirst to currency definitions
  • ce92a02 Replace standard non-breaking space (\u00A0) with narrow nbsp (\u202F).
  • 55635f8 Sets number format based on currency selection
  • 13125be yarn generate:release-notes
  • d2661df Code Rabbit suggestion
  • eabb2eb Code Rabbit follow-up
  • 85c9e92 Configures space enabled preference for currency
  • c0083ce Updates currency data with locale-specific format comments
  • e85bd23 Re-run Tests
  • bf908f4 Replaces nbsp with narrow no-break space for spaceEnabledPref

📊 Changes

8 files changed (+82 additions, -50 deletions)

View changed files

📝 packages/desktop-client/src/components/settings/Currency.tsx (+18 -6)
📝 packages/desktop-client/src/hooks/useFormat.ts (+2 -2)
📝 packages/loot-core/src/shared/arithmetic.test.ts (+1 -1)
📝 packages/loot-core/src/shared/arithmetic.ts (+1 -1)
📝 packages/loot-core/src/shared/currencies.ts (+43 -33)
📝 packages/loot-core/src/shared/util.test.ts (+3 -3)
📝 packages/loot-core/src/shared/util.ts (+8 -4)
upcoming-release-notes/5797.md (+6 -0)

📄 Description

This pull request enhances the currency settings functionality by setting initial number format, symbol position, and fraction display based on the selected currency. It does this by including more metadata in the Currency type, updates parsing and formatting logic for better locale support, and enables Japanese Yen as a currency.

Currency settings improvements:

  • When a user selects a currency in CurrencySettings, the app now automatically updates the number format, symbol position, and fraction display preferences based on the selected currency's metadata. Users can still adjust these settings afterward. (Currency.tsx, currencies.ts, util.ts) [1] [2] [3]
  • The user-facing description in the currency settings UI is updated to clarify that changing the currency also updates number format, symbol position, and fraction display, but these can be adjusted later. (Currency.tsx)

Currency metadata and support:

  • The Currency type now includes new fields: numberFormat and symbolFirst. This enables more accurate locale-specific formatting. (currencies.ts) [1]
    • Also sorts the currencies list so that e.g., EGP, JPY, QAR, SAR are in the right alphabetical order [2]
  • The translation map in Currency.tsx is updated to match the sort order of currencies and corrects the label for Japanese Yen. (Currency.tsx)

Number formatting and parsing enhancements:

  • Number format types are now exported, and the logic for handling space-based thousands separators is updated to use the correct Unicode narrow no-break space (\u202F), improving support for locales like Polish, Russian, and Ukrainian. (util.ts, arithmetic.ts) [1] [2] [3] [4]
    • arithmetic.ts is updated to include both regular NBSP and narrow NBSP characters in the regex, as unicode formatted points.

Documentation:

  • Release notes are updated to reflect the new enhancement. (upcoming-release-notes/5797.md)

Demonstration

https://github.com/user-attachments/assets/b8e6f3de-58e7-4a69-9746-3b00e3ee3ac9

NOTE: I also added the space-symbol separator setting after making this screen recording. The change adds a space if the symbol would come after the number, and no space if before.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/actualbudget/actual/pull/5797 **Author:** [@StephenBrown2](https://github.com/StephenBrown2) **Created:** 9/26/2025 **Status:** ✅ Merged **Merged:** 10/7/2025 **Merged by:** [@matt-fidd](https://github.com/matt-fidd) **Base:** `master` ← **Head:** `currency-number-formats` --- ### 📝 Commits (10+) - [`01b4ae0`](https://github.com/actualbudget/actual/commit/01b4ae06bba233355a462b43eed6c8a8b9b5aaa3) Adds numberFormat and symbolFirst to currency definitions - [`ce92a02`](https://github.com/actualbudget/actual/commit/ce92a02ea81fd796934143c214f6e253b461206f) Replace standard non-breaking space (\u00A0) with narrow nbsp (\u202F). - [`55635f8`](https://github.com/actualbudget/actual/commit/55635f83294988f570040b777b2b6979fbb969e6) Sets number format based on currency selection - [`13125be`](https://github.com/actualbudget/actual/commit/13125becab8c66b73971dca897c7b608c36ac714) yarn generate:release-notes - [`d2661df`](https://github.com/actualbudget/actual/commit/d2661df496915c26e2384b4d30fdaf7a2fc63341) Code Rabbit suggestion - [`eabb2eb`](https://github.com/actualbudget/actual/commit/eabb2ebfc6363a5a54e557ca8913c45aded3ee0c) Code Rabbit follow-up - [`85c9e92`](https://github.com/actualbudget/actual/commit/85c9e9276ee683ce7c06c70d44b824f9eda16b4b) Configures space enabled preference for currency - [`c0083ce`](https://github.com/actualbudget/actual/commit/c0083cee2ed973107248644a29fe6706836e5b46) Updates currency data with locale-specific format comments - [`e85bd23`](https://github.com/actualbudget/actual/commit/e85bd23c477c6cee9e5c57e649a9ea5a3d38b4e9) Re-run Tests - [`bf908f4`](https://github.com/actualbudget/actual/commit/bf908f44471fd86fe28826c0e74e94540525e5b5) Replaces nbsp with narrow no-break space for spaceEnabledPref ### 📊 Changes **8 files changed** (+82 additions, -50 deletions) <details> <summary>View changed files</summary> 📝 `packages/desktop-client/src/components/settings/Currency.tsx` (+18 -6) 📝 `packages/desktop-client/src/hooks/useFormat.ts` (+2 -2) 📝 `packages/loot-core/src/shared/arithmetic.test.ts` (+1 -1) 📝 `packages/loot-core/src/shared/arithmetic.ts` (+1 -1) 📝 `packages/loot-core/src/shared/currencies.ts` (+43 -33) 📝 `packages/loot-core/src/shared/util.test.ts` (+3 -3) 📝 `packages/loot-core/src/shared/util.ts` (+8 -4) ➕ `upcoming-release-notes/5797.md` (+6 -0) </details> ### 📄 Description This pull request enhances the currency settings functionality by setting initial number format, symbol position, and fraction display based on the selected currency. It does this by including more metadata in the Currency type, updates parsing and formatting logic for better locale support, and enables Japanese Yen as a currency. **Currency settings improvements:** * When a user selects a currency in `CurrencySettings`, the app now automatically updates the number format, symbol position, and fraction display preferences based on the selected currency's metadata. Users can still adjust these settings afterward. (`Currency.tsx`, `currencies.ts`, `util.ts`) [[1]](diffhunk://#diff-9b0bd6bc744bfd4afac03d8e6db423fa69216ff2dac2272f2a5dba73494e14ccR65-R66) [[2]](diffhunk://#diff-9b0bd6bc744bfd4afac03d8e6db423fa69216ff2dac2272f2a5dba73494e14ccR88-L87) [[3]](diffhunk://#diff-9b0bd6bc744bfd4afac03d8e6db423fa69216ff2dac2272f2a5dba73494e14ccL174-R181) * The user-facing description in the currency settings UI is updated to clarify that changing the currency also updates number format, symbol position, and fraction display, but these can be adjusted later. (`Currency.tsx`) **Currency metadata and support:** * The `Currency` type now includes new fields: `numberFormat` and `symbolFirst`. This enables more accurate locale-specific formatting. (`currencies.ts`) [[1]](diffhunk://#diff-e58604b34393a62d237d3e6c3c8f02502c9c3857eabb3be763b2e5a47c185068R8-R9) * Also sorts the `currencies` list so that e.g., EGP, JPY, QAR, SAR are in the right alphabetical order [[2]](diffhunk://#diff-9b0bd6bc744bfd4afac03d8e6db423fa69216ff2dac2272f2a5dba73494e14ccR29-L49) * The translation map in `Currency.tsx` is updated to match the sort order of `currencies` and corrects the label for Japanese Yen. (`Currency.tsx`) **Number formatting and parsing enhancements:** * Number format types are now exported, and the logic for handling space-based thousands separators is updated to use the correct Unicode narrow no-break space (`\u202F`), improving support for locales like Polish, Russian, and Ukrainian. (`util.ts`, `arithmetic.ts`) [[1]](diffhunk://#diff-38e21533cdabf107724be33472d5cca2ebda693ca957e11885b3a515e5f355cfL267-R267) [[2]](diffhunk://#diff-38e21533cdabf107724be33472d5cca2ebda693ca957e11885b3a515e5f355cfL280-R284) [[3]](diffhunk://#diff-38e21533cdabf107724be33472d5cca2ebda693ca957e11885b3a515e5f355cfL330-R334) [[4]](diffhunk://#diff-f00ab63a0b721dd9afc0e9f181bc480d0c002c255e741c37c596e7a2b14212a8L41-R41) * `arithmetic.ts` is updated to include both regular NBSP and narrow NBSP characters in the regex, as unicode formatted points. **Documentation:** * Release notes are updated to reflect the new enhancement. (`upcoming-release-notes/5797.md`) **Demonstration** https://github.com/user-attachments/assets/b8e6f3de-58e7-4a69-9746-3b00e3ee3ac9 NOTE: I also added the space-symbol separator setting after making this screen recording. The change adds a space if the symbol would come after the number, and no space if before. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-02-28 21:24:19 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#6126