Nesting of translations breaks Testing
See original GitHub issueSince nesting (similar to this) is not supported by ember-intl yet, the alternative is to define a translation json as:
{
"reuseText": "{count, plural, =1 {Name} other {Names}}",
"secondKey: "{reuseText} has Hello world"
}
and in the template we define the usage as {{t "secondKey" reuseText=(t "reuseText" count=2)}}
. This isn’t going to throw an error. Instead, the reuseText
key is translated to proper text and applied as a param to the secondKey
.
But the same template when running in its test case throws an error similar to this.
After debugging, the test cases scenario, I figured out that the stringify
method makes an additional escape character for double quotes: "
. And the same value is now applied to the first translation as a value to reuseText
. But since the intl.message.parser cannot translate a key that contains a \
, the error of #616 comes up - but only in test cases. The reason being, ember-intl’s test-support helper overrides the missing-message translation util.
-
One possible solution is to fix this to replace even the escaped double quotes with a simple doubt quotes in here.
-
Or, if nesting translations is itself a part of the ember-intl addon, the solution gets simpler where we could define the translation something like the following similar to i18next:
{
"reuseText": "{count, plural, =1 {Name} other {Names}}",
"secondKey: "$t(reuseText) has Hello world"
}
-
Or, is it a mistake to do a translation and then apply that string value to another key?
-
The other possible solution is to rewrite all the strings which are similar to
reuseText
as it’s value manually in all the places which are again a tedious manual process like the following:
{
"reuseText": "{count, plural, =1 {Name} other {Names}}",
"secondKey: "{count, plural, =1 {Name} other {Names}} has Hello world"
}
- Or, is there another totally different solution to this?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:12 (12 by maintainers)
Top GitHub Comments
I’ll take a look!
Released as v4.3.2
Thanks!