Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicitSign parameter to all NumberFormats #940

Open
Albert221 opened this issue Jan 30, 2025 · 1 comment
Open

Add explicitSign parameter to all NumberFormats #940

Albert221 opened this issue Jan 30, 2025 · 1 comment
Labels
package:intl type-enhancement A request for a change that isn't a bug

Comments

@Albert221
Copy link

Albert221 commented Jan 30, 2025

Is your feature request related to a problem? Please describe.
Let's say I'm building an app that shows a number difference, percentage or just a number. If the number is positive, I want to have the plus sign.

Describe the solution you'd like
NumberFormat.decimalPattern, .decimalPatternDigits, .decimalPercentPattern, percentPattern, simpleCurrency, currency, compactCurrency, the default constructor and maybe the scientificPattern (here I'm not sure) shall all have explicitSign constructor parameter. If they can display a minus sign for negative numbers, I don't see why only compact formats should be able to also show a plus sign for non-negative numbers. And this should be a constructor parameter and not only a mutable property on the NumberFormat, because I want to use this not only in code but also in flutter gen-l10n with ARB format and optionalParameters where I could set this flag to true.

Describe alternatives you've considered
Keeping two translation keys, one with a hardcoded plus sign, or passing a string to the translation, with a manually added plus sign.

Additional context
https://pub.dev/documentation/intl/latest/intl/NumberFormat-class.html

@Albert221 Albert221 added the type-enhancement A request for a change that isn't a bug label Jan 30, 2025
@mosuem
Copy link
Member

mosuem commented Jan 31, 2025

Implementing this in package:intl is probably possible, happy to accept a PR ;)

For this to work with the ARB format, this should be included in the ARB spec, so that any ARB users could profit. The spec is currently hosted at https://github.com/google/arb-editor/blob/main/schemas/arb.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:intl type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants