Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions packages/angular_devkit/build_angular/src/utils/i18n-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,14 @@ export async function configureI18nBuild<T extends BrowserBuilderSchema | Server
localeDataPath = findLocaleDataPath(first.toLowerCase(), localeResolver);
if (localeDataPath) {
context.logger.warn(
`Locale data for '${locale}' cannot be found. Using locale data for '${first}'.`,
`Locale data for '${locale}' cannot be found. Using locale data for '${first}'.`,
);
}
}
}
if (!localeDataPath) {
context.logger.warn(
`Locale data for '${locale}' cannot be found. No locale data will be included for this locale.`,
`Locale data for '${locale}' cannot be found. No locale data will be included for this locale.`,
);
} else {
desc.dataPath = localeDataPath;
Expand Down Expand Up @@ -268,12 +268,8 @@ function findLocaleDataPath(locale: string, resolver: (locale: string) => string
try {
return resolver(scrubbedLocale);
} catch {
if (scrubbedLocale === 'en-US') {
// fallback to known existing en-US locale data as of 9.0
return findLocaleDataPath('en-US-POSIX', resolver);
}

return null;
// fallback to known existing en-US locale data as of 14.0
return scrubbedLocale === 'en-US' ? findLocaleDataPath('en', resolver) : null;
}
}

Expand Down
10 changes: 7 additions & 3 deletions tests/legacy-cli/e2e/tests/i18n/ivy-localize-es2015.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expectFileNotToExist, expectFileToMatch, readFile, writeFile } from '../../utils/fs';
import { expectFileNotToExist, expectFileToMatch, readFile } from '../../utils/fs';
import { ng } from '../../utils/process';
import { expectToFail } from '../../utils/utils';
import { externalServer, langTranslations, setupI18nConfig } from './setup';
Expand All @@ -7,9 +7,13 @@ export default async function () {
// Setup i18n tests and config.
await setupI18nConfig();

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

await ng('build', '--source-map');
for (const { lang, outputPath, translation } of langTranslations) {
await expectFileToMatch(`${outputPath}/main.js`, translation.helloPartial);
await expectToFail(() => expectFileToMatch(`${outputPath}/main.js`, '$localize`'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default async function () {
});

const { stderr: err1 } = await ng('build');
if (!err1.includes(`Locale data for 'fr-Abcd' cannot be found. Using locale data for 'fr'.`)) {
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');
}

Expand Down