ng i18n --ivy does not extract correctly HTML message with interpolation
See original GitHub issueπ Bug report
Command (mark with an x
)
- new
- build
- serve
- test
- e2e
- generate
- add
- update
- lint
- xi18n
- run
- config
- help
- version
- doc
Is this a regression?
the ng i18n
command extracts message correctly.
Description
Iβm trying to use ng xi18n --ivy
command with Angular 10.1.5 / CLI 10.1.5 packages to extract all my Typescript and HTML text for translation.
I have for example a label shared in four HTML templates. ng xi18n
extract this label and add four location with the right interpolation.
ng xi18n --ivy
generates a single location (false because it points on Typescript invalid code instead of HTML one) and interpolation is malformed. (single {
instead of two {{
and ?
misplaced).
π¬ Minimal Reproduction
For example, with this template code:
<mad-modal-confirm i18n="@@MAD.confirmDeleteModalMsg" i18n-title="@@psSetupPanel.modalConfirmTitle" title="Delete Power Supply" size="md" id="deletePowerSupplyButton" (closed)="deletePowerSupplyConfirm($event)">
Confirm delete {{uiName}}?
</mad-modal-confirm>
The ng xi18n --output-path locale --format=xlf2
command will generate:
<unit id="MAD.confirmDeleteModalMsg">
<notes>
<note category="location">app/components/setup/ps/setup-panel/ps-setup-panel.component.html:7,9</note>
<note category="location">app/components/setup/wall/panel-setup/panel-setup.component.html:56,58</note>
<note category="location">app/components/setup/vc/setup-panel/vc-setup-panel.component.html:10,12</note>
<note category="location">app/components/setup/zone/detail/zone-detail.component.html:14,16</note>
</notes>
<segment>
<source>
Confirm delete <ph id="0" equiv="INTERPOLATION" disp="{{uiName}}"/>?
</source>
</segment>
</unit>
and the ng xi18n --ivy --output-path src/locale --format=xlf2 --out-file=messages-ivy.xlf
command will generate:
<unit id="MAD.confirmDeleteModalMsg">
<notes>
<note category="location">src/app/components/setup/zone/detail/zone-detail.component.ts:111</note>
</notes>
<segment>
<source> Confirm delete <ph id="0" equiv="INTERPOLATION" disp="{uiName}}?"/>?
</source>
</segment>
</unit>
π₯ Exception or Error
π Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ β³ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 10.1.6
Node: 12.18.4
OS: darwin x64
Angular: 10.1.5
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1001.6
@angular-devkit/build-angular 0.1001.6
@angular-devkit/core 10.1.6
@angular-devkit/schematics 10.1.6
@angular/cdk 10.2.4
@angular/cli 10.1.6
@schematics/angular 10.1.6
@schematics/update 0.1001.6
rxjs 6.6.3
typescript 4.0.3
Anything else relevant?
Issue Analytics
- State:
- Created 3 years ago
- Comments:23 (13 by maintainers)
Top GitHub Comments
LOL! We had the same idea!
@petebacondarwin Thanks for your directions! it was a little bit heavy (in my head at least π) but I succeeded.
Because we cannot use es2015 target for our production build itβs the best solution for us.
Best regards.