globalizejs / globalizejs/globalize
ICU Message Validation and Negative Plural
- Dominant language
- JavaScript
- Stars
- 4.8k
- Forks
- 585
- PR merge metrics
- No merged PRs in 30d
Description
I started playing with Gloablizejs recently and found the following 2 behaviors regarding ICU messages which I was wondering if were features or issues?
1) If I output invalid ICU messages, with for example collision in plural categories, or invalid plural categories, the message will still get through and ignore errors silently, Some examples below:
```js
Globalize.loadMessages({
en: {
test1: [
"You have {count, plural, one {# hot dog} one {# hamburger} one {# sandwich} other {# snacks}} in your lunch bag."
],
test2: [
"You have {count, plural, one {# hot dog} thisIsNotValid1 {# hamburger} thisIsNotValid2 {# sandwich} other {# snacks}} in your lunch bag."
]
}
});
console.log(Globalize( 'en' ).messageFormatter( 'test1' )({count: 1}));
// Output: You have 1 sandwich in your lunch bag.
// Expected output: exception thrown because the plural "one" is used multiple times.
console.log(Globalize( 'en' ).messageFormatter( 'test2' )({count: 1}));
// Output: You have 1 hot dog in your lunch bag.
// Expected output: exception thrown because the plural "thisIsNotValid1" and "thisIsNotValid2" are not valid.
```
2) If I take back the last example for `test2` but set the count to `-1`, the plural rule seems to use `other` while in fact, it should be using `one` - I think this is probably a general rule that applies to most languages but I could not find much detail on this rule.
Contributor guide
Assessment
This issue has not been assessed yet.