x)- [x] bug report -> please search issues before submitting
- [ ] feature request
@angular/cli: 1.3.2
node: 8.2.1
os: linux x64
@angular/animations: 4.3.6
@angular/common: 4.3.6
@angular/compiler: 4.3.6
@angular/core: 4.3.6
@angular/forms: 4.3.6
@angular/http: 4.3.6
@angular/platform-browser: 4.3.6
@angular/platform-browser-dynamic: 4.3.6
@angular/router: 4.3.6
@angular/cli: 1.3.2
@angular/compiler-cli: 4.3.6
@angular/language-service: 4.3.6
ng new test-i18n
app.component.html - Add the following line:
<div i18n>Page {{'5'}} of {{'5'}}</div>
Extract Translation Data
ng xi18n --locale en --output-path src/i18n
"Translate" the file using some tool, in this case just copying the source to target, saving as "messages.en.xlf"
ng serve --aot --i18n-file=src/i18n/messages.en.xlf --i18n-format=xlf --locale=en
ERROR in Unknown placeholder "INTERPOLATION_1" ("Page
of [ERROR ->] "): i18n@0:32
Shows "Page 5 of 5" instead of error.
The error only occured if BOTH Interpolation parts were '5'
Using anything else: e.g. variables (page_offset), other numbers ('4' with '5' or '1' with '1'), numbers instead of strings (5), even using double quotes ("5") DID NOT result in the error.
This means after knowing that I can easily get around that, but still it is a very confusing issue.....
Or is there something I did not see?
Hello, can you give me the content of your xlf file please ?
Is this reproducible in plunkr?
(Do not know about Plunkr, never had Angular running there, especially with i18n)
So based on your xlf file:
<source>Page <x id="INTERPOLATION"/> of <x id="INTERPOLATION"/></source>
<target state="translated">Page <x id="INTERPOLATION"/> of <x id="INTERPOLATION_1"/></target>
In source you have two times INTERPOLATION but in target you have: INTERPOLATION and INTERPOLATION_1 which is why it doesn't work (INTERPOLATION_1 doesn't exist)
Hm, so the tool is to blame that I used to make the translation, will have a look at that.
But still wondering why Angular i18n reacts so strange in that case...
well the IDs are used to match your translations with the content of your templates, if the ID is wrong then it fails and throws
For anyone encountering this error and ending up here - this can also occur if you've given identical IDs to two different messages.
@ocombe
Hello i'm currently working with i18n also and i found problems with translating dynamic text
How does i18n solve it ?
We plan to add a service for dynamic translations at runtime in ivy (the new renderer that we are working on). Right now it's not possible with built-in i18n.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
For anyone encountering this error and ending up here - this can also occur if you've given identical IDs to two different messages.