fix(ivy): i18n - update the compiler to output `MessageId`s (#32594)

Now that the `$localize` translations are `MessageId` based the
compiler must render `MessageId`s in its generated `$localize` code.
This is because the `MessageId` used by the compiler is computed
from information that does not get passed through to the `$localize`
tagged string.

For example, the generated code for the following template

```html
<div id="static" i18n-title="m|d" title="introduction"></div>
```

will contain these localization statements

```ts
if (ngI18nClosureMode) {
  /**
    * @desc d
    * @meaning m
    */
  const MSG_EXTERNAL_8809028065680254561$$APP_SPEC_TS_1 = goog.getMsg("introduction");
  I18N_1 = MSG_EXTERNAL_8809028065680254561$$APP_SPEC_TS_1;
}
else {
  I18N_1 = $localize \`:m|d@@8809028065680254561:introduction\`;
}
```

Since `$localize` is not able to accurately regenerate the source-message
(and so the `MessageId`) from the generated code, it must rely upon the
`MessageId` being provided explicitly in the generated code.

The compiler now prepends all localized messages with a "metadata block"
containing the id (and the meaning and description if defined).

Note that this metadata block will also allow translation file extraction
from the compiled code - rather than relying on the legacy ViewEngine
extraction code. (This will be implemented post-v9).

Although these metadata blocks add to the initial code size, compile-time
inlining will completely remove these strings and so will not impact on
production bundle size.

PR Close #32594
This commit is contained in:
Pete Bacon Darwin 2019-09-13 12:46:05 +01:00 committed by Andrew Kushnir
parent 357aa4a097
commit b741a1c3e7
8 changed files with 1282 additions and 1365 deletions

View File

@ -176,7 +176,7 @@ describe('i18n support in the template compiler', () => {
const input = `
<div i18n="meaningA|descA@@idA">Content A</div>
<div i18n-title="meaningB|descB@@idB" title="Title B">Content B</div>
<div i18n-title="meaningC" title="Title C">Content C</div>
<div i18n-title="meaningC|" title="Title C">Content C</div>
<div i18n-title="meaningD|descD" title="Title D">Content D</div>
<div i18n-title="meaningE@@idE" title="Title E">Content E</div>
<div i18n-title="@@idF" title="Title F">Content F</div>
@ -194,7 +194,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_idA$$APP_SPEC_TS_1$;
}
else {
$I18N_0$ = $localize \`Content A\`;
$I18N_0$ = $localize \`:meaningA|descA@@idA:Content A\`;
}
const $_c2$ = [${AttributeMarker.I18n}, "title"];
var $I18N_3$;
@ -207,19 +207,19 @@ describe('i18n support in the template compiler', () => {
$I18N_3$ = $MSG_EXTERNAL_idB$$APP_SPEC_TS_4$;
}
else {
$I18N_3$ = $localize \`Title B\`;
$I18N_3$ = $localize \`:meaningB|descB@@idB:Title B\`;
}
const $_c5$ = ["title", $I18N_3$];
var $I18N_7$;
if (ngI18nClosureMode) {
/**
* @desc meaningC
* @meaning meaningC
*/
const $MSG_EXTERNAL_4978592519614169666$$APP_SPEC_TS_8$ = goog.getMsg("Title C");
$I18N_7$ = $MSG_EXTERNAL_4978592519614169666$$APP_SPEC_TS_8$;
const $MSG_EXTERNAL_6435899732746131543$$APP_SPEC_TS_8$ = goog.getMsg("Title C");
$I18N_7$ = $MSG_EXTERNAL_6435899732746131543$$APP_SPEC_TS_8$;
}
else {
$I18N_7$ = $localize \`Title C\`;
$I18N_7$ = $localize \`:meaningC|@@6435899732746131543:Title C\`;
}
const $_c9$ = ["title", $I18N_7$];
var $I18N_11$;
@ -232,7 +232,7 @@ describe('i18n support in the template compiler', () => {
$I18N_11$ = $MSG_EXTERNAL_5200291527729162531$$APP_SPEC_TS_12$;
}
else {
$I18N_11$ = $localize \`Title D\`;
$I18N_11$ = $localize \`:meaningD|descD@@5200291527729162531:Title D\`;
}
const $_c13$ = ["title", $I18N_11$];
var $I18N_15$;
@ -244,7 +244,7 @@ describe('i18n support in the template compiler', () => {
$I18N_15$ = $MSG_EXTERNAL_idE$$APP_SPEC_TS_16$;
}
else {
$I18N_15$ = $localize \`Title E\`;
$I18N_15$ = $localize \`:meaningE@@idE:Title E\`;
}
const $_c17$ = ["title", $I18N_15$];
var $I18N_19$;
@ -253,7 +253,7 @@ describe('i18n support in the template compiler', () => {
$I18N_19$ = $MSG_EXTERNAL_idF$$APP_SPEC_TS_20$;
}
else {
$I18N_19$ = $localize \`Title F\`;
$I18N_19$ = $localize \`:@@idF:Title F\`;
}
const $_c21$ = ["title", $I18N_19$];
var $I18N_23$;
@ -265,7 +265,7 @@ describe('i18n support in the template compiler', () => {
$I18N_23$ = $MSG_EXTERNAL_idG$$APP_SPEC_TS_24$;
}
else {
$I18N_23$ = $localize \`Title G\`;
$I18N_23$ = $localize \`:[BACKUP_MESSAGE_ID:idH]desc@@idG:Title G\`;
}
const $_c25$ = ["title", $I18N_23$];
@ -365,7 +365,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_8809028065680254561$$APP_SPEC_TS_1$;
}
else {
$I18N_1$ = $localize \`introduction\`;
$I18N_1$ = $localize \`:m|d@@8809028065680254561:introduction\`;
}
const $_c1$ = ["title", $I18N_1$];
@ -402,7 +402,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_5526535577705876535$$APP_SPEC_TS_1$;
}
else {
$I18N_1$ = $localize \`static text\`;
$I18N_1$ = $localize \`:@@5526535577705876535:static text\`;
}
var $I18N_2$;
if (ngI18nClosureMode) {
@ -416,7 +416,7 @@ describe('i18n support in the template compiler', () => {
$I18N_2$ = $MSG_EXTERNAL_8977039798304050198$$APP_SPEC_TS_2$;
}
else {
$I18N_2$ = $localize \`intro $` +
$I18N_2$ = $localize \`:m|d@@8977039798304050198:intro $` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
}
var $I18N_3$;
@ -431,7 +431,7 @@ describe('i18n support in the template compiler', () => {
$I18N_3$ = $MSG_EXTERNAL_7432761130955693041$$APP_SPEC_TS_3$;
}
else {
$I18N_3$ = $localize \`$` +
$I18N_3$ = $localize \`:m1|d1@@7432761130955693041:$` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
}
const $_c1$ = [
@ -452,7 +452,7 @@ describe('i18n support in the template compiler', () => {
$I18N_6$ = $MSG_EXTERNAL_7566208596013750546$$APP_SPEC_TS_6$;
}
else {
$I18N_6$ = $localize \`$` +
$I18N_6$ = $localize \`:m2|d2@@7566208596013750546:$` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION: and $` +
String.raw `{"\uFFFD1\uFFFD"}:INTERPOLATION_1: and again $` +
String.raw `{"\uFFFD2\uFFFD"}:INTERPOLATION_2:\`;
@ -465,7 +465,7 @@ describe('i18n support in the template compiler', () => {
$I18N_7$ = $MSG_EXTERNAL_6639222533406278123$$APP_SPEC_TS_7$;
}
else {
$I18N_7$ = $localize \`$` +
$I18N_7$ = $localize \`:@@6639222533406278123:$` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
}
const $_c3$ = [
@ -516,7 +516,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_8977039798304050198$;
}
else {
$I18N_1$ = $localize \`intro $` +
$I18N_1$ = $localize \`:m|d@@8977039798304050198:intro $` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
}
const $_c3$ = ["title", $I18N_1$];
@ -559,7 +559,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_8538466649243975456$$APP_SPEC_TS__1$;
}
else {
$I18N_1$ = $localize \`different scope $` +
$I18N_1$ = $localize \`:m|d@@8538466649243975456:different scope $` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
}
const $_c2$ = ["title", $I18N_1$];
@ -609,7 +609,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_3462388422673575127$$APP_SPEC_TS_2$;
}
else {
$I18N_1$ = $localize \`$` +
$I18N_1$ = $localize \`:@@3462388422673575127:$` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION: title\`;
}
const $_c3$ = ["title", $I18N_1$];
@ -658,7 +658,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_5526535577705876535$$APP_SPEC_TS_1$;
}
else {
$I18N_1$ = $localize \`static text\`;
$I18N_1$ = $localize \`:@@5526535577705876535:static text\`;
}
var $I18N_2$;
if (ngI18nClosureMode) {
@ -672,7 +672,7 @@ describe('i18n support in the template compiler', () => {
$I18N_2$ = $MSG_EXTERNAL_8977039798304050198$$APP_SPEC_TS_2$;
}
else {
$I18N_2$ = $localize \`intro $` +
$I18N_2$ = $localize \`:m|d@@8977039798304050198:intro $` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
}
var $I18N_3$;
@ -687,7 +687,7 @@ describe('i18n support in the template compiler', () => {
$I18N_3$ = $MSG_EXTERNAL_7432761130955693041$$APP_SPEC_TS_3$;
}
else {
$I18N_3$ = $localize \`$` +
$I18N_3$ = $localize \`:m1|d1@@7432761130955693041:$` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
}
const $_c1$ = [
@ -708,7 +708,7 @@ describe('i18n support in the template compiler', () => {
$I18N_6$ = $MSG_EXTERNAL_7566208596013750546$$APP_SPEC_TS_6$;
}
else {
$I18N_6$ = $localize \`$` +
$I18N_6$ = $localize \`:m2|d2@@7566208596013750546:$` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION: and $` +
String.raw `{"\uFFFD1\uFFFD"}:INTERPOLATION_1: and again $` +
String.raw `{"\uFFFD2\uFFFD"}:INTERPOLATION_2:\`;
@ -721,7 +721,7 @@ describe('i18n support in the template compiler', () => {
$I18N_7$ = $MSG_EXTERNAL_6639222533406278123$$APP_SPEC_TS_7$;
}
else {
$I18N_7$ = $localize \`$` +
$I18N_7$ = $localize \`:@@6639222533406278123:$` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
}
const $_c3$ = [
@ -775,7 +775,7 @@ describe('i18n support in the template compiler', () => {
$I18N_2$ = $MSG_EXTERNAL_8538466649243975456$$APP_SPEC_TS__3$;
}
else {
$I18N_2$ = $localize \`different scope $` +
$I18N_2$ = $localize \`:m|d@@8538466649243975456:different scope $` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
}
const $_c4$ = ["title", $I18N_2$];
@ -827,7 +827,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_7727043314656808423$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`Element title\`;
$I18N_0$ = $localize \`:m|d@@7727043314656808423:Element title\`;
}
const $_c1$ = ["title", $I18N_0$];
var $I18N_2$;
@ -836,7 +836,7 @@ describe('i18n support in the template compiler', () => {
$I18N_2$ = $MSG_EXTERNAL_4969674997806975147$$APP_SPEC_TS_2$;
}
else {
$I18N_2$ = $localize \`Some content\`;
$I18N_2$ = $localize \`:@@4969674997806975147:Some content\`;
}
template: function MyComponent_Template(rf, ctx) {
@ -865,7 +865,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_ID_WITH_INVALID_CHARS$$APP_SPEC_TS_1$;
}
else {
$I18N_0$ = $localize \`Element title\`;
$I18N_0$ = $localize \`:@@ID.WITH.INVALID.CHARS:Element title\`;
}
const $_c1$ = ["title", $I18N_0$];
var $I18N_2$;
@ -874,7 +874,7 @@ describe('i18n support in the template compiler', () => {
$I18N_2$ = $MSG_EXTERNAL_ID_WITH_INVALID_CHARS_2$$APP_SPEC_TS_4$;
}
else {
$I18N_2$ = $localize \` Some content \`;
$I18N_2$ = $localize \`:@@ID.WITH.INVALID.CHARS.2: Some content \`;
}
`;
@ -922,11 +922,11 @@ describe('i18n support in the template compiler', () => {
const output = String.raw `
var $I18N_0$;
if (ngI18nClosureMode) {
const $MSG_EXTERNAL_0$ = goog.getMsg("Some text");
$I18N_0$ = $MSG_EXTERNAL_0$;
const $MSG_APP_SPEC_TS_1$ = goog.getMsg("Some text");
$I18N_0$ = $MSG_APP_SPEC_TS_1$;
}
else {
$I18N_0$ = $localize \`Some text\`;
$I18N_0$ = $localize \`:@@3784161717320915177:Some text\`;
}
`;
verify(input, output);
@ -944,7 +944,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_4924931801512133405$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`Some text 'with single quotes', "with double quotes" and without quotes.\`;
$I18N_0$ = $localize \`:@@4924931801512133405:Some text 'with single quotes', "with double quotes" and without quotes.\`;
}
`;
@ -967,7 +967,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_4890179241114413722$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`My i18n block #1\`;
$I18N_0$ = $localize \`:@@4890179241114413722:My i18n block #1\`;
}
var $I18N_1$;
if (ngI18nClosureMode) {
@ -975,7 +975,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_2413150872298537152$$APP_SPEC_TS_1$;
}
else {
$I18N_1$ = $localize \`My i18n block #2\`;
$I18N_1$ = $localize \`:@@2413150872298537152:My i18n block #2\`;
}
var $I18N_2$;
if (ngI18nClosureMode) {
@ -983,7 +983,7 @@ describe('i18n support in the template compiler', () => {
$I18N_2$ = $MSG_EXTERNAL_5023003143537152794$$APP_SPEC_TS_2$;
}
else {
$I18N_2$ = $localize \`My i18n block #3\`;
$I18N_2$ = $localize \`:@@5023003143537152794:My i18n block #3\`;
}
template: function MyComponent_Template(rf, ctx) {
@ -1028,7 +1028,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_7597881511811528589$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \` Named interpolation: $` +
$I18N_0$ = $localize \`:@@7597881511811528589: Named interpolation: $` +
String.raw `{"\uFFFD0\uFFFD"}:PH_A: Named interpolation with spaces: $` +
String.raw `{"\uFFFD1\uFFFD"}:PH_B: \`;
}
@ -1065,7 +1065,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_6749967533321674787$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`$` +
$I18N_0$ = $localize \`:@@6749967533321674787:$` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
}
@ -1096,15 +1096,15 @@ describe('i18n support in the template compiler', () => {
const output = String.raw `
var $I18N_0$;
if (ngI18nClosureMode) {
const $MSG_EXTERNAL_5146016486383316049$$APP_SPEC_TS_1$ = goog.getMsg(" {$interpolation} {$interpolation_1} {$interpolation_2} ", {
const $MSG_APP_SPEC_TS_1$$APP_SPEC_TS_1$ = goog.getMsg(" {$interpolation} {$interpolation_1} {$interpolation_2} ", {
"interpolation": "\uFFFD0\uFFFD",
"interpolation_1": "\uFFFD1\uFFFD",
"interpolation_2": "\uFFFD2\uFFFD"
});
$I18N_0$ = $MSG_EXTERNAL_5146016486383316049$$APP_SPEC_TS_1$;
$I18N_0$ = $MSG_APP_SPEC_TS_1$$APP_SPEC_TS_1$;
}
else {
$I18N_0$ = $localize \` $` +
$I18N_0$ = $localize \`:@@1194644703943451474: $` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION: $` +
String.raw `{"\uFFFD1\uFFFD"}:INTERPOLATION_1: $` +
String.raw `{"\uFFFD2\uFFFD"}:INTERPOLATION_2: \`;
@ -1144,7 +1144,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_572579892698764378$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`My i18n block #$` +
$I18N_0$ = $localize \`:@@572579892698764378:My i18n block #$` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
}
var $I18N_1$;
@ -1155,7 +1155,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_609623417156596326$$APP_SPEC_TS_1$;
}
else {
$I18N_1$ = $localize \`My i18n block #$` +
$I18N_1$ = $localize \`:@@609623417156596326:My i18n block #$` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
}
var $I18N_2$;
@ -1166,7 +1166,7 @@ describe('i18n support in the template compiler', () => {
$I18N_2$ = $MSG_EXTERNAL_3998119318957372120$$APP_SPEC_TS_2$;
}
else {
$I18N_2$ = $localize \`My i18n block #$` +
$I18N_2$ = $localize \`:@@3998119318957372120:My i18n block #$` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
}
@ -1228,7 +1228,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_7905233330103651696$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \` My i18n block #$` +
$I18N_0$ = $localize \`:@@7905233330103651696: My i18n block #$` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION: $` +
String.raw `{"\uFFFD#2\uFFFD"}:START_TAG_SPAN:Plain text in nested element$` +
String.raw `{"\uFFFD/#2\uFFFD"}:CLOSE_TAG_SPAN:\`;
@ -1246,7 +1246,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_5788821996131681377$$APP_SPEC_TS_1$;
}
else {
$I18N_1$ = $localize \` My i18n block #$` +
$I18N_1$ = $localize \`:@@5788821996131681377: My i18n block #$` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION: $` +
String.raw `{"[\uFFFD#6\uFFFD|\uFFFD#7\uFFFD]"}:START_TAG_DIV:$` +
String.raw `{"[\uFFFD#6\uFFFD|\uFFFD#7\uFFFD]"}:START_TAG_DIV:$` + String.raw
@ -1317,7 +1317,7 @@ describe('i18n support in the template compiler', () => {
$I18N_2$ = $MSG_EXTERNAL_4782264005467235841$$APP_SPEC_TS_3$;
}
else {
$I18N_2$ = $localize \`Span title $` +
$I18N_2$ = $localize \`:@@4782264005467235841:Span title $` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION: and $` +
String.raw `{"\uFFFD1\uFFFD"}:INTERPOLATION_1:\`;
}
@ -1332,7 +1332,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_4446430594603971069$$APP_SPEC_TS_5$;
}
else {
$I18N_0$ = $localize \` My i18n block #1 with value: $` +
$I18N_0$ = $localize \`:@@4446430594603971069: My i18n block #1 with value: $` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION: $` + String.raw
`{"\uFFFD#2\uFFFD"}:START_TAG_SPAN: Plain text in nested element (block #1) $` +
String.raw `{"\uFFFD/#2\uFFFD"}:CLOSE_TAG_SPAN:\`;
@ -1345,7 +1345,7 @@ describe('i18n support in the template compiler', () => {
$I18N_7$ = $MSG_EXTERNAL_2719594642740200058$$APP_SPEC_TS_8$;
}
else {
$I18N_7$ = $localize \`Span title $` +
$I18N_7$ = $localize \`:@@2719594642740200058:Span title $` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
}
const $_c9$ = ["title", $I18N_7$];
@ -1359,7 +1359,7 @@ describe('i18n support in the template compiler', () => {
$I18N_6$ = $MSG_EXTERNAL_2778714953278357902$$APP_SPEC_TS_10$;
}
else {
$I18N_6$ = $localize \` My i18n block #2 with value $` +
$I18N_6$ = $localize \`:@@2778714953278357902: My i18n block #2 with value $` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION: $` + String.raw
`{"\uFFFD#7\uFFFD"}:START_TAG_SPAN: Plain text in nested element (block #2) $` +
String.raw `{"\uFFFD/#7\uFFFD"}:CLOSE_TAG_SPAN:\`;
@ -1429,7 +1429,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_7679414751795588050$$APP_SPEC_TS__1$;
}
else {
$I18N_1$ = $localize \` Some other content $` +
$I18N_1$ = $localize \`:@@7679414751795588050: Some other content $` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION: $` +
String.raw `{"\uFFFD#3\uFFFD"}:START_TAG_DIV: More nested levels with bindings $` +
String.raw `{"\uFFFD1\uFFFD"}:INTERPOLATION_1: $` +
@ -1498,7 +1498,7 @@ describe('i18n support in the template compiler', () => {
$I18N_2$ = $MSG_EXTERNAL_2367729185105559721$$APP_SPEC_TS__2$;
}
else {
$I18N_2$ = $localize \`App logo #$` +
$I18N_2$ = $localize \`:@@2367729185105559721:App logo #$` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
}
const $_c4$ = ["title", $I18N_2$];
@ -1613,7 +1613,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_1221890473527419724$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \` Some content $` +
$I18N_0$ = $localize \`:@@1221890473527419724: Some content $` +
String.raw
`{"\uFFFD*2:1\uFFFD\uFFFD#1:1\uFFFD"}:START_TAG_DIV_2: Some other content $` +
String.raw `{"\uFFFD0:1\uFFFD"}:INTERPOLATION: $` + String.raw
@ -1696,7 +1696,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_119975189388320493$$APP_SPEC_TS__1$;
}
else {
$I18N_1$ = $localize \`Some other content $` +
$I18N_1$ = $localize \`:@@119975189388320493:Some other content $` +
String.raw `{"\uFFFD#2\uFFFD"}:START_TAG_SPAN:$` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:$` +
String.raw `{"\uFFFD/#2\uFFFD"}:CLOSE_TAG_SPAN:\`;
@ -1745,7 +1745,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_APP_SPEC_TS_2$;
}
else {
$I18N_1$ = $localize \`Hello\`;
$I18N_1$ = $localize \`:@@3902961887793684628:Hello\`;
}
template: function MyComponent_Template(rf, ctx) {
@ -1775,7 +1775,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_4890179241114413722$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`My i18n block #1\`;
$I18N_0$ = $localize \`:@@4890179241114413722:My i18n block #1\`;
}
template: function MyComponent_Template(rf, ctx) {
@ -1802,7 +1802,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}\`;
$I18N_0$ = $localize \`:@@8806993169187953163:{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}\`;
}
$I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
"VAR_SELECT": "\uFFFD0\uFFFD"
@ -1839,7 +1839,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_2413150872298537152$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`My i18n block #2\`;
$I18N_0$ = $localize \`:@@2413150872298537152:My i18n block #2\`;
}
var $I18N_1$;
if (ngI18nClosureMode) {
@ -1847,7 +1847,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_4890179241114413722$$APP_SPEC_TS__1$;
}
else {
$I18N_1$ = $localize \`My i18n block #1\`;
$I18N_1$ = $localize \`:@@4890179241114413722:My i18n block #1\`;
}
function MyComponent_ng_template_0_Template(rf, ctx) {
if (rf & 1) {
@ -1882,7 +1882,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_5295701706185791735$$APP_SPEC_TS_1$;
}
else {
$I18N_1$ = $localize \`Text #1\`;
$I18N_1$ = $localize \`:@@5295701706185791735:Text #1\`;
}
const $_c2$ = [${AttributeMarker.Styles}, "padding", "10px"];
var $I18N_3$;
@ -1891,7 +1891,7 @@ describe('i18n support in the template compiler', () => {
$I18N_3$ = $MSG_EXTERNAL_4722270221386399294$$APP_SPEC_TS_3$;
}
else {
$I18N_3$ = $localize \`Text #2\`;
$I18N_3$ = $localize \`:@@4722270221386399294:Text #2\`;
}
consts: 4,
@ -1927,7 +1927,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_355394464191978948$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`Some content: $` +
$I18N_0$ = $localize \`:@@355394464191978948:Some content: $` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
}
@ -1964,7 +1964,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_355394464191978948$$APP_SPEC_TS__0$;
}
else {
$I18N_0$ = $localize \`Some content: $` +
$I18N_0$ = $localize \`:@@355394464191978948:Some content: $` +
String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
}
function MyComponent_ng_template_0_Template(rf, ctx) {
@ -2012,7 +2012,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_702706566400598764$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`$` +
$I18N_0$ = $localize \`:@@702706566400598764:$` +
String.raw `{"\uFFFD*2:1\uFFFD"}:START_TAG_NG_TEMPLATE:Template content: $` +
String.raw `{"\uFFFD0:1\uFFFD"}:INTERPOLATION:$` +
String.raw `{"\uFFFD/*2:1\uFFFD"}:CLOSE_TAG_NG_TEMPLATE:$` +
@ -2067,7 +2067,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}\`;
$I18N_0$ = $localize \`:@@8806993169187953163:{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}\`;
}
$I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
"VAR_SELECT": "\uFFFD0\uFFFD"
@ -2078,7 +2078,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS__1$;
}
else {
$I18N_1$ = $localize \`{VAR_SELECT, select, male {male} female {female} other {other}}\`;
$I18N_1$ = $localize \`:@@7842238767399919809:{VAR_SELECT, select, male {male} female {female} other {other}}\`;
}
$I18N_1$ = $r3$.ɵɵi18nPostprocess($I18N_1$, {
"VAR_SELECT": "\uFFFD0\uFFFD"
@ -2163,7 +2163,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_2051477021417799640$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`$` +
$I18N_0$ = $localize \`:@@2051477021417799640:$` +
String.raw
`{"[\uFFFD*2:1\uFFFD|\uFFFD*2:2\uFFFD|\uFFFD*1:3\uFFFD]"}:START_TAG_NG_TEMPLATE: Template A: $` +
String.raw `{"\uFFFD0:1\uFFFD"}:INTERPOLATION: $` + String.raw
@ -2221,7 +2221,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`{VAR_SELECT, select, male {male} female {female} other {other}}\`;
$I18N_0$ = $localize \`:@@7842238767399919809:{VAR_SELECT, select, male {male} female {female} other {other}}\`;
}
$I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
"VAR_SELECT": "\uFFFD0\uFFFD"
@ -2232,7 +2232,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS__1$;
}
else {
$I18N_1$ = $localize \`{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}\`;
$I18N_1$ = $localize \`:@@8806993169187953163:{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}\`;
}
$I18N_1$ = $r3$.ɵɵi18nPostprocess($I18N_1$, {
"VAR_SELECT": "\uFFFD0\uFFFD"
@ -2287,7 +2287,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_4891196282781544695$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`$` +
$I18N_0$ = $localize \`:@@4891196282781544695:$` +
String.raw `{"\uFFFD#2\uFFFD\uFFFD/#2\uFFFD"}:TAG_IMG: is my logo #1 \`;
}
var $I18N_2$;
@ -2298,7 +2298,7 @@ describe('i18n support in the template compiler', () => {
$I18N_2$ = $MSG_EXTERNAL_461986953980355147$$APP_SPEC_TS__2$;
}
else {
$I18N_2$ = $localize \`$` +
$I18N_2$ = $localize \`:@@461986953980355147:$` +
String.raw `{"\uFFFD#1\uFFFD\uFFFD/#1\uFFFD"}:TAG_IMG: is my logo #2 \`;
}
function MyComponent_ng_template_3_Template(rf, ctx) {
@ -2344,7 +2344,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_8537814667662432133$$APP_SPEC_TS__0$;
}
else {
$I18N_0$ = $localize \` Root content $` +
$I18N_0$ = $localize \`:@@8537814667662432133: Root content $` +
String.raw
`{"\uFFFD*1:1\uFFFD\uFFFD#1:1\uFFFD"}:START_TAG_NG_CONTAINER: Nested content $` +
String.raw `{"\uFFFD/#1:1\uFFFD\uFFFD/*1:1\uFFFD"}:CLOSE_TAG_NG_CONTAINER:\`;
@ -2371,7 +2371,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_6563391987554512024$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`Test\`;
$I18N_0$ = $localize \`:@@6563391987554512024:Test\`;
}
var $I18N_1$;
if (ngI18nClosureMode) {
@ -2379,7 +2379,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_6563391987554512024$$APP_SPEC_TS_1$;
}
else {
$I18N_1$ = $localize \`Test\`;
$I18N_1$ = $localize \`:@@6563391987554512024:Test\`;
}
`;
@ -2401,7 +2401,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_APP_SPEC_TS_1$;
}
else {
$I18N_0$ = $localize \` Hello $` +
$I18N_0$ = $localize \`:@@161173306924314453: Hello $` +
String.raw `{"\uFFFD#2\uFFFD"}:START_TAG_NG_CONTAINER:there$` +
String.raw `{"\uFFFD/#2\uFFFD"}:CLOSE_TAG_NG_CONTAINER:\`;
}
@ -2437,7 +2437,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_APP_SPEC_TS_1$;
}
else {
$I18N_0$ = $localize \` Hello $` +
$I18N_0$ = $localize \`:@@1968828034476446869: Hello $` +
String.raw `{"\uFFFD#2\uFFFD"}:START_TAG_NG_CONTAINER:there $` +
String.raw `{"\uFFFD#3\uFFFD"}:START_TAG_STRONG:!$` +
String.raw `{"\uFFFD/#3\uFFFD"}:CLOSE_TAG_STRONG:$` +
@ -2477,7 +2477,7 @@ describe('i18n support in the template compiler', () => {
const $MSG_EXTERNAL_3308216566145348998$$APP_SPEC_TS___2$ = goog.getMsg("Content A");
$I18N_1$ = $MSG_EXTERNAL_3308216566145348998$$APP_SPEC_TS___2$;
} else {
$I18N_1$ = $localize \`Content A\`;
$I18N_1$ = $localize \`:@@3308216566145348998:Content A\`;
}
function MyComponent_0_ng_template_0_Template(rf, ctx) {
if (rf & 1) {
@ -2494,7 +2494,7 @@ describe('i18n support in the template compiler', () => {
const $MSG_EXTERNAL_8349021389088127654$$APP_SPEC_TS__4$ = goog.getMsg("Content B");
$I18N_3$ = $MSG_EXTERNAL_8349021389088127654$$APP_SPEC_TS__4$;
} else {
$I18N_3$ = $localize \`Content B\`;
$I18N_3$ = $localize \`:@@8349021389088127654:Content B\`;
}
function MyComponent_ng_container_1_Template(rf, ctx) {
if (rf & 1) {
@ -2541,7 +2541,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_963542717423364282$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`\n Some text\n $` +
$I18N_0$ = $localize \`:@@963542717423364282:\n Some text\n $` +
String.raw `{"\uFFFD#3\uFFFD"}:START_TAG_SPAN:Text inside span$` +
String.raw `{"\uFFFD/#3\uFFFD"}:CLOSE_TAG_SPAN:\n \`;
}
@ -2576,7 +2576,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`{VAR_SELECT, select, male {male} female {female} other {other}}\`;
$I18N_0$ = $localize \`:@@7842238767399919809:{VAR_SELECT, select, male {male} female {female} other {other}}\`;
}
$I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
"VAR_SELECT": "\uFFFD0\uFFFD"
@ -2612,7 +2612,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_4166854826696768832$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`{VAR_SELECT, select, single {'single quotes'} double {"double quotes"} other {other}}\`;
$I18N_0$ = $localize \`:@@4166854826696768832:{VAR_SELECT, select, single {'single quotes'} double {"double quotes"} other {other}}\`;
}
$I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
"VAR_SELECT": "\uFFFD0\uFFFD"
@ -2634,7 +2634,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}\`;
$I18N_0$ = $localize \`:@@8806993169187953163:{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}\`;
}
$I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
"VAR_SELECT": "\uFFFD0\uFFFD"
@ -2674,7 +2674,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`{VAR_SELECT, select, male {male} female {female} other {other}}\`;
$I18N_0$ = $localize \`:@@7842238767399919809:{VAR_SELECT, select, male {male} female {female} other {other}}\`;
}
$I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
"VAR_SELECT": "\uFFFD0\uFFFD"
@ -2688,7 +2688,7 @@ describe('i18n support in the template compiler', () => {
$I18N_3$ = $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS__3$;
}
else {
$I18N_3$ = $localize \`{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}\`;
$I18N_3$ = $localize \`:@@8806993169187953163:{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}\`;
}
$I18N_3$ = $r3$.ɵɵi18nPostprocess($I18N_3$, {
"VAR_SELECT": "\uFFFD0\uFFFD"
@ -2714,7 +2714,7 @@ describe('i18n support in the template compiler', () => {
$I18N_5$ = $MSG_EXTERNAL_1922743304863699161$$APP_SPEC_TS__5$;
}
else {
$I18N_5$ = $localize \`{VAR_SELECT, select, 0 {no emails} 1 {one email} other {{INTERPOLATION} emails}}\`;
$I18N_5$ = $localize \`:@@1922743304863699161:{VAR_SELECT, select, 0 {no emails} 1 {one email} other {{INTERPOLATION} emails}}\`;
}
$I18N_5$ = $r3$.ɵɵi18nPostprocess($I18N_5$, {
"VAR_SELECT": "\uFFFD0\uFFFD",
@ -2771,7 +2771,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_2949673783721159566$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`{VAR_SELECT, select, 10 {ten} 20 {twenty} other {{INTERPOLATION}}}\`;
$I18N_0$ = $localize \`:@@2949673783721159566:{VAR_SELECT, select, 10 {ten} 20 {twenty} other {{INTERPOLATION}}}\`;
}
$I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
"VAR_SELECT": "\uFFFD0\uFFFD",
@ -2810,7 +2810,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_2417296354340576868$$APP_SPEC_TS_1$;
}
else {
$I18N_1$ = $localize \`{VAR_SELECT, select, male {male - {START_BOLD_TEXT}male{CLOSE_BOLD_TEXT}} female {female {START_BOLD_TEXT}female{CLOSE_BOLD_TEXT}} other {{START_TAG_DIV}{START_ITALIC_TEXT}other{CLOSE_ITALIC_TEXT}{CLOSE_TAG_DIV}}}\`;
$I18N_1$ = $localize \`:@@2417296354340576868:{VAR_SELECT, select, male {male - {START_BOLD_TEXT}male{CLOSE_BOLD_TEXT}} female {female {START_BOLD_TEXT}female{CLOSE_BOLD_TEXT}} other {{START_TAG_DIV}{START_ITALIC_TEXT}other{CLOSE_ITALIC_TEXT}{CLOSE_TAG_DIV}}}\`;
}
$I18N_1$ = $r3$.ɵɵi18nPostprocess($I18N_1$, {
"VAR_SELECT": "\uFFFD0\uFFFD",
@ -2836,7 +2836,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_5791551881115084301$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \` $` +
$I18N_0$ = $localize \`:@@5791551881115084301: $` +
String.raw `{$I18N_1$}:ICU: $` +
String.raw `{"\uFFFD#2\uFFFD"}:START_BOLD_TEXT:Other content$` +
String.raw `{"\uFFFD/#2\uFFFD"}:CLOSE_BOLD_TEXT:$` +
@ -2881,7 +2881,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_6879461626778511059$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`{VAR_SELECT, select, male {male of age: {INTERPOLATION}} female {female} other {other}}\`;
$I18N_0$ = $localize \`:@@6879461626778511059:{VAR_SELECT, select, male {male of age: {INTERPOLATION}} female {female} other {other}}\`;
}
$I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
"VAR_SELECT": "\uFFFD0\uFFFD",
@ -2921,7 +2921,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_1$;
}
else {
$I18N_1$ = $localize \`{VAR_SELECT, select, male {male} female {female} other {other}}\`;
$I18N_1$ = $localize \`:@@7842238767399919809:{VAR_SELECT, select, male {male} female {female} other {other}}\`;
}
$I18N_1$ = $r3$.ɵɵi18nPostprocess($I18N_1$, {
"VAR_SELECT": "\uFFFD0\uFFFD"
@ -2932,7 +2932,7 @@ describe('i18n support in the template compiler', () => {
$I18N_2$ = $MSG_EXTERNAL_7068143081688428291$$APP_SPEC_TS_2$;
}
else {
$I18N_2$ = $localize \`{VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other}}\`;
$I18N_2$ = $localize \`:@@7068143081688428291:{VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other}}\`;
}
$I18N_2$ = $r3$.ɵɵi18nPostprocess($I18N_2$, {
"VAR_SELECT": "\uFFFD1\uFFFD"
@ -2946,7 +2946,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_2967249209167308918$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \` $` +
$I18N_0$ = $localize \`:@@2967249209167308918: $` +
String.raw `{$I18N_1$}:ICU: $` + String.raw `{$I18N_2$}:ICU_1: \`;
}
@ -2988,7 +2988,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_APP_SPEC_TS_1$;
}
else {
$I18N_1$ = $localize \`{VAR_SELECT, select, male {male} female {female} other {other}}\`;
$I18N_1$ = $localize \`:@@7842238767399919809:{VAR_SELECT, select, male {male} female {female} other {other}}\`;
}
$I18N_1$ = $r3$.ɵɵi18nPostprocess($I18N_1$, {
"VAR_SELECT": "\uFFFD0\uFFFD"
@ -2999,7 +2999,7 @@ describe('i18n support in the template compiler', () => {
$I18N_2$ = $MSG_APP_SPEC_TS_2$;
}
else {
$I18N_2$ = $localize \`{VAR_SELECT, select, male {male} female {female} other {other}}\`;
$I18N_2$ = $localize \`:@@7842238767399919809:{VAR_SELECT, select, male {male} female {female} other {other}}\`;
}
$I18N_2$ = $r3$.ɵɵi18nPostprocess($I18N_2$, {
"VAR_SELECT": "\uFFFD1\uFFFD"
@ -3011,7 +3011,7 @@ describe('i18n support in the template compiler', () => {
$I18N_4$ = $MSG_APP_SPEC_TS__4$;
}
else {
$I18N_4$ = $localize \`{VAR_SELECT, select, male {male} female {female} other {other}}\`;
$I18N_4$ = $localize \`:@@7842238767399919809:{VAR_SELECT, select, male {male} female {female} other {other}}\`;
}
$I18N_4$ = $r3$.ɵɵi18nPostprocess($I18N_4$, {
"VAR_SELECT": "\uFFFD0:1\uFFFD"
@ -3027,7 +3027,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \` $` +
$I18N_0$ = $localize \`:@@7986645988117050801: $` +
String.raw `{"\uFFFDI18N_EXP_ICU\uFFFD"}:ICU: $` +
String.raw `{"\uFFFD#2\uFFFD"}:START_TAG_DIV: $` +
String.raw `{"\uFFFDI18N_EXP_ICU\uFFFD"}:ICU: $` + String.raw
@ -3096,7 +3096,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_343563413083115114$$APP_SPEC_TS_0$;
}
else {
$I18N_1$ = $localize \`{VAR_SELECT_1, select, male {male of age: {VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other}}} female {female} other {other}}\`;
$I18N_1$ = $localize \`:@@343563413083115114:{VAR_SELECT_1, select, male {male of age: {VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other}}} female {female} other {other}}\`;
}
$I18N_1$ = $r3$.ɵɵi18nPostprocess($I18N_1$, {
"VAR_SELECT": "\uFFFD0\uFFFD",
@ -3108,7 +3108,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_3052001905251380936$$APP_SPEC_TS_3$;
}
else {
$I18N_0$ = $localize \` $` +
$I18N_0$ = $localize \`:@@3052001905251380936: $` +
String.raw `{$I18N_1$}:ICU: \`;
}
consts: 2,
@ -3151,7 +3151,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_6870293071705078389$$APP_SPEC_TS_1$;
}
else {
$I18N_0$ = $localize \`{VAR_PLURAL, plural, =0 {zero} =2 {{INTERPOLATION} {VAR_SELECT, select, cat {cats} dog {dogs} other {animals}} !} other {other - {INTERPOLATION}}}\`;
$I18N_0$ = $localize \`:@@6870293071705078389:{VAR_PLURAL, plural, =0 {zero} =2 {{INTERPOLATION} {VAR_SELECT, select, cat {cats} dog {dogs} other {animals}} !} other {other - {INTERPOLATION}}}\`;
}
$I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
"VAR_SELECT": "\uFFFD0\uFFFD",
@ -3194,7 +3194,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_1$;
}
else {
$I18N_1$ = $localize \`{VAR_SELECT, select, male {male} female {female} other {other}}\`;
$I18N_1$ = $localize \`:@@7842238767399919809:{VAR_SELECT, select, male {male} female {female} other {other}}\`;
}
$I18N_1$ = $r3$.ɵɵi18nPostprocess($I18N_1$, {
"VAR_SELECT": "\uFFFD0\uFFFD"
@ -3206,7 +3206,7 @@ describe('i18n support in the template compiler', () => {
$I18N_3$ = $MSG_EXTERNAL_7068143081688428291$$APP_SPEC_TS__3$;
}
else {
$I18N_3$ = $localize \`{VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other}}\`;
$I18N_3$ = $localize \`:@@7068143081688428291:{VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other}}\`;
}
$I18N_3$ = $r3$.ɵɵi18nPostprocess($I18N_3$, {
"VAR_SELECT": "\uFFFD0:1\uFFFD"
@ -3222,7 +3222,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_1194472282609532229$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \` $` +
$I18N_0$ = $localize \`:@@1194472282609532229: $` +
String.raw `{$I18N_1$}:ICU: $` +
String.raw `{"\uFFFD*2:1\uFFFD\uFFFD#1:1\uFFFD"}:START_TAG_SPAN: $` +
String.raw `{$I18N_3$}:ICU_1: $` +
@ -3280,7 +3280,7 @@ describe('i18n support in the template compiler', () => {
$I18N_1$ = $MSG_EXTERNAL_7825031864601787094$$APP_SPEC_TS_1$;
}
else {
$I18N_1$ = $localize \`{VAR_SELECT, select, male {male {INTERPOLATION}} female {female {INTERPOLATION_1}} other {other}}\`;
$I18N_1$ = $localize \`:@@7825031864601787094:{VAR_SELECT, select, male {male {INTERPOLATION}} female {female {INTERPOLATION_1}} other {other}}\`;
}
$I18N_1$ = $r3$.ɵɵi18nPostprocess($I18N_1$, {
"VAR_SELECT": "\uFFFD0\uFFFD",
@ -3294,7 +3294,7 @@ describe('i18n support in the template compiler', () => {
$I18N_4$ = $MSG_EXTERNAL_2310343208266678305$$APP_SPEC_TS__3$;
}
else {
$I18N_4$ = $localize \`{VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other: {INTERPOLATION}}}\`;
$I18N_4$ = $localize \`:@@2310343208266678305:{VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other: {INTERPOLATION}}}\`;
}
$I18N_4$ = $r3$.ɵɵi18nPostprocess($I18N_4$, {
"VAR_SELECT": "\uFFFD0:1\uFFFD",
@ -3311,7 +3311,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_7186042105600518133$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \` $` +
$I18N_0$ = $localize \`:@@7186042105600518133: $` +
String.raw `{I18N_1}:ICU: $` +
String.raw `{"\uFFFD*2:1\uFFFD\uFFFD#1:1\uFFFD"}:START_TAG_SPAN: $` +
String.raw `{I18N_4}:ICU_1: $` +
@ -3370,7 +3370,7 @@ describe('i18n support in the template compiler', () => {
$I18N_0$ = $MSG_EXTERNAL_6318060397235942326$$APP_SPEC_TS_0$;
}
else {
$I18N_0$ = $localize \`{VAR_SELECT, select, male {male {PH_A}} female {female {PH_B}} other {other {PH_WITH_SPACES}}}\`;
$I18N_0$ = $localize \`:@@6318060397235942326:{VAR_SELECT, select, male {male {PH_A}} female {female {PH_B}} other {other {PH_WITH_SPACES}}}\`;
}
$I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
"VAR_SELECT": "\uFFFD0\uFFFD",

View File

@ -9,6 +9,7 @@ import * as i18n from '../../../i18n/i18n_ast';
import * as o from '../../../output/output_ast';
import {serializeIcuNode} from './icu_serializer';
import {metaFromI18nMessage, serializeI18nMeta} from './meta';
import {formatI18nPlaceholderName} from './util';
export function createLocalizeStatements(
@ -16,15 +17,13 @@ export function createLocalizeStatements(
params: {[name: string]: o.Expression}): o.Statement[] {
const statements = [];
// TODO: re-enable these comments when we have a plan on how to make them work so that Closure
// compiler doesn't complain about the JSDOC comments.
// const jsdocComment = i18nMetaToDocStmt(metaFromI18nMessage(message));
// if (jsdocComment !== null) {
// statements.push(jsdocComment);
// }
const metaBlock = serializeI18nMeta(metaFromI18nMessage(message));
const {messageParts, placeHolders} = serializeI18nMessageForLocalize(message);
// Update first message part with metadata
messageParts[0] = `:${metaBlock}:${messageParts[0]}`;
statements.push(new o.ExpressionStatement(variable.set(
o.localizedString(messageParts, placeHolders, placeHolders.map(ph => params[ph])))));
@ -132,4 +131,4 @@ function processMessagePieces(pieces: MessagePiece[]):
messageParts.push('');
}
return {messageParts, placeHolders};
}
}

View File

@ -178,6 +178,23 @@ export function parseI18nMeta(meta?: string): I18nMeta {
return {id, meaning, description};
}
/**
* Serialize the given `meta` into a string that can be used in a `$localize` tagged string metadata
* block. The format is the same as that parsed by `parseI18nMeta()`.
*
* @param meta The metadata to serialize
*/
export function serializeI18nMeta(meta: I18nMeta): string {
let metaBlock = meta.description || '';
if (meta.meaning) {
metaBlock = `${meta.meaning}|${metaBlock}`;
}
if (meta.id) {
metaBlock = `${metaBlock}@@${meta.id}`;
}
return metaBlock;
}
// Converts i18n meta information for a message (id, description, meaning)
// to a JsDoc statement formatted as expected by the Closure compiler.
export function i18nMetaToDocStmt(meta: I18nMeta): o.JSDocCommentStmt|null {

View File

@ -5,8 +5,6 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {I18nMeta, parseI18nMeta} from '@angular/compiler/src/render3/view/i18n/meta';
import {AST} from '../../../src/expression_parser/ast';
import {Lexer} from '../../../src/expression_parser/lexer';
import {Parser} from '../../../src/expression_parser/parser';
@ -17,6 +15,7 @@ import {I18nContext} from '../../../src/render3/view/i18n/context';
import {serializeI18nMessageForGetMsg} from '../../../src/render3/view/i18n/get_msg_utils';
import {serializeIcuNode} from '../../../src/render3/view/i18n/icu_serializer';
import {serializeI18nMessageForLocalize} from '../../../src/render3/view/i18n/localize_utils';
import {I18nMeta, parseI18nMeta, serializeI18nMeta} from '../../../src/render3/view/i18n/meta';
import {formatI18nPlaceholderName} from '../../../src/render3/view/i18n/util';
import {parseR3 as parse} from './util';
@ -200,10 +199,8 @@ describe('Utils', () => {
([input, output]) => { expect(formatI18nPlaceholderName(input)).toEqual(output); });
});
it('parseI18nMeta', () => {
const meta = (id?: string, meaning?: string, description?: string) =>
({id, meaning, description});
const cases = [
describe('metadata serialization', () => {
const metadataCases: [string, I18nMeta][] = [
['', meta()],
['desc', meta('', '', 'desc')],
['desc@@id', meta('id', '', 'desc')],
@ -211,9 +208,20 @@ describe('Utils', () => {
['meaning|desc@@id', meta('id', 'meaning', 'desc')],
['@@id', meta('id', '', '')],
];
cases.forEach(([input, output]) => {
expect(parseI18nMeta(input as string)).toEqual(output as I18nMeta, input);
it('parseI18nMeta()', () => {
metadataCases.forEach(
([input, output]) => { expect(parseI18nMeta(input)).toEqual(output, input); });
});
it('serializeI18nMeta()', () => {
metadataCases.forEach(
([output, input]) => { expect(serializeI18nMeta(input)).toEqual(output, input); });
});
function meta(id?: string, meaning?: string, description?: string): I18nMeta {
return {id, meaning, description};
}
});
});

File diff suppressed because it is too large Load Diff

View File

@ -19,11 +19,9 @@ import {ivyEnabled, onlyInIvy} from '@angular/private/testing';
describe('ViewContainerRef', () => {
const TRANSLATIONS: any = {
'Bar': 'o',
'{$START_TAG_BEFORE}{$CLOSE_TAG_BEFORE}{$START_TAG_DIV}{$START_TAG_INSIDE}{$CLOSE_TAG_INSIDE}{$CLOSE_TAG_DIV}{$START_TAG_AFTER}{$CLOSE_TAG_AFTER}':
'F{$START_TAG_DIV}{$CLOSE_TAG_DIV}o',
'{$START_TAG_BEFORE}{$CLOSE_TAG_BEFORE}{$START_TAG_DIV}{$START_TAG_IN}{$CLOSE_TAG_IN}{$CLOSE_TAG_DIV}{$START_TAG_AFTER}{$CLOSE_TAG_AFTER}':
'{$START_TAG_DIV}{$CLOSE_TAG_DIV}{$START_TAG_BEFORE}{$CLOSE_TAG_BEFORE}'
'6587679027921703718': 'o',
'1059980791999999199': 'F{$START_TAG_DIV}{$CLOSE_TAG_DIV}o',
'8808498902423973223': '{$START_TAG_DIV}{$CLOSE_TAG_DIV}{$START_TAG_BEFORE}{$CLOSE_TAG_BEFORE}'
};
/**

View File

@ -11,8 +11,8 @@ import '@angular/localize/init';
import {loadTranslations} from '@angular/localize';
const translations = {
'Hello World!': 'Bonjour Monde!',
'Hello Title!': 'Bonjour Titre!',
'6947830843539421219': 'Bonjour Monde!',
'6935800796474951272': 'Bonjour Titre!',
};
loadTranslations(translations);

View File

@ -11,19 +11,27 @@ import '@angular/localize/init';
import {loadTranslations} from '@angular/localize';
export const translations = {
'What needs to be done?': `Qu'y a-t-il à faire ?`,
'{$START_HEADING_LEVEL1}todos{$CLOSE_HEADING_LEVEL1}{$TAG_INPUT}':
// What needs to be done?
'5102526651904871634': `Qu'y a-t-il à faire ?`,
// {$START_HEADING_LEVEL1}todos{$CLOSE_HEADING_LEVEL1}{$TAG_INPUT}
'8643091609122689720':
'{$START_HEADING_LEVEL1}liste de tâches{$CLOSE_HEADING_LEVEL1}{$TAG_INPUT}',
'{VAR_PLURAL, plural, =1 {item left} other {items left}}':
'{VAR_PLURAL, plural, =1 {tâche restante} other {tâches restantes}}',
'{$START_TAG_STRONG}{$INTERPOLATION}{$CLOSE_TAG_STRONG}{$ICU}':
'{$START_TAG_STRONG}{$INTERPOLATION}{$CLOSE_TAG_STRONG} {$ICU}',
' Clear completed ': ' Effacer terminés ',
'Demonstrate Components': 'Démontrer les components',
'Demonstrate Structural Directives': 'Démontrer les directives structurelles',
'Demonstrate {$value}': 'Démontrer {$value}',
'Demonstrate zoneless change detection': 'Démontrer la détection des changements sans zonejs',
'Demonstrate internationalization': `Démontrer l'internationalisation`
// {VAR_PLURAL, plural, =1 {item left} other {items left}}
'271375439086996113': '{VAR_PLURAL, plural, =1 {tâche restante} other {tâches restantes}}',
// {$START_TAG_STRONG}{$INTERPOLATION}{$CLOSE_TAG_STRONG}{$ICU}
'4169337202119891309': '{$START_TAG_STRONG}{$INTERPOLATION}{$CLOSE_TAG_STRONG} {$ICU}',
// Clear Completed
'3329962774478249377': ' Effacer terminés ',
// Demonstrate Components
'5738403869589701812': ' Démontrer les components',
// Demonstrate Structural Directives
'4405796757024158842': 'Démontrer les directives structurelles',
// Demonstrate {$value}
'2762077329405284613': 'Démontrer {$value}',
// Demonstrate zoneless change detection
'3484387157632222646': 'Démontrer la détection des changements sans zonejs',
// Demonstrate internationalization
'442837859415373816': `Démontrer l'internationalisation`
};
loadTranslations(translations);