Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Add [[PluralRules]] internal slot like Intl.RelativeTimeFormat #86

Closed
longlho opened this issue Jan 5, 2020 · 7 comments
Closed

Add [[PluralRules]] internal slot like Intl.RelativeTimeFormat #86

longlho opened this issue Jan 5, 2020 · 7 comments
Labels
future Issue is valid but will not be prioritized currently

Comments

@longlho
Copy link
Contributor

longlho commented Jan 5, 2020

I'm confused by some of the results so looking for guidance. E.g:

new Intl.NumberFormat('en', { style: 'currency', currencyDisplay: 'name', currency: 'GBP'}).format(1)
// 1.00 British pounds

I would expect it to be 1 British pound especially since new Intl.PluralRules('en').select('1.00') yields one.

The other confusion is around scientific notation and whether the plural rules should use the whole number or the mantissa.

Thanks!

@sffc
Copy link
Collaborator

sffc commented Jan 5, 2020

Related: #64, #80

When scientific or compact notation is used, the whole number should be considered in Intl.PluralRules. For example, "1K" should get the plural form of 1000. A few locales have special rules for such numbers, which is being addressed in ICU-13836.

The behavior "1.00 British pounds" is correct. You get that out of Intl.PluralRules if you pass in the correct option:

new Intl.PluralRules('en', { minimumFractionDigits: 2 }).select(1)
// "other"

I'll need to check the spec for what the behavior is supposed to be when you pass the currency options bag to Intl.PluralRules.

@sffc sffc added the question Further information is requested label Jan 5, 2020
@longlho
Copy link
Contributor Author

longlho commented Jan 6, 2020

Thanks that fixes it! What's your thought on introducing an internal [[PluralRules]] in NumberFormat (similar to Intl.RelativeTimeFormat here). That would clear out the options bag for PL. Right now the spec is fairly ambiguous when it comes to plural selection in unit/currency/compact.

@sffc
Copy link
Collaborator

sffc commented Jan 8, 2020

That's a good idea. This would be a larger change than I'm interested in doing with Unified NumberFormat currently, because we already have significant changes from Stage 3. I'll label this as "future" and we can do a follow-on Editorial PR to clean this up and make the behavior less ambiguous.

@sffc sffc added future Issue is valid but will not be prioritized currently and removed question Further information is requested labels Jan 8, 2020
@sffc sffc changed the title How should notation & currency impact PluralRules ? Add [[PluralRules]] internal slot like Intl.RelativeTimeFormat Jan 8, 2020
@longlho
Copy link
Contributor Author

longlho commented Jan 8, 2020

Cool sgtm!

@longlho
Copy link
Contributor Author

longlho commented Jan 8, 2020

Another question:

new Intl.NumberFormat('en', {
  style: 'currency', 
  currency: 'ZWD', 
  currencyDisplay: 'name', 
  notation: 'scientific'
}).format(10000)
// '1E4 Zimbabwean dollar (1980–2008)'

instead of +1E4 Zimbabwean dollars (1980–2008) (seems like the mantissa dictates the plural form in this case?)

@sffc
Copy link
Collaborator

sffc commented Jan 9, 2020

That's an ICU bug being addressed in https://unicode-org.atlassian.net/browse/ICU-13836 (the bug says "compact notation", but it also applies to scientific notation).

Here is the PR to fix it: unicode-org/icu#938

@sffc
Copy link
Collaborator

sffc commented Mar 23, 2020

Upstream issue for potential remaining work items on this issue:

tc39/ecma402#399

@sffc sffc closed this as completed Mar 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
future Issue is valid but will not be prioritized currently
Projects
None yet
Development

No branches or pull requests

2 participants