-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular-devkit/build-angular): provide locale data discovery fal…
…lbacks This synchronizes the behavior with the FW's wherein the language code will be used if the data for the full locale is not found. The user will still be notified in the event this occurs.
- Loading branch information
Showing
2 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
tests/legacy-cli/e2e/tests/i18n/ivy-localize-locale-data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
import { ng } from '../../utils/process'; | ||
import { updateJsonFile } from '../../utils/project'; | ||
import { setupI18nConfig } from './legacy'; | ||
|
||
export default async function() { | ||
// Setup i18n tests and config. | ||
await setupI18nConfig(true); | ||
|
||
// Update angular.json | ||
await updateJsonFile('angular.json', workspaceJson => { | ||
const appProject = workspaceJson.projects['test-project']; | ||
// tslint:disable-next-line: no-any | ||
const i18n: Record<string, any> = appProject.i18n; | ||
|
||
i18n.sourceLocale = 'fr-Abcd'; | ||
appProject.architect['build'].options.localize = ['fr-Abcd']; | ||
}); | ||
|
||
const { stderr: err1 } = await ng('build'); | ||
if (!err1.includes(`Locale data for 'fr-Abcd' cannot be found. Using locale data for 'fr'.`)) { | ||
throw new Error('locale data fallback warning not shown'); | ||
} | ||
|
||
// Update angular.json | ||
await updateJsonFile('angular.json', workspaceJson => { | ||
const appProject = workspaceJson.projects['test-project']; | ||
// tslint:disable-next-line: no-any | ||
const i18n: Record<string, any> = appProject.i18n; | ||
|
||
i18n.sourceLocale = 'en-US'; | ||
appProject.architect['build'].options.localize = ['en-US']; | ||
}); | ||
|
||
const { stderr: err2 } = await ng('build'); | ||
if (err2.includes(`Locale data for 'en-US' cannot be found. No locale data will be included for this locale.`)) { | ||
throw new Error('locale data not found warning shown'); | ||
} | ||
|
||
} |