ng extract-i18n extracts incorrect `equiv-text` value
See original GitHub issue🐞 bug report
Affected Package
The issue is caused by package @angular/localize
Is this a regression?
Yes, the previous version in which this bug was not present was: v10
Description
Component template (it’s usually formatted like this by prettier):
<div i18n>
test {{ title }}
</div>
Running ng xi18n
in angular v10, produced output that contained source
element that looked:
<source>
test <x id="INTERPOLATION" equiv-text="{{ title }}"/>
</source>
Now after running ng extract-i18n
it’s:
<source> test <x id="INTERPOLATION" equiv-text="t {{ title "/>
</source>
🔬 Minimal Reproduction
https://github.com/kamilchlebek/equiv-text-angular11 (see messages.xlf
)
🌍 Your Environment
(it’s a brand new project created using ng new
)
Angular Version:
Angular CLI: 11.0.1
Node: 12.16.1
OS: linux x64
Angular: 11.0.0
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1100.1
@angular-devkit/build-angular 0.1100.1
@angular-devkit/core 11.0.1
@angular-devkit/schematics 11.0.1
@angular/cli 11.0.1
@schematics/angular 11.0.1
@schematics/update 0.1100.1
rxjs 6.6.3
typescript 4.0.5
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
angular - Problem extracting equiv-text in XLIFF files with ng ...
When I run ng extract-i18n, in the generated xlf file, the "equiv-text" attribute of INTERPOLATION and ICU tokens is wrong.
Read more >ng extract-i18n - Angular
Option Description Default Value
‑‑format Output format for the generated file. xlf
‑‑out‑file Name of the file to output.
‑‑output‑path Path where output will be placed....
Read more >Angular i18n: internationalization & localization with examples
Extracting translations to XLF files. ... ng add @angular/localize ... for Angular 11+ it is advised to use ng extract-i18n command instead.
Read more >Angular internationalization (i18n) tutorial - Localizely
The value of this attribute is optional. ... All these value parts are optional. ... ng extract-i18n --output-path src/locale.
Read more >Localizing Your App - Angular 11 - W3cubDocs
To override the value of LOCALE_ID , add the locale parameter. ... The ng extract-i18n command (with no options) generates a source language...
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 Free
Top 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
Here’s the fix: #39717. It was not trivial so it took a bit longer than I thought.
I have found the cause of the problem. When we process the
i18n
tags, we run the processing twice. Once before whitespace has been removed (which results in correct source-spans) and then again after whitespace has been collapsed (which results in incorrect source-spans for placeholders).See https://github.com/angular/angular/blob/1f956184c426814be8fcbdab03396c910e29d935/packages/compiler/src/render3/view/template.ts#L2085-L2088
A fix is in the works…