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

@ -3385,6 +3385,30 @@ describe('i18n support in the template compiler', () => {
verify(input, output);
});
it('should attach metadata in case an ICU represents the whole message', () => {
const input = `
<div i18n="meaningA|descA@@idA">{count, select, 1 {one} other {more than one}}</div>
`;
const output = String.raw `
var $I18N_0$;
if (ngI18nClosureMode) {
/**
* @desc descA
* @meaning meaningA
*/
const $MSG_EXTERNAL_idA$$APP_SPEC_TS_1$ = goog.getMsg("{VAR_SELECT, select, 1 {one} other {more than one}}");
$I18N_0$ = $MSG_EXTERNAL_idA$$APP_SPEC_TS_1$;
}
else {
$I18N_0$ = $localize \`:meaningA|descA@@idA:{VAR_SELECT, select, 1 {one} other {more than one}}\`;
}
$I18N_0$ = i0.ɵɵi18nPostprocess($I18N_0$, { "VAR_SELECT": "\uFFFD0\uFFFD" });
`;
verify(input, output);
});
});
describe('errors', () => {