|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright Google Inc. All Rights Reserved. |
| 4 | + * |
| 5 | + * Use of this source code is governed by an MIT-style license that can be |
| 6 | + * found in the LICENSE file at https://angular.io/license |
| 7 | + */ |
| 8 | +import { ng } from '../../utils/process'; |
| 9 | +import { updateJsonFile } from '../../utils/project'; |
| 10 | +import { setupI18nConfig } from './legacy'; |
| 11 | + |
| 12 | +export default async function() { |
| 13 | + // Setup i18n tests and config. |
| 14 | + await setupI18nConfig(true); |
| 15 | + |
| 16 | + // Update angular.json |
| 17 | + await updateJsonFile('angular.json', workspaceJson => { |
| 18 | + const appProject = workspaceJson.projects['test-project']; |
| 19 | + // tslint:disable-next-line: no-any |
| 20 | + const i18n: Record<string, any> = appProject.i18n; |
| 21 | + |
| 22 | + i18n.sourceLocale = 'fr-Abcd'; |
| 23 | + appProject.architect['build'].options.localize = ['fr-Abcd']; |
| 24 | + }); |
| 25 | + |
| 26 | + const { stderr: err1 } = await ng('build'); |
| 27 | + if (!err1.includes(`Locale data for 'fr-Abcd' cannot be found. Using locale data for 'fr'.`)) { |
| 28 | + throw new Error('locale data fallback warning not shown'); |
| 29 | + } |
| 30 | + |
| 31 | + // Update angular.json |
| 32 | + await updateJsonFile('angular.json', workspaceJson => { |
| 33 | + const appProject = workspaceJson.projects['test-project']; |
| 34 | + // tslint:disable-next-line: no-any |
| 35 | + const i18n: Record<string, any> = appProject.i18n; |
| 36 | + |
| 37 | + i18n.sourceLocale = 'en-US'; |
| 38 | + appProject.architect['build'].options.localize = ['en-US']; |
| 39 | + }); |
| 40 | + |
| 41 | + const { stderr: err2 } = await ng('build'); |
| 42 | + if (err2.includes(`Locale data for 'en-US' cannot be found. No locale data will be included for this locale.`)) { |
| 43 | + throw new Error('locale data not found warning shown'); |
| 44 | + } |
| 45 | + |
| 46 | +} |
0 commit comments