-
Notifications
You must be signed in to change notification settings - Fork 26k
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 extract-i18n extracts incorrect equiv-text
value
#39671
Comments
I can confirm this bug. I am looking into it now. |
Just to give an update... these I think this is a bug in the Angular compiler, similar to one that I fixed recently. See #39486. Investigating further... |
That's bad 😞 As I workaround I could switch prettier
but Of course I'd rather avoid that for https://prettier.io/blog/2018/11/07/1.15.0.html#whitespace-sensitive-formatting |
I have found the cause of the problem. When we process the See angular/packages/compiler/src/render3/view/template.ts Lines 2085 to 2088 in 1f95618
A fix is in the works... |
When the `preserveWhitespaces` is not true, the template parser will process the parsed AST nodes to remove excess whitespace. Since the generated `goog.getMsg()` statements rely upon the AST nodes after this whitespace is removed, the i18n extraction must make a second pass. Previously this resulted in innacurrate source-spans for the i18n text and placeholder nodes that were extracted in the second pass. This commit fixes this by reusing the source-spans from the first pass when extracting the nodes in the second pass. Fixes angular#39671
When the `preserveWhitespaces` is not true, the template parser will process the parsed AST nodes to remove excess whitespace. Since the generated `goog.getMsg()` statements rely upon the AST nodes after this whitespace is removed, the i18n extraction must make a second pass. Previously this resulted in innacurrate source-spans for the i18n text and placeholder nodes that were extracted in the second pass. This commit fixes this by reusing the source-spans from the first pass when extracting the nodes in the second pass. Fixes angular#39671
Here's the fix: #39717. It was not trivial so it took a bit longer than I thought. |
Great, thank you! Can't wait to see it released 🚀 |
When the `preserveWhitespaces` is not true, the template parser will process the parsed AST nodes to remove excess whitespace. Since the generated `goog.getMsg()` statements rely upon the AST nodes after this whitespace is removed, the i18n extraction must make a second pass. Previously this resulted in innacurrate source-spans for the i18n text and placeholder nodes that were extracted in the second pass. This commit fixes this by reusing the source-spans from the first pass when extracting the nodes in the second pass. Fixes angular#39671
…39717) When the `preserveWhitespaces` is not true, the template parser will process the parsed AST nodes to remove excess whitespace. Since the generated `goog.getMsg()` statements rely upon the AST nodes after this whitespace is removed, the i18n extraction must make a second pass. Previously this resulted in innacurrate source-spans for the i18n text and placeholder nodes that were extracted in the second pass. This commit fixes this by reusing the source-spans from the first pass when extracting the nodes in the second pass. Fixes #39671 PR Close #39717
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
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):
Running
ng xi18n
in angular v10, produced output that containedsource
element that looked:Now after running
ng extract-i18n
it's:🔬 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:
The text was updated successfully, but these errors were encountered: