New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ng i18n --ivy does not extract correctly HTML message with interpolation #39241
Comments
The fact that it only captures one of the locations is a bug. We should track that independently and fix it. The incorrect The incorrect location path ( |
Indeed the CLI does forcefully turn this on. (https://github.com/angular/angular-cli/blob/677f6007268c534982c748faeebccb369cb4bc64/tests/legacy-cli/e2e/tests/i18n/extract-ivy-libraries.ts#L66) |
First problem is now tracked in #39330 |
It seems that switching es2015 (with or without --ivy) & es5 (without --ivy)
es5 (with --ivy)
Here's the repo: https://github.com/kamilchlebek/i18n-ivy-es5 PS. I didn't want to create new issue, because I'm not sure whether using |
Thanks @kamilchlebek - I'll take a look. It is generally better to create new issues rather than post on closed ones. |
@kamilchlebek - I just cloned your repo and ran The calls to |
@petebacondarwin Thank you for investigation. Then I think the easiest solution for me is to create
|
The workaround for you is to create a new If this workaround is not usable for you please open a new issue so that I can track the work for fixing it. |
LOL! We had the same idea! |
I made some tests with last Angular 11 and I always have bad translation: <unit id="MAD.confirmDeleteModalMsg">
<notes>
<note category="location">src/app/components/setup/zone/detail/zone-detail.component.html:14,16</note>
<note category="location">src/app/components/setup/wall/panel-setup/panel-setup.component.html:56,58</note>
<note category="location">src/app/components/setup/vc/setup-panel/vc-setup-panel.component.html:10,12</note>
<note category="location">src/app/components/setup/ps/setup-panel/ps-setup-panel.component.html:7,9</note>
</notes>
<segment>
<source> Confirm delete <ph id="0" equiv="INTERPOLATION" disp="e {{uiName"/>?
</source>
</segment>
</unit> for the original text to translate: <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> I'm really disappointed because I like the new Angular 11 version but I cannot migrate my project with this show stopper. |
@bougnat12 There's an issue with multiline translations in angular 11. It's already reported here: #39671 Fix is on the way |
@bougnat12 - you can check to see if #39671 is the same issue that you are experiencing by temporarily setting |
@kamilchlebek Thanks. I will be patient... @petebacondarwin We always had forced I have corrected the signaled warnings: it was mainly |
I was not suggesting this as a workaround. It was purely to help you check that your problem was the same one as reported (and fixed) at #39671. |
I have created a new I tried: "extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "mad-web-ui:build",
"tsConfig": "src/tsconfig.i18n.json"
}
}, But it failed. I think I miss a step but I don't know how to correct this... |
I think you have to create a new build target first, with the new tsconfig. And then reference this new target in your |
@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. |
It's not the same bug as I tried to explain. Spaces issues are solved by correcting my HTML code. My main and blocking issue is about the INTERPOLATION part: I made some tests with last Angular 11 and I always have bad translation: <unit id="MAD.confirmDeleteModalMsg">
<segment>
<source> Confirm delete <ph id="0" equiv="INTERPOLATION" disp="e {{uiName"/>?
</source>
</segment>
</unit> for the original text to translate: <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> Previously I had this result (as explained at the top of this issue): <source> Confirm delete <ph id="0" equiv="INTERPOLATION" disp="{uiName}}?"/>? The and now with Angular 11, I have: <source> Confirm delete <ph id="0" equiv="INTERPOLATION" disp="e {{uiName"/>? Now, the |
Yes, I believe your invalid |
OK thanks. I understand. It's due to the HTML code indentation most of the time. I'll try to correct simple cases as to go ahead: <button>
LABEL
</button> with <button>LABEL</button> But maybe it will remain some complicated cases. Thanks for your help. |
Hopefully #39717 will resolve this for you @bougnat12 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 Bug report
Command (mark with an
x
)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:
The
ng xi18n --output-path locale --format=xlf2
command will generate:and the
ng xi18n --ivy --output-path src/locale --format=xlf2 --out-file=messages-ivy.xlf
command will generate:🔥 Exception or Error
🌍 Your Environment
Anything else relevant?
The text was updated successfully, but these errors were encountered: