Escaping # in select/plural/etc
See original GitHub issue- I am on the latest ember-intl version
- I have searched the issues of this repo and believe that this is not a duplicate
Before 5.0.0
, # did not need to be escaped in select
. In 5.0.x
it now gets parsed the same as plural
.
In my usage, #
was only ever used in select
and hasnβt been used in plural
- where it would have the same correct behaviour seen in example seven
in 4.x
Escaping characters in 5.0.0 is now '
instead of \
, so '#
should produce #
(e.g syntax in examples four, five and ten)
Environment
- Ember Version: 3.18.0
- Ember CLI Version: 3.18.0
- Ember Intl Version: 5.0.7
- Browser(s): N/A
- Node Version: 14.1.0
Steps to Reproduce
en-us.yaml
:
three: "Rank #{rank}"
four: "{type, select,
anime {Rank '#{rank}}
other {}}"
five: "{type, select,
anime {Rank '#{rank}}
manga {Rank '#{rank}}
other {}}"
six: "{type, select,
anime {Rank #{rank}}
manga {Rank #{rank}}
other {}}"
seven: "{num, plural,
=0 {#{num} zero}
=1 {#{num} one}
other {#{num} other}}"
eight: "{num, plural,
=0 {'#'{num} zero}
=1 {'#'{num} one}
other {'#'{num} other}}"
- Template usage:
<ul>
<li>3 {{t "three" rank=1}}</li>
<li>4 {{t "four" rank=1 type="anime"}}</li>
<li>5 {{t "five" rank=1 type="anime"}}</li>
<li>6 {{t "six" rank=1 type="anime"}}</li>
<li>7 {{t "seven" num=1}}</li>
<li>8 {{t "eight" num=1}}</li>
</ul>
- Output
3 Rank #1 (correct)
4 Rank {type, number}1
5 Rank {type, number}1
6 Rank NaN1 (Rank #1 in 4.x)
7 11 one (correct)
8 11 one (should be invalid? see nine)
- The following in
en-us
produces an error:
Select nine
uses incorrect syntax and should produce this error (but works in plural eight
without error)
Plural ten
uses correct syntax (but works in select three
)
nine: "{type, select,
anime {Rank '#'{rank}}
manga {Rank '#'{rank}}
other {}}"
ten: "{num, plural,
=0 {'#{num} zero}
=1 {'#{num} one}
other {'#{num}} other}"
[nine] An error occured (Expected β#β, β'β, ββββ, β\nβ, β{β, β}β, [^'], any character, argumentElement, double apostrophes, or tagElement but end of input found.) when extracting ICU arguments for β{type, select, anime {Rank β#β{rank} (Most Popular Anime)} manga {Rank β#β{rank} (Most Popular Anime)} other {}}β
[ten] An error occured (Expected β#β, β'β, ββββ, β\nβ, β{β, β}β, [^β], any character, argumentElement, double apostrophes, or tagElement but end of input found.) when extracting ICU arguments for β{num, plural, =0 {β#{num} zero} =1 {β#{num} one} other {β#{num} other}}β
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
Fixed in 5.0.9
Okay unsure what I was seeing then - sorry. Iβll need to open a bug upstream in intl-messageformat and figure out whatβs going on.
If you put that translation in the repl you can see itβs parsing it incorrectly - appears to be parsing it as a number type (
type 2
) instead of literal (type 0
).