Skip to content

--localize: pipes localization missing for default language if it's not English #16389

@cyrilletuzi

Description

@cyrilletuzi

🐞 Bug report

Command

  • build

Is this a regression?

No, as it's a new feature in v9.

Description

When using the new --localize option, if the default language (sourceLocale) is not English, localization for pipes is missing in the default language, resulting the app to fail.

🔬 Minimal Reproduction

  • create an app with v9 cli
  • use a pipe involving i18n like date
  • use a language other than English as default in your source code (let's say French)
  • translate the app for other languages (let's say English and Deutsh)
  • add the config in angular.json:
"projects": {
  "demo": {
    "i18n": {
      "sourceLocale": "fr",
      "locales": {
        "en": "src/locale/messages.en.xlf",
        "de": "src/locale/messages.de.xlf",
      }
    }
  }
}
  • ng build --prod --localize

Result: en and de will work fine, but fr won't have localization for pipes.

If English is the default like below, every locale will work fine:

"projects": {
  "demo": {
    "i18n": {
      "sourceLocale": "en",
      "locales": {
        "fr": "src/locale/messages.fr.xlf",
        "de": "src/locale/messages.de.xlf",
      }
    }
  }
}

🔥 Exception or Error

In browser console:


Error: InvalidPipeArgument: 'Missing locale data for the locale "fr".' for pipe 't'

Resulting in everything after the pipe in the template to fail to render.

🌍 Your Environment


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

Angular: 9.0.0-rc.5
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, localize, material
... platform-browser, platform-browser-dynamic, router
... service-worker
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-ng-packagr   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
ng-packagr                         9.0.0-rc.3
rxjs                               6.5.3
typescript                         3.6.4
webpack                            4.41.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions