refactor(compiler): i18n - render legacy i18n message ids (#34135)
Now that `@angular/localize` can interpret multiple legacy message ids in the metablock of a `$localize` tagged template string, this commit adds those ids to each i18n message extracted from component templates, but only if the `enableI18nLegacyMessageIdFormat` is not `false`. PR Close #34135
This commit is contained in:

committed by
Miško Hevery

parent
8e96b450e2
commit
e524322c43
@ -509,12 +509,20 @@ export class LocalizedString extends Expression {
|
||||
* @param messagePart The first part of the tagged string
|
||||
*/
|
||||
serializeI18nHead(): {cooked: string, raw: string} {
|
||||
const MEANING_SEPARATOR = '|';
|
||||
const ID_SEPARATOR = '@@';
|
||||
const LEGACY_ID_INDICATOR = '␟';
|
||||
|
||||
let metaBlock = this.metaBlock.description || '';
|
||||
if (this.metaBlock.meaning) {
|
||||
metaBlock = `${this.metaBlock.meaning}|${metaBlock}`;
|
||||
metaBlock = `${this.metaBlock.meaning}${MEANING_SEPARATOR}${metaBlock}`;
|
||||
}
|
||||
if (this.metaBlock.customId || this.metaBlock.legacyId) {
|
||||
metaBlock = `${metaBlock}@@${this.metaBlock.customId || this.metaBlock.legacyId}`;
|
||||
if (this.metaBlock.customId) {
|
||||
metaBlock = `${metaBlock}${ID_SEPARATOR}${this.metaBlock.customId}`;
|
||||
}
|
||||
if (this.metaBlock.legacyIds) {
|
||||
this.metaBlock.legacyIds.forEach(
|
||||
legacyId => { metaBlock = `${metaBlock}${LEGACY_ID_INDICATOR}${legacyId}`; });
|
||||
}
|
||||
return createCookedRawString(metaBlock, this.messageParts[0]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user