Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): control legacy ID i18n extraction…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
clydin authored and filipesilva committed Nov 2, 2020
1 parent d10cf91 commit 21ea651
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function getI18nOutfile(format: string | undefined) {
}
}

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

let usingIvy = false;
let useLegacyIds = true;

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

// Default value for legacy message ids is currently true
useLegacyIds = wco.tsConfig.options.enableI18nLegacyMessageIdFormat ?? true;

// Ivy extraction is the default for Ivy applications.
usingIvy = (isIvyApplication && options.ivy === undefined) || !!options.ivy;

Expand Down Expand Up @@ -244,6 +248,7 @@ export async function execute(
options.format,
i18n.sourceLocale,
config.context || projectRoot,
useLegacyIds,
);
const content = serializer.serialize(ivyMessages);

Expand Down

0 comments on commit 21ea651

Please sign in to comment.