diff --git a/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts b/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts
index 784b3f1311..5603b2e8c7 100644
--- a/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts
+++ b/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts
@@ -2064,6 +2064,21 @@ runInEachFileSystem(os => {
expect(jsContents).toContain(':@@5dbba0a3da8dff890e20cf76eb075d58900fbcd3:Some text');
});
+ it('should render legacy id when `enableI18nLegacyMessageIdFormat` is not false and `i18nInFormat` is set to "xliff"',
+ () => {
+ env.tsconfig({i18nInFormat: 'xliff'});
+ env.write(`test.ts`, `
+ import {Component} from '@angular/core';
+ @Component({
+ selector: 'test',
+ template: '
Some text
'
+ })
+ class FooCmp {}`);
+ env.driveMain();
+ const jsContents = env.getContents('test.js');
+ expect(jsContents).toContain(':@@5dbba0a3da8dff890e20cf76eb075d58900fbcd3:Some text');
+ });
+
it('should render legacy id when `enableI18nLegacyMessageIdFormat` is not false and `i18nInFormat` is set to "xlf2"',
() => {
env.tsconfig({i18nInFormat: 'xlf2'});
@@ -2079,6 +2094,21 @@ runInEachFileSystem(os => {
expect(jsContents).toContain(':@@8321000940098097247:Some text');
});
+ it('should render legacy id when `enableI18nLegacyMessageIdFormat` is not false and `i18nInFormat` is set to "xliff2"',
+ () => {
+ env.tsconfig({i18nInFormat: 'xliff2'});
+ env.write(`test.ts`, `
+ import {Component} from '@angular/core';
+ @Component({
+ selector: 'test',
+ template: 'Some text
'
+ })
+ class FooCmp {}`);
+ env.driveMain();
+ const jsContents = env.getContents('test.js');
+ expect(jsContents).toContain(':@@8321000940098097247:Some text');
+ });
+
it('should render legacy id when `enableI18nLegacyMessageIdFormat` is not false and `i18nInFormat` is set to "xmb"',
() => {
env.tsconfig({i18nInFormat: 'xmb'});
diff --git a/packages/compiler/src/render3/view/i18n/meta.ts b/packages/compiler/src/render3/view/i18n/meta.ts
index 46a873082b..afee55bade 100644
--- a/packages/compiler/src/render3/view/i18n/meta.ts
+++ b/packages/compiler/src/render3/view/i18n/meta.ts
@@ -52,10 +52,11 @@ export class I18nMetaVisitor implements html.Visitor {
message.id = typeof meta !== 'string' && (meta as i18n.Message).id || decimalDigest(message);
}
- if (this.i18nLegacyMessageIdFormat === 'xlf') {
+ if (this.i18nLegacyMessageIdFormat === 'xlf' || this.i18nLegacyMessageIdFormat === 'xliff') {
message.legacyId = computeDigest(message);
} else if (
- this.i18nLegacyMessageIdFormat === 'xlf2' || this.i18nLegacyMessageIdFormat === 'xmb') {
+ this.i18nLegacyMessageIdFormat === 'xlf2' || this.i18nLegacyMessageIdFormat === 'xliff2' ||
+ this.i18nLegacyMessageIdFormat === 'xmb') {
message.legacyId = computeDecimalDigest(message);
} else if (typeof meta !== 'string') {
// This occurs if we are doing the 2nd pass after whitespace removal