Skip to content

application builder generates different linenumber for i18n messages than browser builder #25883

Closed
@cexbrayat

Description

@cexbrayat

Command

extract-i18n

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

template:

<!-- comment -->
<h1 i18n>Welcome</h1>
<!-- comment -->

When extracting the messages, browser builder gives:

      <trans-unit id="7627914200888412251" datatype="html">
        <source>Welcome</source>
        <context-group purpose="location">
          <context context-type="sourcefile">src/app/app.component.html</context>
          <context context-type="linenumber">2</context>
        </context-group>
      </trans-unit>

whereas application builder gives:

      <trans-unit id="7627914200888412251" datatype="html">
        <source>Welcome</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>

linenumber includes 3 whereas the element is only on line 2.

Minimal Reproduction

Run

npx @angular/cli@next new i18n-linenumber --defaults --no-routing
cd i18n-linenumber
ng add @angular/localize

Replace the app.component.html file with:

<!-- comment -->
<h1 i18n>Welcome</h1>
<!-- comment -->

Run:

ng extract-i18n --output-path src/locale/

The generated file is:

<?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="3492007542396725315" datatype="html">
        <source>Welcome</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>
    </body>
  </file>
</xliff>

Switch the builder to browser in angular.json and run the extraction command again.
The generated file has the correct line number 2.

Exception or Error

No response

Your Environment

Angular CLI: 17.0.0-next.5
Node: 18.16.0
Package Manager: npm 9.7.1
OS: darwin arm64

Angular: 17.0.0-next.5
... animations, cli, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1700.0-next.5
@angular-devkit/build-angular   17.0.0-next.5
@angular-devkit/core            17.0.0-next.5
@angular-devkit/schematics      17.0.0-next.5
@schematics/angular             17.0.0-next.5
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.0

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions