Skip to content

ng xi18n isn't extracting localized messages when using $localize inside component ts files #16375

@josuerios

Description

@josuerios

🐞 Bug report / 🚀Feature request

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Description

ng xi18n isn't extracting localized messages when using $localize inside component ts files.

🔬 Minimal Reproduction

  1. Create a Angular v9 Ivy enabled application.
  2. Add @angular/localize (ng add @angular/localize)
  3. Add a localized message in a component HTML template using i18n attribute (<h2 i18n="@@works">This works</h2>).
  4. Add a localized message in a component ts file using $localize (this.message = $localize`:@@anId:a basic message`;)
  5. Execute ng xi18n.
  6. Only the HTML template messages are being extracted.

Manually adding the non extracted translations and building the application works as expected but running ng xi18n again will erase them.

I've created a minimal GitHub repository with the reproduction of the issue : ivy-xi18n-issue

🌍 Your Environment


Angular CLI: 9.0.0-rc.5
Node: 10.17.0
OS: darwin x64

Angular: 9.0.0-rc.5
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.0-rc.5
@angular-devkit/build-angular     0.900.0-rc.5
@angular-devkit/build-optimizer   0.900.0-rc.5
@angular-devkit/build-webpack     0.900.0-rc.5
@angular-devkit/core              9.0.0-rc.5
@angular-devkit/schematics        9.0.0-rc.5
@ngtools/webpack                  9.0.0-rc.5
@schematics/angular               9.0.0-rc.5
@schematics/update                0.900.0-rc.5
rxjs                              6.5.3
typescript                        3.6.4
webpack                           4.41.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions