Skip to content

Commit 9d88c96

Browse files
alan-agius4clydin
authored andcommitted
fix(@angular-devkit/build-angular): replace fallback locale for en-US
Pre version 14, the locale for `en-US` was `en-US-POSIX`. now in version 14, this has changed to `en-US`. List of all available locales https://github.com/unicode-org/cldr-json/blob/7033ea9b03aad6ef9cc64057d9cb88fec3fecc53/cldr-json/cldr-core/availableLocales.json#L64 Closes #23334 (cherry picked from commit 1f66ede)
1 parent bb6c200 commit 9d88c96

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

packages/angular_devkit/build_angular/src/utils/i18n-options.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,14 @@ export async function configureI18nBuild<T extends BrowserBuilderSchema | Server
200200
localeDataPath = findLocaleDataPath(first.toLowerCase(), localeResolver);
201201
if (localeDataPath) {
202202
context.logger.warn(
203-
`Locale data for '${locale}' cannot be found. Using locale data for '${first}'.`,
203+
`Locale data for '${locale}' cannot be found. Using locale data for '${first}'.`,
204204
);
205205
}
206206
}
207207
}
208208
if (!localeDataPath) {
209209
context.logger.warn(
210-
`Locale data for '${locale}' cannot be found. No locale data will be included for this locale.`,
210+
`Locale data for '${locale}' cannot be found. No locale data will be included for this locale.`,
211211
);
212212
} else {
213213
desc.dataPath = localeDataPath;
@@ -268,12 +268,8 @@ function findLocaleDataPath(locale: string, resolver: (locale: string) => string
268268
try {
269269
return resolver(scrubbedLocale);
270270
} catch {
271-
if (scrubbedLocale === 'en-US') {
272-
// fallback to known existing en-US locale data as of 9.0
273-
return findLocaleDataPath('en-US-POSIX', resolver);
274-
}
275-
276-
return null;
271+
// fallback to known existing en-US locale data as of 14.0
272+
return scrubbedLocale === 'en-US' ? findLocaleDataPath('en', resolver) : null;
277273
}
278274
}
279275

tests/legacy-cli/e2e/tests/i18n/ivy-localize-es2015.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expectFileNotToExist, expectFileToMatch, readFile, writeFile } from '../../utils/fs';
1+
import { expectFileNotToExist, expectFileToMatch, readFile } from '../../utils/fs';
22
import { ng } from '../../utils/process';
33
import { expectToFail } from '../../utils/utils';
44
import { externalServer, langTranslations, setupI18nConfig } from './setup';
@@ -7,9 +7,13 @@ export default async function () {
77
// Setup i18n tests and config.
88
await setupI18nConfig();
99

10-
await writeFile('.browserslistrc', 'Chrome 65');
10+
const { stderr } = await ng('build', '--source-map');
11+
if (/Locale data for .+ cannot be found/.test(stderr)) {
12+
throw new Error(
13+
`A warning for a locale not found was shown. This should not happen.\n\nSTDERR:\n${stderr}\n`,
14+
);
15+
}
1116

12-
await ng('build', '--source-map');
1317
for (const { lang, outputPath, translation } of langTranslations) {
1418
await expectFileToMatch(`${outputPath}/main.js`, translation.helloPartial);
1519
await expectToFail(() => expectFileToMatch(`${outputPath}/main.js`, '$localize`'));

tests/legacy-cli/e2e/tests/i18n/ivy-localize-locale-data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default async function () {
2525
});
2626

2727
const { stderr: err1 } = await ng('build');
28-
if (!err1.includes(`Locale data for 'fr-Abcd' cannot be found. Using locale data for 'fr'.`)) {
28+
if (!err1.includes(`Locale data for 'fr-Abcd' cannot be found. Using locale data for 'fr'.`)) {
2929
throw new Error('locale data fallback warning not shown');
3030
}
3131

0 commit comments

Comments
 (0)