question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

  1. 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}}"
  1. 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>
  1. 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)
  1. 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:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jasonmitcommented, May 7, 2020

Fixed in 5.0.9

1reaction
jasonmitcommented, May 7, 2020

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).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Oracle SQL escape character (for a '&') - Stack Overflow
I've tried escaping the special character in the query using the '\' above but I still can't avoid the ampersand, '&', causing a...
Read more >
HTML Escaping - YouTube
HTML escaping using the cgi module This educational video was created for use in LaunchCode's in-person training programs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found