Support NumberFormat rev. 2 in Fluent
Categories
(Core :: Internationalization: Localization, defect)
Tracking
()
People
(Reporter: flod, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: good-first-bug, helpwanted)
NUMBER(100, signDisplay: "always")
NUMBER(-99, signDisplay: "never")
In Firefox this will display 100
and -99
, while on Fluent's playground it will display correctly +100
and 99
.
Also getting correctly +100
in Console with
new Intl.NumberFormat("en-US", {
signDisplay: "always"
}).format([100]);
Updated•4 years ago
|
Comment 1•4 years ago
|
||
This is just a new addition to ECMA-402 that has to be propagated to https://searchfox.org/mozilla-central/source/intl/l10n/rust/fluent-ffi/src/ffi.rs#49 and then used in https://searchfox.org/mozilla-central/source/intl/l10n/FluentBundle.cpp#210
Comment 2•4 years ago
|
||
We should extend this bug to cover other features supported by Unified Number Format (NumberFormat rev. 2) proposal https://github.com/tc39/proposal-unified-intl-numberformat
The functionality is there, but in some cases the operations between C++ and options bag are not trivial, and we should closely follow what SpiderMonkey is doing here https://searchfox.org/mozilla-central/source/js/src/builtin/intl/NumberFormat.cpp#496
Comment 3•4 years ago
|
||
With bug 1695937 fixed, Gecko can now handle NumberFormat rev. 2!
What's left is to add support for it into fluent-rs. NumberFormat is this weird outlier for now, since it is defined in fluent-rs
itself because we do need to format numbers (compared to DateTime
which is a CustomType
and doesn't exist in fluent-rs
itself), even in a quasi way.
Eventually, I expect fluent-bundle
to just depend on icu_number
which should handle it well, but for now, we will have to:
- Extend https://github.com/projectfluent/fluent-rs/blob/master/fluent-bundle/src/types/number.rs#L60 to pass through all new options from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat
- Extend https://searchfox.org/mozilla-central/source/intl/l10n/rust/fluent-ffi/src/ffi.rs#49 to match it
- Extend https://searchfox.org/mozilla-central/source/intl/l10n/FluentBundle.cpp#212 to match it
That should do it.
In theory we could try to make mozilla::intl::NumberFormatOptions
accessible from Rust so that we could remove NumberFormatOptionsRaw
and just construct the m::i::NumberFormatOptions
from fluent::types::NumberFormatOptions
, but I'm not sure if that type will work well as exposed to Rust.
:dminor - what do you think?
Comment 4•4 years ago
|
||
I think everything in mozilla::intl::NumberFormatOptions
has a natural rust representation, but I think we'd have to write manual wrappers to get it working. I spent a little bit of time with bindgen
this morning, and it was not generating anything sensible for mozilla::Maybe
. I don't think it's worth investing in writing manual wrappers when we eventually plan to just call into icu_number
directly, so your steps 1 - 3 make good sense to me.
Updated•4 years ago
|
Comment 5•3 years ago
|
||
This good-first-bug hasn't had any activity for 2 months, it is automatically unassigned.
For more information, please visit auto_nag documentation.
Updated•2 years ago
|
Description
•