Skip to content
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 ourterms of serviceand privacy statement.We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extract-i18n produces incorrect "equiv-text" attributes of interpolation elements #56845

Open
1 task
tkleinkeopened this issue Jul 4, 2024 · 2 comments
Open
1 task

Comments

@tkleinke
Copy link

tkleinke commented Jul 4, 2024

Command

extract-i18n

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

In the XLF file generated by extract-i18n, there are sometimes incorrect values inside the "equiv-text" attributes of the interpolation elements. In these cases, "equiv-text" does contain parts of the surrounding text (sometimes including other HTML elements). It seems that the issue occurs when the interpolation element is located directly at the beginning of the translation unit (so a linebreak inside the HTML element fixes the output, see example below).

Minimal Reproduction

This example leads to the expected output:

HTML template:

<div i18n= "@@project.download.progressInfo.database" >
{{getRoundedProgress(databaseProgressPercent)}}% finished...
</div>
<div>Something else</div>

XLF generated by extract-i18n (using builder @angular-devkit/build-angular:extract-i18n):

<trans-unit id= "project.download.progressInfo.database" datatype= "html" >
<source> <x id= "INTERPOLATION" equiv-text= "{{getRoundedProgress(databaseProgressPercent)}}" />% finished... </source>
<context-group purpose= "location" >
<context context-type= "sourcefile" >src/app/components/project/download-project-progress-modal.html</context>
<context context-type= "linenumber" >12,14</context>
</context-group>
</trans-unit>

This example produces incorrect content in "equiv-text":

HTML template:

<div i18n= "@@project.download.progressInfo.database" >{{getRoundedProgress(databaseProgressPercent)}}% finished...</div>
<div>Something else</div>

XLF generated by extract-i18n (using builder @angular-devkit/build-angular:extract-i18n):

<trans-unit id= "project.download.progressInfo.database" datatype= "html" >
<source><x id= "INTERPOLATION" equiv-text= "% finished...&lt;/div&gt;
&lt;div&gt;Something else&lt;/div&gt;" />% finished...</source>
<context-group purpose= "location" >
<context context-type= "sourcefile" >src/app/components/project/download-project-progress-modal.html</context>
<context context-type= "linenumber" >12</context>
</context-group>
</trans-unit>

Exception or Error

No response

Your Environment

Angular CLI: 18.0.6
Node: 20.14.0
Package Manager: npm 10.7.0
OS: darwin arm64

Angular: 18.0.5
... animations, cdk, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router

Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1800.6
@angular-devkit/build-angular 18.0.6
@angular-devkit/core 18.0.6
@angular-devkit/schematics 18.0.6
@angular/cli 18.0.6
@schematics/angular 18.0.6
rxjs 6.5.5
typescript 5.4.5
zone.js 0.14.7

Anything else relevant?

No response

@alan-agius4 alan-agius4 transferred this issue from angular/angular-cli Jul 4, 2024
@ngbot ngbot bot added this to theneedsTriagemilestone Jul 4, 2024
@sakachi99
Copy link

I am also experiencing this behaviour. in both, an angular v18 project.
As well as an angular v15 project (which is scheduled for upgrade later this year)

@Licen-it
Copy link

Licen-it commented Aug 2, 2024

it looks similar to the issue i opened#56824

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants