angular: Extractor no longer extracts the parameter/expression of the interpolated string into disp attribute
🐞 bug report
Is this a regression?
Yes. This used to work in 10.0 and earlier.
Description
Extractor no longer extracts the parameter/expression of the interpolated string into disp attribute
🔬 Minimal Reproduction
Repo is here.
Write an interpolated string that has any parameter. For example
<p i18n>My name is {{name}}</p>
Then run the extractor
ng xi18n --format=xlf2 --output-path src/locale --ivy
The result XLIFF no longer contain disp attribute of it does not contain the parameter/expression used in the interpolated string
<segment>
<source>My name is <ph id="0" equiv="INTERPOLATION" disp=""\uFFFD0\uFFFD""/></source>
</segment>
This used to be
<segment>
<source>My name is <ph id="0" equiv="INTERPOLATION" disp="{{name}};"/></source>
</segment>
🌍 Your Environment
Angular Version:
Angular CLI: 10.1.0
Node: 12.9.1
OS: win32 x64
Angular: 10.1.0
... animations, cli, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.1001.0
@angular-devkit/build-angular 0.1001.0
@angular-devkit/build-optimizer 0.1001.0
@angular-devkit/build-webpack 0.1001.0
@angular-devkit/core 10.1.0
@angular-devkit/schematics 10.1.0
@ngtools/webpack 10.1.0
@schematics/angular 10.1.0
@schematics/update 0.1001.0
rxjs 6.6.2
typescript 4.0.2
webpack 4.44.1
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 21 (12 by maintainers)
Commits related to this issue
- refactor(localize): avoid free-standing `FileSystem` functions These free standing functions rely upon the "current" `FileSystem`, but it is safer to explicitly pass the `FileSystem` into functions o... — committed to petebacondarwin/angular by petebacondarwin 4 years ago
- refactor(localize): avoid free-standing `FileSystem` functions These free standing functions rely upon the "current" `FileSystem`, but it is safer to explicitly pass the `FileSystem` into functions o... — committed to petebacondarwin/angular by petebacondarwin 4 years ago
- refactor(localize): avoid free-standing `FileSystem` functions These free standing functions rely upon the "current" `FileSystem`, but it is safer to explicitly pass the `FileSystem` into functions o... — committed to petebacondarwin/angular by petebacondarwin 4 years ago
- refactor(localize): avoid free-standing `FileSystem` functions (#39006) These free standing functions rely upon the "current" `FileSystem`, but it is safer to explicitly pass the `FileSystem` into fu... — committed to angular/angular by petebacondarwin 4 years ago
Hey guys, I still have a problem with the “equiv-text” attribute. I am using the latest tag
10.1.6
from the CLI but some translation messages still have incorrect values.eg.:
<ng-container i18n="Update @@update"> <b>{{value1}}:</b> current {{value2}} to new {{value3}} </ng-container>
will be extracted as (with --ivy):
will be extracted as (without --ivy):
Is this an issue in my code or in the cli extraction command?
Example Repo https://github.com/Niklas187/ng-xi18n-ivy-bug.git
version:
OK, I worked out what is going on. The localize stuff relies upon a
FileSystem
, which the CLI is mocking up to get everything to work. But… internally the extraction is callingabsoluteFrom()
, which looks for a “current”FileSystem
by callinggetFileSystem()
. This is a kind of global that should be set viasetFileSystem()
before running the localize code.But CLI is not calling this and so the “current” FileSystem is different to the one being passed in and it is converting backslashes to forward slashes in paths. So the source-maps are not being loaded from the fake file system that the CLI is providing.
Arguably the CLI shouldn’t have to worry about the “current” FileSystem. I’ll look into the best way to fix this…
OK, so it is something to do with the CLI integration… on Windows I get the same problem if I use
ng xi18n
. But try the following:This generates the correct output.
Tested locally and #38645 does appear to fix this issue. Running the commands on the above reproduction results in:
This might be fixed by https://github.com/angular/angular/pull/38645 I will test later today
Yes this is a different issue
On Fri, Sep 4, 2020 at 05:22 Sonu Kapoor notifications@github.com wrote: