Skip to content

Commit

Permalink
fix(@ngtools/webpack): do not change user's LOCALE_ID
Browse files Browse the repository at this point in the history
  • Loading branch information
ocombe authored and hansl committed Nov 23, 2017
1 parent c636daf commit b056b1d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 5 additions & 3 deletions packages/@ngtools/webpack/src/angular_compiler_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export class AngularCompilerPlugin implements Tapable {
private _donePromise: Promise<void> | null;
private _compiler: any = null;
private _compilation: any = null;
private _normalizedLocale: string;

// TypeChecker process.
private _forkTypeChecker = true;
Expand Down Expand Up @@ -225,7 +226,8 @@ export class AngularCompilerPlugin implements Tapable {
this._compilerOptions.i18nOutFormat = options.i18nOutFormat;
}
if (options.locale !== undefined) {
this._compilerOptions.i18nInLocale = this._validateLocale(options.locale);
this._compilerOptions.i18nInLocale = options.locale;
this._normalizedLocale = this._validateLocale(options.locale);
}
if (options.missingTranslation !== undefined) {
this._compilerOptions.i18nInMissingTranslations =
Expand Down Expand Up @@ -652,9 +654,9 @@ export class AngularCompilerPlugin implements Tapable {
// If we have a locale, auto import the locale data file.
// This transform must go before replaceBootstrap because it looks for the entry module
// import, which will be replaced.
if (this._compilerOptions.i18nInLocale) {
if (this._normalizedLocale) {
this._transformers.push(registerLocaleData(isAppPath, getEntryModule,
this._compilerOptions.i18nInLocale));
this._normalizedLocale));
}

if (!this._JitMode) {
Expand Down
6 changes: 5 additions & 1 deletion tests/e2e/tests/i18n/build-locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ export default function () {
.then(() => expectFileToMatch('dist/main.bundle.js', /registerLocaleData/))
.then(() => expectFileToMatch('dist/main.bundle.js', /angular_common_locales_fr/))
.then(() => rimraf('dist'))
.then(() => expectToFail(() => ng('build', '--aot', '--locale=no-locale')))
.then(() => ng('build', '--aot', '--locale=fr_FR'))
.then(() => expectFileToMatch('dist/main.bundle.js', /registerLocaleData/))
.then(() => expectFileToMatch('dist/main.bundle.js', /angular_common_locales_fr/))
.then(() => rimraf('dist'))
.then(() => expectToFail(() => ng('build', '--aot', '--locale=no-locale')));
}

0 comments on commit b056b1d

Please sign in to comment.