Ember-intl: Utilizing escaped { in translation text does not work as expected

Created on 8 Feb 2019  路  4Comments  路  Source: ember-intl/ember-intl

  • [x] I am on the latest ember-intl version
  • [x] I have searched the issues of this repo and believe that this is not a duplicate

Environment

  • Ember Version: 3.6.1
  • Ember CLI Version: 3.7.1
  • Ember Intl Version: 3.5.0
  • Browser(s): Chrome
  • Node Version: 8.11.4

Steps to Reproduce

I am attempting to convert from ember-i18n to ember-intl and ran into a problem with the change from
{{ to {. There are several translations that look like this.

View {0} - {1} of {2}

Where the {'s are actually supposed to be passed through to the final translation.

According to the ICU message syntax the correct new format is this.

View '{'0'}' - '{'1'}' of '{'2'}'

When attempting this using an online ICU message editor.

https://format-message.github.io/icu-message-format-for-translators/editor.html

it works as expected. When i run this with intl i get this.

this.intl.formatMessage("page '{'0'}'") core.js:45 Uncaught Error: The intl string context variable ''0'' was not provided to the string 'page '{'0'}'' at MessageFormat.format (core.js:45) at FormatMessage.format (format-message.js:53) at Class.formatMessage (intl.js:235) at eval (eval at <anonymous> (component.js:48), <anonymous>:1:11) at Class._initJqGrid (component.js:48) at sendEvent (metal.js:182) at Class.trigger [as _super] (evented.js:69) at Class.trigger (core_view.js:62) at Class.superWrapper [as trigger] (utils.js:284) at CurlyComponentManager.didCreate (glimmer.js:3464)

dependency issue help wanted

Most helpful comment

Bummer,

Thanks for all the hard work!

It looks like i can do \\{0\\} for right now.

All 4 comments

Upstream issue, see: https://github.com/ember-intl/ember-intl/issues/616#issuecomment-427547389

Busy moment for me, so I won't be able to take this on for awhile. Since this is a breaking change, and I feel important, we should aim for this to land in 4.0.0

Bummer,

Thanks for all the hard work!

It looks like i can do \\{0\\} for right now.

After updating the translation parser and compiler, this should now be resolved on master.

There are many breaking changes so will be releasing a 5.0.0-unstable shortly while I document all the breaking changes.

This is resolved in 5.0.0. Single ticks are now the recommended approach.

Was this page helpful?
0 / 5 - 0 ratings