🐞 Bug report
Command (mark with an x)
Is this a regression?
No
Description
Running the extract-i18n command will always log duplicate i18n message IDs as warnings, regardless of the value of the i18nDuplicateTranslation option in the build target.
🔬 Minimal Reproduction
This repository can be used to quickly reproduce this bug:
https://github.com/reduckted/repro-extract-i18n-duplicates
Or using this archive:
repro-extract-i18n-duplicates.zip
- Run
npm i
- Run
ng extract-i18n
The template app.component.html contains two i18n messages with the same ID but different text. The angular.json file has the i18nDuplicateTranslation option set to "error" in the browser builder.
The output is:
WARNINGS:
- Duplicate messages with id "test":
- "first" : src\app\app.component.html:1
- "second" : src\app\app.component.html:2
🔥 Exception or Error
I expect that with i18nDuplicateTranslation set to "error", the duplicate message IDs will be logged as errors and that the process exits with a non-zero exit code.
Instead, the duplicate message IDs are logged as a warning, and the process exits with an exit code of zero.
🌍 Your Environment
> ng version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 14.1.0
Node: 16.12.0
Package Manager: npm 8.15.0
OS: win32 x64
Angular: 14.1.0
... animations, cli, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1401.0
@angular-devkit/build-angular 14.1.0
@angular-devkit/core 14.1.0
@angular-devkit/schematics 14.1.0
@schematics/angular 14.1.0
rxjs 7.5.6
typescript 4.7.4
Anything else relevant?
Looking at the code, it seems like this might be a simple fix. 🤞
The duplicate message IDs are checked here with a hard-coded value of "warning" and then always logged as warnings:
|
const diagnostics = checkDuplicateMessages( |
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
|
checkFileSystem as any, |
|
ivyMessages, |
|
'warning', |
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
|
basePath as any, |
|
); |
|
if (diagnostics.messages.length > 0) { |
|
context.logger.warn(diagnostics.formatDiagnostics('')); |
|
} |
Earlier in the same function, the browser target options are fetched here, which should contain the value of the i18nDuplicateTranslation option:
|
const browserOptions = await context.validateOptions<JsonObject & BrowserBuilderOptions>( |
|
await context.getTargetOptions(browserTarget), |
|
await context.getBuilderNameForTarget(browserTarget), |
|
); |
🐞 Bug report
Command (mark with an
x)Is this a regression?
No
Description
Running the
extract-i18ncommand will always log duplicate i18n message IDs as warnings, regardless of the value of thei18nDuplicateTranslationoption in the build target.🔬 Minimal Reproduction
This repository can be used to quickly reproduce this bug:
https://github.com/reduckted/repro-extract-i18n-duplicates
Or using this archive:
repro-extract-i18n-duplicates.zip
npm ing extract-i18nThe template
app.component.htmlcontains two i18n messages with the same ID but different text. Theangular.jsonfile has thei18nDuplicateTranslationoption set to"error"in the browser builder.The output is:
🔥 Exception or Error
I expect that with
i18nDuplicateTranslationset to"error", the duplicate message IDs will be logged as errors and that the process exits with a non-zero exit code.Instead, the duplicate message IDs are logged as a warning, and the process exits with an exit code of zero.
🌍 Your Environment
Anything else relevant?
Looking at the code, it seems like this might be a simple fix. 🤞
The duplicate message IDs are checked here with a hard-coded value of "warning" and then always logged as warnings:
angular-cli/packages/angular_devkit/build_angular/src/builders/extract-i18n/index.ts
Lines 273 to 283 in 1b89fd4
Earlier in the same function, the browser target options are fetched here, which should contain the value of the
i18nDuplicateTranslationoption:angular-cli/packages/angular_devkit/build_angular/src/builders/extract-i18n/index.ts
Lines 138 to 141 in 1b89fd4