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:
Andrew Kushnir
2019-10-15 15:54:14 -07:00
committed by Matias Niemelä
parent 1a8bd22fa3
commit 7e64bbe5a8
3 changed files with 49 additions and 3 deletions

View File

@ -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;