Skip to content

Commit 21ea651

Browse files
clydinfilipesilva
authored andcommitted
fix(@angular-devkit/build-angular): control legacy ID i18n extraction via TypeScript configuration
This change allows the usage of the legacy i18n message identifier format during extraction to be controlled via the `angularCompilerOptions` option `enableI18nLegacyMessageIdFormat` within the application's TypeScript configuration.
1 parent d10cf91 commit 21ea651

File tree

1 file changed

+6
-1
lines changed
  • packages/angular_devkit/build_angular/src/extract-i18n

1 file changed

+6
-1
lines changed

packages/angular_devkit/build_angular/src/extract-i18n/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function getI18nOutfile(format: string | undefined) {
4242
}
4343
}
4444

45-
async function getSerializer(format: Format, sourceLocale: string, basePath: string, useLegacyIds = true) {
45+
async function getSerializer(format: Format, sourceLocale: string, basePath: string, useLegacyIds: boolean) {
4646
switch (format) {
4747
case Format.Xmb:
4848
const { XmbTranslationSerializer } =
@@ -125,6 +125,7 @@ export async function execute(
125125
const i18n = createI18nOptions(metadata);
126126

127127
let usingIvy = false;
128+
let useLegacyIds = true;
128129

129130
const ivyMessages: LocalizeMessage[] = [];
130131
const { config, projectRoot } = await generateBrowserWebpackConfigFromContext(
@@ -154,6 +155,9 @@ export async function execute(
154155
(wco) => {
155156
const isIvyApplication = wco.tsConfig.options.enableIvy !== false;
156157

158+
// Default value for legacy message ids is currently true
159+
useLegacyIds = wco.tsConfig.options.enableI18nLegacyMessageIdFormat ?? true;
160+
157161
// Ivy extraction is the default for Ivy applications.
158162
usingIvy = (isIvyApplication && options.ivy === undefined) || !!options.ivy;
159163

@@ -244,6 +248,7 @@ export async function execute(
244248
options.format,
245249
i18n.sourceLocale,
246250
config.context || projectRoot,
251+
useLegacyIds,
247252
);
248253
const content = serializer.serialize(ivyMessages);
249254

0 commit comments

Comments
 (0)