Skip to content

Commit b056b1d

Browse files
ocombehansl
authored andcommitted
fix(@ngtools/webpack): do not change user's LOCALE_ID
1 parent c636daf commit b056b1d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

packages/@ngtools/webpack/src/angular_compiler_plugin.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export class AngularCompilerPlugin implements Tapable {
108108
private _donePromise: Promise<void> | null;
109109
private _compiler: any = null;
110110
private _compilation: any = null;
111+
private _normalizedLocale: string;
111112

112113
// TypeChecker process.
113114
private _forkTypeChecker = true;
@@ -225,7 +226,8 @@ export class AngularCompilerPlugin implements Tapable {
225226
this._compilerOptions.i18nOutFormat = options.i18nOutFormat;
226227
}
227228
if (options.locale !== undefined) {
228-
this._compilerOptions.i18nInLocale = this._validateLocale(options.locale);
229+
this._compilerOptions.i18nInLocale = options.locale;
230+
this._normalizedLocale = this._validateLocale(options.locale);
229231
}
230232
if (options.missingTranslation !== undefined) {
231233
this._compilerOptions.i18nInMissingTranslations =
@@ -652,9 +654,9 @@ export class AngularCompilerPlugin implements Tapable {
652654
// If we have a locale, auto import the locale data file.
653655
// This transform must go before replaceBootstrap because it looks for the entry module
654656
// import, which will be replaced.
655-
if (this._compilerOptions.i18nInLocale) {
657+
if (this._normalizedLocale) {
656658
this._transformers.push(registerLocaleData(isAppPath, getEntryModule,
657-
this._compilerOptions.i18nInLocale));
659+
this._normalizedLocale));
658660
}
659661

660662
if (!this._JitMode) {

tests/e2e/tests/i18n/build-locale.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,9 @@ export default function () {
1818
.then(() => expectFileToMatch('dist/main.bundle.js', /registerLocaleData/))
1919
.then(() => expectFileToMatch('dist/main.bundle.js', /angular_common_locales_fr/))
2020
.then(() => rimraf('dist'))
21-
.then(() => expectToFail(() => ng('build', '--aot', '--locale=no-locale')))
21+
.then(() => ng('build', '--aot', '--locale=fr_FR'))
22+
.then(() => expectFileToMatch('dist/main.bundle.js', /registerLocaleData/))
23+
.then(() => expectFileToMatch('dist/main.bundle.js', /angular_common_locales_fr/))
24+
.then(() => rimraf('dist'))
25+
.then(() => expectToFail(() => ng('build', '--aot', '--locale=no-locale')));
2226
}

0 commit comments

Comments
 (0)