Skip to content

Commit cda57ae

Browse files
clydinvikerman
authored andcommitted
feat(@angular-devkit/build-angular): optimize i18n localize usage in source locale
1 parent cf116da commit cda57ae

File tree

3 files changed

+6
-22
lines changed

3 files changed

+6
-22
lines changed

packages/angular_devkit/build_angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
},
9999
"peerDependencies": {
100100
"@angular/compiler-cli": ">=9.0.0-beta < 10",
101-
"@angular/localize": "^9.0.0-next.10",
101+
"@angular/localize": "^9.0.0-next.11",
102102
"typescript": ">=3.6 < 3.7"
103103
},
104104
"peerDependenciesMeta": {

packages/angular_devkit/build_angular/src/browser/index.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -459,30 +459,15 @@ export function buildWebpackBrowser(
459459

460460
const diagnostics = new localizeDiag.Diagnostics();
461461
const translationFilePaths = [];
462-
let copySourceLocale = false;
462+
let handleSourceLocale = false;
463463
for (const locale of i18n.inlineLocales) {
464464
if (locale === i18n.sourceLocale) {
465-
copySourceLocale = true;
465+
handleSourceLocale = true;
466466
continue;
467467
}
468468
translationFilePaths.push(i18n.locales[locale].file);
469469
}
470470

471-
if (copySourceLocale) {
472-
await copyAssets(
473-
[
474-
{
475-
glob: '**/*',
476-
// tslint:disable-next-line: no-non-null-assertion
477-
input: webpackStats.outputPath!,
478-
output: i18n.sourceLocale,
479-
},
480-
],
481-
[baseOutputPath],
482-
'',
483-
);
484-
}
485-
486471
if (translationFilePaths.length > 0) {
487472
const sourceFilePaths = [];
488473
for (const result of processResults) {
@@ -503,6 +488,7 @@ export function buildWebpackBrowser(
503488
path.join(baseOutputPath, locale, relativePath),
504489
diagnostics,
505490
missingTranslation: options.i18nMissingTranslation || 'warning',
491+
sourceLocale: handleSourceLocale ? i18n.sourceLocale : undefined,
506492
});
507493
} catch (err) {
508494
context.logger.error('Localized bundle generation failed: ' + err.message);

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ export default async function() {
2525
}
2626
await npm('install', `${localizeVersion}`);
2727

28-
// Temporarily add the localize "polyfill" -- release version will not need this
29-
// TODO: Remove after next framework release
30-
await appendToFile('src/polyfills.ts', '\nimport "@angular/localize/init";');
31-
3228
const baseDir = 'dist/test-project';
3329

3430
// Set configurations for each locale.
@@ -108,6 +104,8 @@ export default async function() {
108104
for (const { lang, translation } of langTranslations) {
109105
await expectFileToMatch(`${baseDir}/${lang}/main-es5.js`, translation);
110106
await expectFileToMatch(`${baseDir}/${lang}/main-es2015.js`, translation);
107+
await expectToFail(() => expectFileToMatch(`${baseDir}/${lang}/main-es5.js`, '$localize'));
108+
await expectToFail(() => expectFileToMatch(`${baseDir}/${lang}/main-es2015.js`, '$localize'));
111109

112110
// Ivy i18n doesn't yet work with `ng serve` so we must use a separate server.
113111
const app = express();

0 commit comments

Comments
 (0)