question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
petebacondarwincommented, Nov 16, 2020

Here’s the fix: #39717. It was not trivial so it took a bit longer than I thought.

1reaction
petebacondarwincommented, Nov 14, 2020

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…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found