Skip to content

Commit a0457e4

Browse files
author
Angular Builds
committed
798790622 fix(@angular-devkit/build-angular): allow new i18n options to work with VE
1 parent 02e701d commit a0457e4

File tree

6 files changed

+37
-18
lines changed

6 files changed

+37
-18
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{
22
"name": "@angular-devkit/build-angular",
3-
"version": "0.900.0-next.19+106.08f0067",
3+
"version": "0.900.0-next.19+107.7987906",
44
"description": "Angular Webpack Build Facade",
55
"experimental": true,
66
"main": "src/index.js",
77
"typings": "src/index.d.ts",
88
"builders": "builders.json",
99
"dependencies": {
10-
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#08f006714",
11-
"@angular-devkit/build-optimizer": "github:angular/angular-devkit-build-optimizer-builds#08f006714",
12-
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#08f006714",
13-
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#08f006714",
10+
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#798790622",
11+
"@angular-devkit/build-optimizer": "github:angular/angular-devkit-build-optimizer-builds#798790622",
12+
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#798790622",
13+
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#798790622",
1414
"@babel/core": "7.7.2",
1515
"@babel/generator": "7.7.2",
1616
"@babel/preset-env": "7.7.1",
17-
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#08f006714",
17+
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#798790622",
1818
"ajv": "6.10.2",
1919
"autoprefixer": "9.7.1",
2020
"babel-loader": "8.0.6",

src/utils/i18n-options.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface I18nOptions {
2020
}>;
2121
flatOutput?: boolean;
2222
readonly shouldInline: boolean;
23+
veCompatLocale?: string;
2324
}
2425
export declare function createI18nOptions(metadata: json.JsonObject, inline?: boolean | string[]): I18nOptions;
2526
export declare function configureI18nBuild<T extends BrowserBuilderSchema | ServerBuilderSchema>(context: BuilderContext, options: T): Promise<{

src/utils/i18n-options.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,22 @@ async function configureI18nBuild(context, options) {
7171
mergeDeprecatedI18nOptions(i18n, buildOptions.i18nLocale, buildOptions.i18nFile);
7272
}
7373
else if (buildOptions.localize !== undefined && !usingIvy) {
74-
buildOptions.localize = undefined;
75-
context.logger.warn(`Option 'localize' is not supported with View Engine.`);
74+
if (buildOptions.localize === true ||
75+
(Array.isArray(buildOptions.localize) && buildOptions.localize.length > 1)) {
76+
throw new Error(`Localization with multiple locales in one build is not supported with View Engine.`);
77+
}
78+
for (const deprecatedOption of ['i18nLocale', 'i18nFormat', 'i18nFile']) {
79+
// tslint:disable-next-line: no-any
80+
if (typeof buildOptions[deprecatedOption] !== 'undefined') {
81+
context.logger.warn(`Option 'localize' and deprecated '${deprecatedOption}' found. Using 'localize'.`);
82+
}
83+
}
84+
if (buildOptions.localize === false ||
85+
(Array.isArray(buildOptions.localize) && buildOptions.localize.length === 0)) {
86+
buildOptions.i18nFile = undefined;
87+
buildOptions.i18nLocale = undefined;
88+
buildOptions.i18nFormat = undefined;
89+
}
7690
}
7791
// Clear deprecated options when using Ivy to prevent unintended behavior
7892
if (usingIvy) {
@@ -120,6 +134,17 @@ async function configureI18nBuild(context, options) {
120134
if (usedFormats.size > 0) {
121135
buildOptions.i18nFormat = [...usedFormats][0];
122136
}
137+
// Provide support for using the Ivy i18n options with VE
138+
if (!usingIvy) {
139+
i18n.veCompatLocale = buildOptions.i18nLocale = [...i18n.inlineLocales][0];
140+
if (buildOptions.i18nLocale !== i18n.sourceLocale) {
141+
buildOptions.i18nFile = i18n.locales[buildOptions.i18nLocale].file;
142+
}
143+
// Clear inline locales to prevent any new i18n related processing
144+
i18n.inlineLocales.clear();
145+
// Update the output path to include the locale to mimic Ivy localize behavior
146+
buildOptions.outputPath = path.join(buildOptions.outputPath, buildOptions.i18nLocale);
147+
}
123148
}
124149
// If inlining store the output in a temporary location to facilitate post-processing
125150
if (i18n.shouldInline) {

src/utils/output-paths.d.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
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-
*/
81
import { I18nOptions } from './i18n-options';
92
export declare function ensureOutputPaths(baseOutputPath: string, i18n: I18nOptions): string[];

src/utils/output-paths.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
23
/**
34
* @license
45
* Copyright Google Inc. All Rights Reserved.
56
*
67
* Use of this source code is governed by an MIT-style license that can be
78
* found in the LICENSE file at https://angular.io/license
89
*/
9-
Object.defineProperty(exports, "__esModule", { value: true });
1010
const fs_1 = require("fs");
1111
const path_1 = require("path");
1212
function ensureOutputPaths(baseOutputPath, i18n) {
1313
const outputPaths = i18n.shouldInline && !i18n.flatOutput
1414
? [...i18n.inlineLocales].map(l => path_1.join(baseOutputPath, l))
15-
: [baseOutputPath];
15+
: [i18n.veCompatLocale ? path_1.join(baseOutputPath, i18n.veCompatLocale) : baseOutputPath];
1616
for (const outputPath of outputPaths) {
1717
if (!fs_1.existsSync(outputPath)) {
1818
fs_1.mkdirSync(outputPath, { recursive: true });

uniqueId

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Mon Nov 18 2019 19:07:09 GMT+0000 (Coordinated Universal Time)
1+
Mon Nov 18 2019 19:27:45 GMT+0000 (Coordinated Universal Time)

0 commit comments

Comments
 (0)