Skip to content

Commit d3f8563

Browse files
author
Angular Builds
committed
0a570c0 feat(@angular/build): add support for customizing URL segments with i18n
1 parent 21836e6 commit d3f8563

File tree

7 files changed

+21
-16
lines changed

7 files changed

+21
-16
lines changed

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"name": "@angular-devkit/build-angular",
3-
"version": "19.1.0-next.0+sha-d7214e9",
3+
"version": "19.1.0-next.0+sha-0a570c0",
44
"description": "Angular Webpack Build Facade",
55
"main": "src/index.js",
66
"typings": "src/index.d.ts",
77
"builders": "builders.json",
88
"dependencies": {
99
"@ampproject/remapping": "2.3.0",
10-
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#d7214e9",
11-
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#d7214e9",
12-
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#d7214e9",
13-
"@angular/build": "github:angular/angular-build-builds#d7214e9",
10+
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#0a570c0",
11+
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#0a570c0",
12+
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#0a570c0",
13+
"@angular/build": "github:angular/angular-build-builds#0a570c0",
1414
"@babel/core": "7.26.0",
1515
"@babel/generator": "7.26.3",
1616
"@babel/helper-annotate-as-pure": "7.25.9",
@@ -21,7 +21,7 @@
2121
"@babel/preset-env": "7.26.0",
2222
"@babel/runtime": "7.26.0",
2323
"@discoveryjs/json-ext": "0.6.3",
24-
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#d7214e9",
24+
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#0a570c0",
2525
"@vitejs/plugin-basic-ssl": "1.2.0",
2626
"ansi-colors": "4.1.3",
2727
"autoprefixer": "10.4.20",
@@ -70,7 +70,7 @@
7070
"@angular/localize": "^19.0.0 || ^19.1.0-next.0",
7171
"@angular/platform-server": "^19.0.0 || ^19.1.0-next.0",
7272
"@angular/service-worker": "^19.0.0 || ^19.1.0-next.0",
73-
"@angular/ssr": "github:angular/angular-ssr-builds#d7214e9",
73+
"@angular/ssr": "github:angular/angular-ssr-builds#0a570c0",
7474
"@web/test-runner": "^0.19.0",
7575
"browser-sync": "^3.0.2",
7676
"jest": "^29.5.0",
@@ -91,7 +91,7 @@
9191
"@angular/service-worker": {
9292
"optional": true
9393
},
94-
"@angular/ssr": "github:angular/angular-ssr-builds#d7214e9",
94+
"@angular/ssr": "github:angular/angular-ssr-builds#0a570c0",
9595
"@web/test-runner": {
9696
"optional": true
9797
},

src/builders/browser/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,15 @@ function buildWebpackBrowser(options, context, transforms = {}) {
316316
})));
317317
}));
318318
function getLocaleBaseHref(i18n, locale) {
319-
if (i18n.locales[locale] && i18n.locales[locale]?.baseHref !== '') {
320-
return (0, utils_1.urlJoin)(options.baseHref || '', i18n.locales[locale].baseHref ?? `/${locale}/`);
319+
if (i18n.flatOutput) {
320+
return undefined;
321321
}
322-
return undefined;
322+
const localeData = i18n.locales[locale];
323+
if (!localeData) {
324+
return undefined;
325+
}
326+
const baseHrefSuffix = localeData.baseHref ?? localeData.subPath + '/';
327+
return baseHrefSuffix !== '' ? (0, utils_1.urlJoin)(options.baseHref || '', baseHrefSuffix) : undefined;
323328
}
324329
}
325330
function assertNever(input) {

src/builders/extract-i18n/options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async function normalizeOptions(context, projectName, options) {
3333
// Target specifier defaults to the current project's build target with no specified configuration
3434
const buildTargetSpecifier = options.buildTarget ?? ':';
3535
const buildTarget = (0, architect_1.targetFromTargetString)(buildTargetSpecifier, projectName, 'build');
36-
const i18nOptions = (0, private_1.createI18nOptions)(projectMetadata);
36+
const i18nOptions = (0, private_1.createI18nOptions)(projectMetadata, /** inline */ false, context.logger);
3737
// Normalize xliff format extensions
3838
let format = options.format;
3939
switch (format) {

src/utils/i18n-webpack.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async function configureI18nBuild(context, options) {
3030
const buildOptions = { ...options };
3131
const tsConfig = await (0, read_tsconfig_1.readTsconfig)(buildOptions.tsConfig, context.workspaceRoot);
3232
const metadata = await context.getProjectMetadata(context.target);
33-
const i18n = (0, private_1.createI18nOptions)(metadata, buildOptions.localize);
33+
const i18n = (0, private_1.createI18nOptions)(metadata, buildOptions.localize, context.logger);
3434
// No additional processing needed if no inlining requested and no source locale defined.
3535
if (!i18n.shouldInline && !i18n.hasDefinedSourceLocale) {
3636
return { buildOptions, i18n };

src/utils/normalize-cache.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
1010
exports.normalizeCacheOptions = normalizeCacheOptions;
1111
const node_path_1 = require("node:path");
1212
/** Version placeholder is replaced during the build process with actual package version */
13-
const VERSION = '19.1.0-next.0+sha-d7214e9';
13+
const VERSION = '19.1.0-next.0+sha-0a570c0';
1414
function hasCacheMetadata(value) {
1515
return (!!value &&
1616
typeof value === 'object' &&

src/utils/output-paths.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function ensureOutputPaths(baseOutputPath, i18n) {
1414
const outputPaths = i18n.shouldInline
1515
? [...i18n.inlineLocales].map((l) => [
1616
l,
17-
i18n.flatOutput ? baseOutputPath : (0, path_1.join)(baseOutputPath, l),
17+
i18n.flatOutput ? baseOutputPath : (0, path_1.join)(baseOutputPath, i18n.locales[l].subPath),
1818
])
1919
: [['', baseOutputPath]];
2020
for (const [, outputPath] of outputPaths) {

uniqueId

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Sat Dec 07 2024 17:50:48 GMT+0000 (Coordinated Universal Time)
1+
Sat Dec 07 2024 18:04:56 GMT+0000 (Coordinated Universal Time)

0 commit comments

Comments
 (0)