i18n translation id for "String + Plural" expression
See original GitHub issueI’m submitting an i18n feature request
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:
Current behavior
I am following the Angular 6 i18n guide: https://angular.io/guide/i18n Apparently there is no option to customize the id of the inner plural expression in an interpolated expression like “String + Plural”
Example:
<span i18n="@@interpolated-time">Time: {minutes, plural, other {{{minutes}} elapsed}}</span>`
<trans-unit id="interpolated-time" datatype="html">
<source>Time: <x id="ICU" equiv-text="{minutes, plural, other {...}}"/></source>
<target>Tiempo: <x id="ICU" equiv-text="{minutes, plural, other {...}}"/></target>
</trans-unit>
<trans-unit id="plural-time" datatype="html">
<source>{VAR_PLURAL, plural, other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> elapsed} }</source>
<target>{VAR_PLURAL, plural, other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> transcurridos} }</target>
</trans-unit>
The result is: Tiempo: 1440 elapsed
The workaround is to separate the expression in 2 simple expressions “string” + “plural”.
Expected behavior
- The translation result should be
Tiempo: 1440 transcurridos
- Either, trans-unit should be detected automatically (by source) or the inner expression id should be customizable.
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
- Generating random translation id for inner expressions is not mantainable.
- Managing inner expression ids is mantainable.
Environment
Angular version: 6
Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
For Tooling issues:
- Node version: XX
- Platform:
Others:
Issue Analytics
- State:
- Created 5 years ago
- Reactions:8
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Plurals - i18next documentation
We provide the ability to have special translation for {count: 0} , so that a more natural language can be used. If the...
Read more >A Step-by-Step Guide to Go Internationalization (i18n)
Manually setting the translation strings ... The simplest way to organize the translations is to have them assigned into the application binary.
Read more >Prepare component for translation - Angular
Use the i18n attribute to mark a static text message in your component templates for translation. Place it on every element tag that...
Read more >Angular i18n: internationalization & localization with examples
trans-unit is the tag containing a single translation. id is a translation identifier and has a special meaning. xi18n generates the id for...
Read more >Hugo Multilingual Part 2: Strings localization | Regis Philibert
i18n/en.yaml - id: hello translation: "Hello" - id: how_are_you ... sure this phrase is always faithfully localized, single or plural?
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
AFAIK, Angular splits “String + Plural” expression in 2 simpler expressions.
The plural inner expression gets a random identifier and it should match the trans-unit “id” in the messages.xlf file in order to work.
The exact Translate a nested expression example in https://angular.io/guide/i18n should be like this:
The id 7151c2e67748b726f0864fc443861d45df21d706 should be obtained from compilation output:
Is there any option to customize this random generated id in the expression?
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.