mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1673539 - Multiply by 100 when using style percent in Fluent. r=dminor
Differential Revision: https://phabricator.services.mozilla.com/D94845
This commit is contained in:
parent
617e00d069
commit
40fc79d8ea
@ -227,7 +227,8 @@ ffi::RawNumberFormatter* FluentBuiltInNumberFormatterCreate(
|
||||
MOZ_ASSERT(U_SUCCESS(ec), "Failed to format the currency unit.");
|
||||
}
|
||||
if (aOptions->style == ffi::FluentNumberStyleRaw::Percent) {
|
||||
formatter = formatter.unit(icu::NoUnit::percent());
|
||||
formatter = formatter.unit(icu::NoUnit::percent())
|
||||
.scale(icu::number::Scale::powerOfTen(2));
|
||||
}
|
||||
|
||||
if (aOptions->minimum_significant_digits >= 0 ||
|
||||
|
@ -4,6 +4,7 @@
|
||||
function run_test() {
|
||||
test_methods_presence(FluentBundle);
|
||||
test_methods_calling(FluentBundle, FluentResource);
|
||||
test_number_options(FluentBundle, FluentResource);
|
||||
|
||||
ok(true);
|
||||
}
|
||||
@ -29,3 +30,18 @@ function test_methods_calling(FluentBundle, FluentResource) {
|
||||
equal(bundle.formatPattern(msg2.value, { name: "Amy" }), "Hello Amy");
|
||||
ok(true);
|
||||
}
|
||||
|
||||
function test_number_options(FluentBundle, FluentResource) {
|
||||
const bundle = new FluentBundle(["en-US", "pl"], {
|
||||
useIsolating: false,
|
||||
});
|
||||
bundle.addResource(new FluentResource(`
|
||||
key = { NUMBER(0.53, style: "percent") } { NUMBER(0.12, style: "percent", minimumFractionDigits: 0) }
|
||||
{ NUMBER(-2.5, style: "percent") } { NUMBER(2.91, style: "percent") } { NUMBER("wrong", style: "percent") }
|
||||
`));
|
||||
|
||||
const msg = bundle.getMessage("key");
|
||||
equal(bundle.formatPattern(msg.value), "53.00% 12%\n-250.0% 291.00% ");
|
||||
|
||||
ok(true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user