Skip to content

Number parsing overrides minimumFractionDigits #449

Open
@zbraniecki

Description

@zbraniecki

The way we store number's precision has been rewritten in 2bd94bc to store a value as a number and precision as minimumFractionDigits option to intl number formatter.

This has an unfortunate consequence in that the number of fraction digits specified in the input hardcodes the mfd option, which is different from how Intl.NumberFormat works.

Here's an example (ignore for now that we wanted to limit currency setting from L10n, same argument applies for partial arguments or other forms of default precision):

(5).toLocaleString("en"); // "5"
(5.00).toLocaleString("en"); // "5"
(5).toLocaleString("en", {style: "currency", currency: "USD"}); // "$5.00"
(5.00).toLocaleString("en", {style: "currency", currency: "USD"}); // "$5.00"

But in Fluent, this will happen:

key1 = Hello { 5 } World
key2 = Hello { 5.00 } World
key3 = Hello { NUMBER(5, style: "currency", currency: "USD") } World
key4 = Hello { NUMBER(5.00, style: "currency", currency: "USD") } World

output:

Hello 5 World
Hello 5.00 World
Hello $5 World
Hello $5.00 World

I aligned fluent-rs with fluent.js here projectfluent/fluent-rs@df9c489 but am a bit concerned about this behavior difference.

@stasm, @Pike - do you think this is an issue or a feature?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions