Closed blazekv closed 6 months ago
Thanks for reporting the issue.
Could you please give @ngx-env/builder@17.2.0 a try?
@chihab I tried it and output is still same. I tried it on different project (not blank one). I could try it also on that sample project I created for reproduction tomorrow.
Output with @ngx-env/builder:application
Extraction Complete. (Messages: 0)
If i switched to @ngx-env/builder:browser output is
Extraction Complete. (Messages: 1172)
Fixed in @ngx-env/builder@17.2.1, my bad.
Thank you for that fast response. @chihab I am not sure if it is already fixed. I tried it in my real project and I got this message:
Extraction Complete. (Messages: 413)
but as I wrote before without @ngx-env/builder or with @ngx-env/builder:browser I got:
Extraction Complete. (Messages: 1172)
I am not sure if I find time to investigate difference today. I will probably look at it at monday and let you know.
Something has been fixed at least since you now get 413 messages :)
Re-opening the issue, I'll see if I can reproduce your use case, your investigation would help.
Based on that numbers I had a hunch. It seems that for some reason extraction from templates did not work properly. I tried that on that simple project and here are numbers and examples.
3 translation strings
Component:
export class AppComponent {
title = $localize`ngx-env-test`;
}
Template
<div i18n i18n-title title="Attribute string">
element string
</div>
projects.architect.build.builder = @angular-devkit/build-angular:application
projects.architect.extract-i18n.builder = @angular-devkit/build-angular:extract-i18n
I had 3 extracted messages with this output:
Extraction Complete. (Messages: 3)
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en-US" datatype="plaintext" original="ng2.template">
<body>
<trans-unit id="156685006078229661" datatype="html">
<source>Attribute string</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/app.component.html</context>
<context context-type="linenumber">2,3</context>
</context-group>
</trans-unit>
<trans-unit id="5176180191114202338" datatype="html">
<source> element string
</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/app.component.html</context>
<context context-type="linenumber">3,5</context>
</context-group>
</trans-unit>
<trans-unit id="7459501857900893879" datatype="html">
<source>ngx-env-test</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/app.component.ts</context>
<context context-type="linenumber">13</context>
</context-group>
</trans-unit>
</body>
</file>
</xliff>
(I know this is probably wrong setting but just to test all cases)
projects.architect.build.builder = @ngx-env/builder:application
projects.architect.extract-i18n.builder = @angular-devkit/build-angular:extract-i18n
Extraction Complete. (Messages: 0)
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en-US" datatype="plaintext" original="ng2.template">
<body>
</body>
</file>
</xliff>
And finally these two settings has same output:
projects.architect.build.builder = @ngx-env/builder:application
projects.architect.extract-i18n.builder = @ngx-env/builder:extract-i18n
projects.architect.build.builder = @angular-devkit/build-angular:application
projects.architect.extract-i18n.builder =@ngx-env/builder:extract-i18n
Extraction Complete. (Messages: 1)
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en-US" datatype="plaintext" original="ng2.template">
<body>
<trans-unit id="7459501857900893879" datatype="html">
<source>ngx-env-test</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/app.component.ts</context>
<context context-type="linenumber">13</context>
</context-group>
</trans-unit>
</body>
</file>
</xliff>
Fixed in latest update. Could you please give it a try?
It works correctly in the latest version. Thank you.
Steps to reproduce: 1) Create new project with Angular CLI 17 -
ng new ngx-env-test
2) Add localization -ng add @angular/localize
3) Add ngx-env builder -ng add @ngx-env/builder
4) Create localization in AppComponenttitle = $localize`Hello world`
5) Use ESbuild in Angular.json -"builder": "@ngx-env/builder:application"
6) Run extractionng extract-i18n --output-path src/locale
angular.json
It looks like something is wrong because according to output is seems that ESbuild is not run at all. Output is here
But if I switch to webpack build by setting
"builder": "@ngx-env/builder:browser"
message are extracted.And also without ngx-env builder with ESbuild by setting
"builder": "@angular-devkit/build-angular:application"
everything works OK.