fix(ivy): use container i18n meta if a message is a single ICU (#33191)
Prior to this commit, metadata defined on ICU container element was not inherited by the ICU if the whole message is a single ICU (for example: `<ng-container i18n="meaning|description@@id">{count, select, ...}</ng-container>). This commit updates the logic to use parent container i18n meta information for the cases when a message consists of a single ICU. Fixes #33171 PR Close #33191
This commit is contained in:

committed by
Matias Niemelä

parent
1a8bd22fa3
commit
7e64bbe5a8
@ -111,7 +111,7 @@ export class I18nMetaVisitor implements html.Visitor {
|
||||
element.attrs = attrs;
|
||||
}
|
||||
}
|
||||
html.visitAll(this, element.children);
|
||||
html.visitAll(this, element.children, element.i18n);
|
||||
return element;
|
||||
}
|
||||
|
||||
@ -127,8 +127,10 @@ export class I18nMetaVisitor implements html.Visitor {
|
||||
const icu = icuFromI18nMessage(message);
|
||||
icu.name = name;
|
||||
} else {
|
||||
// when ICU is a root level translation
|
||||
message = this._generateI18nMessage([expansion], meta);
|
||||
// ICU is a top level message, try to use metadata from container element if provided via
|
||||
// `context` argument. Note: context may not be available for standalone ICUs (without
|
||||
// wrapping element), so fallback to ICU metadata in this case.
|
||||
message = this._generateI18nMessage([expansion], context || meta);
|
||||
}
|
||||
expansion.i18n = message;
|
||||
return expansion;
|
||||
|
Reference in New Issue
Block a user