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:
parent
357aa4a097
commit
b741a1c3e7
|
@ -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",
|
||||
|
|
|
@ -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])))));
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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};
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -19,24 +19,21 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
|
|||
import {onlyInIvy} from '@angular/private/testing';
|
||||
|
||||
|
||||
onlyInIvy('Ivy i18n logic')
|
||||
.describe(
|
||||
'runtime i18n', () => {
|
||||
onlyInIvy('Ivy i18n logic').describe('runtime i18n', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [AppComp, DirectiveWithTplRef, UppercasePipe]});
|
||||
TestBed.configureTestingModule({declarations: [AppComp, DirectiveWithTplRef, UppercasePipe]});
|
||||
});
|
||||
|
||||
afterEach(() => { setDelayProjection(false); });
|
||||
|
||||
it('should translate text', () => {
|
||||
loadTranslations({'text': 'texte'});
|
||||
loadTranslations({'3667842621564887364': 'texte'});
|
||||
const fixture = initWithTemplate(AppComp, `<div i18n>text</div>`);
|
||||
expect(fixture.nativeElement.innerHTML).toEqual(`<div>texte</div>`);
|
||||
});
|
||||
|
||||
it('should support interpolations', () => {
|
||||
loadTranslations({'Hello {$INTERPOLATION}!': 'Bonjour {$INTERPOLATION}!'});
|
||||
loadTranslations({'4848371593517801531': 'Bonjour {$INTERPOLATION}!'});
|
||||
const fixture = initWithTemplate(AppComp, `<div i18n>Hello {{name}}!</div>`);
|
||||
expect(fixture.nativeElement.innerHTML).toEqual(`<div>Bonjour Angular!</div>`);
|
||||
fixture.componentRef.instance.name = `John`;
|
||||
|
@ -45,18 +42,15 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('should support named interpolations', () => {
|
||||
loadTranslations({
|
||||
' Hello {$USER_NAME}! Emails: {$AMOUNT_OF_EMAILS_RECEIVED} ':
|
||||
' Bonjour {$USER_NAME}! Emails: {$AMOUNT_OF_EMAILS_RECEIVED} '
|
||||
});
|
||||
loadTranslations(
|
||||
{'5429622669757720522': ' Bonjour {$USER_NAME}! Emails: {$AMOUNT_OF_EMAILS_RECEIVED} '});
|
||||
const fixture = initWithTemplate(AppComp, `
|
||||
<div i18n>
|
||||
Hello {{ name // i18n(ph="user_name") }}!
|
||||
Emails: {{ count // i18n(ph="amount of emails received") }}
|
||||
</div>
|
||||
`);
|
||||
expect(fixture.nativeElement.innerHTML)
|
||||
.toEqual(`<div> Bonjour Angular! Emails: 0 </div>`);
|
||||
expect(fixture.nativeElement.innerHTML).toEqual(`<div> Bonjour Angular! Emails: 0 </div>`);
|
||||
fixture.componentRef.instance.name = `John`;
|
||||
fixture.componentRef.instance.count = 5;
|
||||
fixture.detectChanges();
|
||||
|
@ -64,7 +58,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('should support interpolations with custom interpolation config', () => {
|
||||
loadTranslations({'Hello {$INTERPOLATION}': 'Bonjour {$INTERPOLATION}'});
|
||||
loadTranslations({'3771704108176831903': 'Bonjour {$INTERPOLATION}'});
|
||||
const interpolation = ['{%', '%}'] as[string, string];
|
||||
TestBed.overrideComponent(AppComp, {set: {interpolation}});
|
||||
const fixture = initWithTemplate(AppComp, `<div i18n>Hello {% name %}</div>`);
|
||||
|
@ -74,17 +68,15 @@ onlyInIvy('Ivy i18n logic')
|
|||
|
||||
it('should support &ngsp; in translatable sections', () => {
|
||||
// note: the `` unicode symbol represents the `&ngsp;` in translations
|
||||
loadTranslations({'text ||': 'texte ||'});
|
||||
const fixture =
|
||||
initWithTemplate(AppCompWithWhitespaces, `<div i18n>text |&ngsp;|</div>`);
|
||||
loadTranslations({'2564699219547368060': 'texte ||'});
|
||||
const fixture = initWithTemplate(AppCompWithWhitespaces, `<div i18n>text |&ngsp;|</div>`);
|
||||
|
||||
expect(fixture.nativeElement.innerHTML).toEqual(`<div>texte | |</div>`);
|
||||
});
|
||||
|
||||
it('should support interpolations with complex expressions', () => {
|
||||
loadTranslations({
|
||||
' {$INTERPOLATION} - {$INTERPOLATION_1} - {$INTERPOLATION_2} ':
|
||||
' {$INTERPOLATION} - {$INTERPOLATION_1} - {$INTERPOLATION_2} (fr) '
|
||||
'3552931695168961643': ' {$INTERPOLATION} - {$INTERPOLATION_1} - {$INTERPOLATION_2} (fr) '
|
||||
});
|
||||
const fixture = initWithTemplate(AppComp, `
|
||||
<div i18n>
|
||||
|
@ -93,8 +85,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
{{ obj?.getA()?.b }}
|
||||
</div>
|
||||
`);
|
||||
// the `obj` field is not yet defined, so 2nd and 3rd interpolations return empty
|
||||
// strings
|
||||
// the `obj` field is not yet defined, so 2nd and 3rd interpolations return empty strings
|
||||
expect(fixture.nativeElement.innerHTML).toEqual(`<div> ANGULAR - - (fr) </div>`);
|
||||
|
||||
fixture.componentRef.instance.obj = {
|
||||
|
@ -108,7 +99,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
|
||||
it('should support elements', () => {
|
||||
loadTranslations({
|
||||
'Hello {$START_TAG_SPAN}world{$CLOSE_TAG_SPAN} and {$START_TAG_DIV}universe{$CLOSE_TAG_DIV}!':
|
||||
'4352419997312772902':
|
||||
'Bonjour {$START_TAG_SPAN}monde{$CLOSE_TAG_SPAN} et {$START_TAG_DIV}univers{$CLOSE_TAG_DIV}!'
|
||||
});
|
||||
const fixture = initWithTemplate(
|
||||
|
@ -118,19 +109,16 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('should support removing elements', () => {
|
||||
loadTranslations({
|
||||
'Hello {$START_BOLD_TEXT}my{$CLOSE_BOLD_TEXT}{$START_TAG_SPAN}world{$CLOSE_TAG_SPAN}':
|
||||
'Bonjour {$START_TAG_SPAN}monde{$CLOSE_TAG_SPAN}'
|
||||
});
|
||||
const fixture = initWithTemplate(
|
||||
AppComp, `<div i18n>Hello <b>my</b><span>world</span></div><div>!</div>`);
|
||||
loadTranslations({'4038508921050216955': 'Bonjour {$START_TAG_SPAN}monde{$CLOSE_TAG_SPAN}'});
|
||||
const fixture =
|
||||
initWithTemplate(AppComp, `<div i18n>Hello <b>my</b><span>world</span></div><div>!</div>`);
|
||||
expect(fixture.nativeElement.innerHTML)
|
||||
.toEqual(`<div>Bonjour <span>monde</span></div><div>!</div>`);
|
||||
});
|
||||
|
||||
it('should support moving elements', () => {
|
||||
loadTranslations({
|
||||
'Hello {$START_TAG_SPAN}world{$CLOSE_TAG_SPAN} and {$START_TAG_DIV}universe{$CLOSE_TAG_DIV}!':
|
||||
'4352419997312772902':
|
||||
'Bonjour {$START_TAG_DIV}univers{$CLOSE_TAG_DIV} et {$START_TAG_SPAN}monde{$CLOSE_TAG_SPAN}!'
|
||||
});
|
||||
const fixture = initWithTemplate(
|
||||
|
@ -141,7 +129,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
|
||||
it('should support template directives', () => {
|
||||
loadTranslations({
|
||||
'Content: {$START_TAG_DIV}before{$START_TAG_SPAN}middle{$CLOSE_TAG_SPAN}after{$CLOSE_TAG_DIV}!':
|
||||
'3546490957396057142':
|
||||
'Contenu: {$START_TAG_DIV}avant{$START_TAG_SPAN}milieu{$CLOSE_TAG_SPAN}après{$CLOSE_TAG_DIV}!'
|
||||
});
|
||||
const fixture = initWithTemplate(
|
||||
|
@ -161,11 +149,9 @@ onlyInIvy('Ivy i18n logic')
|
|||
|
||||
it('should support multiple i18n blocks', () => {
|
||||
loadTranslations({
|
||||
'trad {$INTERPOLATION}': 'traduction {$INTERPOLATION}',
|
||||
'start {$INTERPOLATION} middle {$INTERPOLATION_1} end':
|
||||
'start {$INTERPOLATION_1} middle {$INTERPOLATION} end',
|
||||
'{$START_TAG_C}trad{$CLOSE_TAG_C}{$START_TAG_D}{$CLOSE_TAG_D}{$START_TAG_E}{$CLOSE_TAG_E}':
|
||||
'{$START_TAG_E}{$CLOSE_TAG_E}{$START_TAG_C}traduction{$CLOSE_TAG_C}'
|
||||
'2954523302699461941': 'traduction {$INTERPOLATION}',
|
||||
'6316306955288477512': 'start {$INTERPOLATION_1} middle {$INTERPOLATION} end',
|
||||
'4435073550869683142': '{$START_TAG_E}{$CLOSE_TAG_E}{$START_TAG_C}traduction{$CLOSE_TAG_C}'
|
||||
});
|
||||
const fixture = initWithTemplate(AppComp, `
|
||||
<div>
|
||||
|
@ -184,9 +170,9 @@ onlyInIvy('Ivy i18n logic')
|
|||
|
||||
it('should support multiple sibling i18n blocks', () => {
|
||||
loadTranslations({
|
||||
'Section 1': 'Section un',
|
||||
'Section 2': 'Section deux',
|
||||
'Section 3': 'Section trois',
|
||||
'1789603390900945185': 'Section un',
|
||||
'3131519605456222658': 'Section deux',
|
||||
'1438862747497772785': 'Section trois',
|
||||
});
|
||||
const fixture = initWithTemplate(AppComp, `
|
||||
<div>
|
||||
|
@ -195,15 +181,14 @@ onlyInIvy('Ivy i18n logic')
|
|||
<div i18n>Section 3</div>
|
||||
</div>`);
|
||||
expect(fixture.nativeElement.innerHTML)
|
||||
.toEqual(
|
||||
`<div><div>Section un</div><div>Section deux</div><div>Section trois</div></div>`);
|
||||
.toEqual(`<div><div>Section un</div><div>Section deux</div><div>Section trois</div></div>`);
|
||||
});
|
||||
|
||||
it('should support multiple sibling i18n blocks inside of a template directive', () => {
|
||||
loadTranslations({
|
||||
'Section 1': 'Section un',
|
||||
'Section 2': 'Section deux',
|
||||
'Section 3': 'Section trois',
|
||||
'1789603390900945185': 'Section un',
|
||||
'3131519605456222658': 'Section deux',
|
||||
'1438862747497772785': 'Section trois',
|
||||
});
|
||||
const fixture = initWithTemplate(AppComp, `
|
||||
<ul *ngFor="let item of [1,2,3]">
|
||||
|
@ -219,10 +204,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('should properly escape quotes in content', () => {
|
||||
loadTranslations({
|
||||
'\'Single quotes\' and "Double quotes"':
|
||||
'\'Guillemets simples\' et "Guillemets doubles"'
|
||||
});
|
||||
loadTranslations({'7582605960852813916': '\'Guillemets simples\' et "Guillemets doubles"'});
|
||||
const fixture =
|
||||
initWithTemplate(AppComp, `<div i18n>'Single quotes' and "Double quotes"</div>`);
|
||||
|
||||
|
@ -231,7 +213,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('should correctly bind to context in nested template', () => {
|
||||
loadTranslations({'Item {$INTERPOLATION}': 'Article {$INTERPOLATION}'});
|
||||
loadTranslations({'4691107123853093118': 'Article {$INTERPOLATION}'});
|
||||
const fixture = initWithTemplate(AppComp, `
|
||||
<div *ngFor='let id of items'>
|
||||
<div i18n>Item {{ id }}</div>
|
||||
|
@ -251,19 +233,16 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('should handle i18n attribute with directives', () => {
|
||||
loadTranslations({'Hello {$INTERPOLATION}': 'Bonjour {$INTERPOLATION}'});
|
||||
const fixture =
|
||||
initWithTemplate(AppComp, `<div *ngIf="visible" i18n>Hello {{ name }}</div>`);
|
||||
loadTranslations({'3771704108176831903': 'Bonjour {$INTERPOLATION}'});
|
||||
const fixture = initWithTemplate(AppComp, `<div *ngIf="visible" i18n>Hello {{ name }}</div>`);
|
||||
expect(fixture.nativeElement.firstChild).toHaveText('Bonjour Angular');
|
||||
});
|
||||
|
||||
it('should work correctly with event listeners', () => {
|
||||
loadTranslations({'Hello {$INTERPOLATION}': 'Bonjour {$INTERPOLATION}'});
|
||||
|
||||
@Component({
|
||||
selector: 'app-comp',
|
||||
template: `<div i18n (click)="onClick()">Hello {{ name }}</div>`
|
||||
})
|
||||
@Component(
|
||||
{selector: 'app-comp', template: `<div i18n (click)="onClick()">Hello {{ name }}</div>`})
|
||||
class ListenerComp {
|
||||
name = `Angular`;
|
||||
clicks = 0;
|
||||
|
@ -287,15 +266,15 @@ onlyInIvy('Ivy i18n logic')
|
|||
|
||||
describe('ng-container and ng-template support', () => {
|
||||
it('should support ng-container', () => {
|
||||
loadTranslations({'text': 'texte'});
|
||||
loadTranslations({'3667842621564887364': 'texte'});
|
||||
const fixture = initWithTemplate(AppComp, `<ng-container i18n>text</ng-container>`);
|
||||
expect(fixture.nativeElement.innerHTML).toEqual(`texte<!--ng-container-->`);
|
||||
});
|
||||
|
||||
it('should handle single translation message within ng-template', () => {
|
||||
loadTranslations({'Hello {$INTERPOLATION}': 'Bonjour {$INTERPOLATION}'});
|
||||
const fixture = initWithTemplate(
|
||||
AppComp, `<ng-template i18n tplRef>Hello {{ name }}</ng-template>`);
|
||||
loadTranslations({'3771704108176831903': 'Bonjour {$INTERPOLATION}'});
|
||||
const fixture =
|
||||
initWithTemplate(AppComp, `<ng-template i18n tplRef>Hello {{ name }}</ng-template>`);
|
||||
|
||||
const element = fixture.nativeElement;
|
||||
expect(element).toHaveText('Bonjour Angular');
|
||||
|
@ -304,7 +283,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
// Note: applying structural directives to <ng-template> is typically user error, but it
|
||||
// is technically allowed, so we need to support it.
|
||||
it('should handle structural directives on ng-template', () => {
|
||||
loadTranslations({'Hello {$INTERPOLATION}': 'Bonjour {$INTERPOLATION}'});
|
||||
loadTranslations({'3771704108176831903': 'Bonjour {$INTERPOLATION}'});
|
||||
const fixture = initWithTemplate(
|
||||
AppComp, `<ng-template *ngIf="name" i18n tplRef>Hello {{ name }}</ng-template>`);
|
||||
|
||||
|
@ -314,8 +293,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
|
||||
it('should be able to act as child elements inside i18n block (plain text content)', () => {
|
||||
loadTranslations({
|
||||
|
||||
'{$START_TAG_NG_TEMPLATE} Hello {$CLOSE_TAG_NG_TEMPLATE}{$START_TAG_NG_CONTAINER} Bye {$CLOSE_TAG_NG_CONTAINER}':
|
||||
'3250373733165819471':
|
||||
'{$START_TAG_NG_TEMPLATE} Bonjour {$CLOSE_TAG_NG_TEMPLATE}{$START_TAG_NG_CONTAINER} Au revoir {$CLOSE_TAG_NG_CONTAINER}'
|
||||
});
|
||||
const fixture = initWithTemplate(AppComp, `
|
||||
|
@ -335,8 +313,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
|
||||
it('should be able to act as child elements inside i18n block (text + tags)', () => {
|
||||
loadTranslations({
|
||||
|
||||
'{$START_TAG_NG_TEMPLATE}{$START_TAG_SPAN}Hello{$CLOSE_TAG_SPAN}{$CLOSE_TAG_NG_TEMPLATE}{$START_TAG_NG_CONTAINER}{$START_TAG_SPAN}Hello{$CLOSE_TAG_SPAN}{$CLOSE_TAG_NG_CONTAINER}':
|
||||
'7109932217076518742':
|
||||
'{$START_TAG_NG_TEMPLATE}{$START_TAG_SPAN}Bonjour{$CLOSE_TAG_SPAN}{$CLOSE_TAG_NG_TEMPLATE}{$START_TAG_NG_CONTAINER}{$START_TAG_SPAN}Bonjour{$CLOSE_TAG_SPAN}{$CLOSE_TAG_NG_CONTAINER}'
|
||||
});
|
||||
const fixture = initWithTemplate(AppComp, `
|
||||
|
@ -358,15 +335,8 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('should be able to act as child elements inside i18n block (text + pipes)', () => {
|
||||
// Note: for some reason keeping this key inline causes clang to reformat the entire
|
||||
// file
|
||||
// in a very weird way. Keeping it separated like this seems to make it happy.
|
||||
const key = '{$START_TAG_NG_TEMPLATE}Hello {$INTERPOLATION}{$CLOSE_TAG_NG_TEMPLATE}' +
|
||||
'{$START_TAG_NG_CONTAINER}Bye {$INTERPOLATION}{$CLOSE_TAG_NG_CONTAINER}';
|
||||
|
||||
loadTranslations({
|
||||
|
||||
[key]:
|
||||
'2351903444091919458':
|
||||
'{$START_TAG_NG_TEMPLATE}Hej {$INTERPOLATION}{$CLOSE_TAG_NG_TEMPLATE}{$START_TAG_NG_CONTAINER}Vi ses {$INTERPOLATION}{$CLOSE_TAG_NG_CONTAINER}'
|
||||
});
|
||||
const fixture = initWithTemplate(AppComp, `
|
||||
|
@ -377,14 +347,12 @@ onlyInIvy('Ivy i18n logic')
|
|||
`);
|
||||
|
||||
const element = fixture.nativeElement.firstChild;
|
||||
expect(element.textContent.replace(/\s+/g, ' ').trim())
|
||||
.toBe('Hej ANGULARVi ses ANGULAR');
|
||||
expect(element.textContent.replace(/\s+/g, ' ').trim()).toBe('Hej ANGULARVi ses ANGULAR');
|
||||
});
|
||||
|
||||
it('should be able to handle deep nested levels with templates', () => {
|
||||
loadTranslations({
|
||||
|
||||
'{$START_TAG_SPAN} Hello - 1 {$CLOSE_TAG_SPAN}{$START_TAG_SPAN_1} Hello - 2 {$START_TAG_SPAN_1} Hello - 3 {$START_TAG_SPAN_1} Hello - 4 {$CLOSE_TAG_SPAN}{$CLOSE_TAG_SPAN}{$CLOSE_TAG_SPAN}{$START_TAG_SPAN} Hello - 5 {$CLOSE_TAG_SPAN}':
|
||||
'3582176345457676':
|
||||
'{$START_TAG_SPAN} Bonjour - 1 {$CLOSE_TAG_SPAN}{$START_TAG_SPAN_1} Bonjour - 2 {$START_TAG_SPAN_1} Bonjour - 3 {$START_TAG_SPAN_1} Bonjour - 4 {$CLOSE_TAG_SPAN}{$CLOSE_TAG_SPAN}{$CLOSE_TAG_SPAN}{$START_TAG_SPAN} Bonjour - 5 {$CLOSE_TAG_SPAN}'
|
||||
});
|
||||
const fixture = initWithTemplate(AppComp, `
|
||||
|
@ -415,11 +383,8 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('should handle self-closing tags as content', () => {
|
||||
loadTranslations({
|
||||
|
||||
'{$START_TAG_SPAN}My logo{$TAG_IMG}{$CLOSE_TAG_SPAN}':
|
||||
'{$START_TAG_SPAN}Mon logo{$TAG_IMG}{$CLOSE_TAG_SPAN}'
|
||||
});
|
||||
loadTranslations(
|
||||
{'3294715134260231285': '{$START_TAG_SPAN}Mon logo{$TAG_IMG}{$CLOSE_TAG_SPAN}'});
|
||||
const content = `My logo<img src="logo.png" title="Logo">`;
|
||||
const fixture = initWithTemplate(AppComp, `
|
||||
<ng-container i18n>
|
||||
|
@ -438,8 +403,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
}
|
||||
});
|
||||
|
||||
it('should correctly find context for an element inside i18n section in <ng-template>',
|
||||
() => {
|
||||
it('should correctly find context for an element inside i18n section in <ng-template>', () => {
|
||||
@Directive({selector: '[myDir]'})
|
||||
class Dir {
|
||||
condition = true;
|
||||
|
@ -474,11 +438,8 @@ onlyInIvy('Ivy i18n logic')
|
|||
|
||||
describe('should support ICU expressions', () => {
|
||||
it('with no root node', () => {
|
||||
loadTranslations({
|
||||
|
||||
'{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}':
|
||||
'{VAR_SELECT, select, 10 {dix} 20 {vingt} other {autre}}'
|
||||
});
|
||||
loadTranslations(
|
||||
{'8806993169187953163': '{VAR_SELECT, select, 10 {dix} 20 {vingt} other {autre}}'});
|
||||
const fixture =
|
||||
initWithTemplate(AppComp, `{count, select, 10 {ten} 20 {twenty} other {other}}`);
|
||||
|
||||
|
@ -487,11 +448,8 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('with no i18n tag', () => {
|
||||
loadTranslations({
|
||||
|
||||
'{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}':
|
||||
'{VAR_SELECT, select, 10 {dix} 20 {vingt} other {autre}}'
|
||||
});
|
||||
loadTranslations(
|
||||
{'8806993169187953163': '{VAR_SELECT, select, 10 {dix} 20 {vingt} other {autre}}'});
|
||||
const fixture = initWithTemplate(
|
||||
AppComp, `<div>{count, select, 10 {ten} 20 {twenty} other {other}}</div>`);
|
||||
|
||||
|
@ -501,11 +459,9 @@ onlyInIvy('Ivy i18n logic')
|
|||
|
||||
it('multiple', () => {
|
||||
loadTranslations({
|
||||
|
||||
'{VAR_PLURAL, plural, =0 {no {START_BOLD_TEXT}emails{CLOSE_BOLD_TEXT}!} =1 {one {START_ITALIC_TEXT}email{CLOSE_ITALIC_TEXT}} other {{INTERPOLATION} {START_TAG_SPAN}emails{CLOSE_TAG_SPAN}}}':
|
||||
'3639715378617754400':
|
||||
'{VAR_PLURAL, plural, =0 {aucun {START_BOLD_TEXT}email{CLOSE_BOLD_TEXT}!} =1 {un {START_ITALIC_TEXT}email{CLOSE_ITALIC_TEXT}} other {{INTERPOLATION} {START_TAG_SPAN}emails{CLOSE_TAG_SPAN}}}',
|
||||
'{VAR_SELECT, select, other {(name)}}':
|
||||
'{VAR_SELECT, select, other {({$INTERPOLATION})}}'
|
||||
'484647350062685600': '{VAR_SELECT, select, other {({INTERPOLATION})}}'
|
||||
});
|
||||
const fixture = initWithTemplate(AppComp, `<div i18n>{count, plural,
|
||||
=0 {no <b>emails</b>!}
|
||||
|
@ -531,26 +487,21 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('with custom interpolation config', () => {
|
||||
loadTranslations({
|
||||
|
||||
'{VAR_SELECT, select, 10 {ten} other {{$INTERPOLATION}}}':
|
||||
'{VAR_SELECT, select, 10 {dix} other {{$INTERPOLATION}}}'
|
||||
});
|
||||
loadTranslations(
|
||||
{'8091236997374391053': '{VAR_SELECT, select, 10 {dix} other {{INTERPOLATION}}}'});
|
||||
const interpolation = ['{%', '%}'] as[string, string];
|
||||
TestBed.overrideComponent(AppComp, {set: {interpolation}});
|
||||
const fixture = initWithTemplate(
|
||||
AppComp, `<div i18n>{count, select, 10 {ten} other {{% name %}}}</div>`);
|
||||
const fixture =
|
||||
initWithTemplate(AppComp, `<div i18n>{count, select, 10 {ten} other {{% name %}}}</div>`);
|
||||
|
||||
expect(fixture.nativeElement).toHaveText(`Angular`);
|
||||
});
|
||||
|
||||
it('inside HTML elements', () => {
|
||||
loadTranslations({
|
||||
|
||||
'{VAR_PLURAL, plural, =0 {no {START_BOLD_TEXT}emails{CLOSE_BOLD_TEXT}!} =1 {one {START_ITALIC_TEXT}email{CLOSE_ITALIC_TEXT}} other {{INTERPOLATION} {START_TAG_SPAN}emails{CLOSE_TAG_SPAN}}}':
|
||||
'3639715378617754400':
|
||||
'{VAR_PLURAL, plural, =0 {aucun {START_BOLD_TEXT}email{CLOSE_BOLD_TEXT}!} =1 {un {START_ITALIC_TEXT}email{CLOSE_ITALIC_TEXT}} other {{INTERPOLATION} {START_TAG_SPAN}emails{CLOSE_TAG_SPAN}}}',
|
||||
'{VAR_SELECT, select, other {(name)}}':
|
||||
'{VAR_SELECT, select, other {({$INTERPOLATION})}}'
|
||||
'484647350062685600': '{VAR_SELECT, select, other {({INTERPOLATION})}}'
|
||||
});
|
||||
const fixture = initWithTemplate(AppComp, `<div i18n><span>{count, plural,
|
||||
=0 {no <b>emails</b>!}
|
||||
|
@ -578,13 +529,8 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('inside template directives', () => {
|
||||
loadTranslations({
|
||||
|
||||
'{VAR_SELECT, select, other {(name)}}':
|
||||
'{VAR_SELECT, select, other {({$INTERPOLATION})}}'
|
||||
});
|
||||
const fixture =
|
||||
initWithTemplate(AppComp, `<div i18n><span *ngIf="visible">{name, select,
|
||||
loadTranslations({'484647350062685600': '{VAR_SELECT, select, other {({INTERPOLATION})}}'});
|
||||
const fixture = initWithTemplate(AppComp, `<div i18n><span *ngIf="visible">{name, select,
|
||||
other {({{name}})}
|
||||
}</span></div>`);
|
||||
expect(fixture.nativeElement.innerHTML)
|
||||
|
@ -600,24 +546,16 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('inside ng-container', () => {
|
||||
loadTranslations({
|
||||
|
||||
'{VAR_SELECT, select, other {(name)}}':
|
||||
'{VAR_SELECT, select, other {({$INTERPOLATION})}}'
|
||||
});
|
||||
loadTranslations({'484647350062685600': '{VAR_SELECT, select, other {({INTERPOLATION})}}'});
|
||||
const fixture = initWithTemplate(AppComp, `<ng-container i18n>{name, select,
|
||||
other {({{name}})}
|
||||
}</ng-container>`);
|
||||
expect(fixture.nativeElement.innerHTML)
|
||||
.toEqual(`(Angular)<!--ICU 4--><!--ng-container-->`);
|
||||
expect(fixture.nativeElement.innerHTML).toEqual(`(Angular)<!--ICU 4--><!--ng-container-->`);
|
||||
});
|
||||
|
||||
it('inside <ng-template>', () => {
|
||||
loadTranslations({
|
||||
|
||||
'{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}':
|
||||
'{VAR_SELECT, select, 10 {dix} 20 {vingt} other {autre}}'
|
||||
});
|
||||
loadTranslations(
|
||||
{'8806993169187953163': '{VAR_SELECT, select, 10 {dix} 20 {vingt} other {autre}}'});
|
||||
const fixture = initWithTemplate(
|
||||
AppComp, `
|
||||
<ng-template i18n tplRef>` +
|
||||
|
@ -631,9 +569,8 @@ onlyInIvy('Ivy i18n logic')
|
|||
|
||||
it('nested', () => {
|
||||
loadTranslations({
|
||||
|
||||
'{VAR_PLURAL, plural, =0 {zero} other {{INTERPOLATION} {VAR_SELECT, select, cat {cats} dog {dogs} other {animals}}!}}':
|
||||
'{VAR_PLURAL, plural, =0 {zero} other {{INTERPOLATION} {VAR_SELECT, select, cat {chats} dog {chients} other {animaux}}!}}'
|
||||
'6934090145627876010':
|
||||
'{VAR_PLURAL, plural, =0 {zero} other {{INTERPOLATION} {VAR_SELECT, select, cat {chats} dog {chiens} other {animaux}}!}}'
|
||||
});
|
||||
const fixture = initWithTemplate(AppComp, `<div i18n>{count, plural,
|
||||
=0 {zero}
|
||||
|
@ -653,13 +590,10 @@ onlyInIvy('Ivy i18n logic')
|
|||
|
||||
it('nested with interpolations in "other" blocks', () => {
|
||||
// Note: for some reason long string causing clang to reformat the entire file.
|
||||
const key =
|
||||
'{VAR_PLURAL, plural, =0 {zero} =2 {{INTERPOLATION} {VAR_SELECT, select, ' +
|
||||
'cat {cats} dog {dogs} other {animals}}!} other {other - {INTERPOLATION}}}';
|
||||
const translation =
|
||||
'{VAR_PLURAL, plural, =0 {zero} =2 {{INTERPOLATION} {VAR_SELECT, select, ' +
|
||||
'cat {chats} dog {chients} other {animaux}}!} other {other - {INTERPOLATION}}}';
|
||||
loadTranslations({[key]: translation});
|
||||
'cat {chats} dog {chiens} other {animaux}}!} other {other - {INTERPOLATION}}}';
|
||||
loadTranslations({'3182623695425530660': translation});
|
||||
|
||||
const fixture = initWithTemplate(AppComp, `<div i18n>{count, plural,
|
||||
=0 {zero}
|
||||
|
@ -685,8 +619,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
it('should return the correct plural form for ICU expressions when using a specific locale',
|
||||
() => {
|
||||
registerLocaleData(localeRo);
|
||||
TestBed.configureTestingModule(
|
||||
{providers: [{provide: LOCALE_ID, useValue: 'ro'}]});
|
||||
TestBed.configureTestingModule({providers: [{provide: LOCALE_ID, useValue: 'ro'}]});
|
||||
// We could also use `TestBed.overrideProvider(LOCALE_ID, {useValue: 'ro'});`
|
||||
const fixture = initWithTemplate(AppComp, `
|
||||
{count, plural,
|
||||
|
@ -751,8 +684,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('with empty values', () => {
|
||||
const fixture =
|
||||
initWithTemplate(AppComp, `{count, select, 10 {} 20 {twenty} other {other}}`);
|
||||
const fixture = initWithTemplate(AppComp, `{count, select, 10 {} 20 {twenty} other {other}}`);
|
||||
|
||||
const element = fixture.nativeElement;
|
||||
expect(element).toHaveText('other');
|
||||
|
@ -836,9 +768,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
dir = this;
|
||||
}
|
||||
|
||||
attachEmbeddedView() {
|
||||
this.viewContainerRef.createEmbeddedView(this.templateRef);
|
||||
}
|
||||
attachEmbeddedView() { this.viewContainerRef.createEmbeddedView(this.templateRef); }
|
||||
}
|
||||
|
||||
@Component({
|
||||
|
@ -995,17 +925,16 @@ onlyInIvy('Ivy i18n logic')
|
|||
|
||||
describe('should support attributes', () => {
|
||||
it('text', () => {
|
||||
loadTranslations({'text': 'texte'});
|
||||
const fixture = initWithTemplate(AppComp, `<div i18n i18n-title title="text"></div>`);
|
||||
loadTranslations({'3667842621564887364': 'texte'});
|
||||
const fixture = initWithTemplate(AppComp, `<div i18n i18n-title title='text'></div>`);
|
||||
expect(fixture.nativeElement.innerHTML).toEqual(`<div title="texte"></div>`);
|
||||
});
|
||||
|
||||
it('interpolations', () => {
|
||||
loadTranslations({'hello {$INTERPOLATION}': 'bonjour {$INTERPOLATION}'});
|
||||
loadTranslations({'1721737630608625819': 'bonjour {$INTERPOLATION}'});
|
||||
const fixture =
|
||||
initWithTemplate(AppComp, `<div i18n i18n-title title="hello {{name}}"></div>`);
|
||||
expect(fixture.nativeElement.innerHTML)
|
||||
.toEqual(`<div title="bonjour Angular"></div>`);
|
||||
expect(fixture.nativeElement.innerHTML).toEqual(`<div title="bonjour Angular"></div>`);
|
||||
|
||||
fixture.componentRef.instance.name = 'John';
|
||||
fixture.detectChanges();
|
||||
|
@ -1013,15 +942,14 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('with pipes', () => {
|
||||
loadTranslations({'hello {$INTERPOLATION}': 'bonjour {$INTERPOLATION}'});
|
||||
loadTranslations({'5990850149002293021': 'bonjour {$INTERPOLATION}'});
|
||||
const fixture = initWithTemplate(
|
||||
AppComp, `<div i18n i18n-title title="hello {{name | uppercase}}"></div>`);
|
||||
expect(fixture.nativeElement.innerHTML)
|
||||
.toEqual(`<div title="bonjour ANGULAR"></div>`);
|
||||
expect(fixture.nativeElement.innerHTML).toEqual(`<div title="bonjour ANGULAR"></div>`);
|
||||
});
|
||||
|
||||
it('multiple attributes', () => {
|
||||
loadTranslations({'hello {$INTERPOLATION}': 'bonjour {$INTERPOLATION}'});
|
||||
loadTranslations({'1721737630608625819': 'bonjour {$INTERPOLATION}'});
|
||||
const fixture = initWithTemplate(
|
||||
AppComp,
|
||||
`<input i18n i18n-title title="hello {{name}}" i18n-placeholder placeholder="hello {{name}}">`);
|
||||
|
@ -1035,26 +963,28 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('on removed elements', () => {
|
||||
loadTranslations(
|
||||
{'text': 'texte', '{$START_TAG_SPAN}content{$CLOSE_TAG_SPAN}': 'contenu'});
|
||||
const fixture = initWithTemplate(
|
||||
AppComp, `<div i18n><span i18n-title title="text">content</span></div>`);
|
||||
loadTranslations({
|
||||
'3667842621564887364': 'texte',
|
||||
'4851941758912026972': 'contenu',
|
||||
});
|
||||
const fixture =
|
||||
initWithTemplate(AppComp, `<div i18n><span i18n-title title="text">content</span></div>`);
|
||||
expect(fixture.nativeElement.innerHTML).toEqual(`<div>contenu</div>`);
|
||||
});
|
||||
|
||||
it('with custom interpolation config', () => {
|
||||
loadTranslations({'Hello {$INTERPOLATION}': 'Bonjour {$INTERPOLATION}'});
|
||||
loadTranslations({'6353989911216474113': 'Bonjour {$INTERPOLATION}'});
|
||||
const interpolation = ['{%', '%}'] as[string, string];
|
||||
TestBed.overrideComponent(AppComp, {set: {interpolation}});
|
||||
const fixture = initWithTemplate(
|
||||
AppComp, `<div i18n-title="m|d" title="Hello {% name %}"></div>`);
|
||||
const fixture =
|
||||
initWithTemplate(AppComp, `<div i18n-title="m|d" title="Hello {% name %}"></div>`);
|
||||
|
||||
const element = fixture.nativeElement.firstChild;
|
||||
expect(element.title).toBe('Bonjour Angular');
|
||||
});
|
||||
|
||||
it('in nested template', () => {
|
||||
loadTranslations({'Item {$INTERPOLATION}': 'Article {$INTERPOLATION}'});
|
||||
loadTranslations({'5108705942887033129': 'Article {$INTERPOLATION}'});
|
||||
const fixture = initWithTemplate(AppComp, `
|
||||
<div *ngFor='let item of [1,2,3]'>
|
||||
<div i18n-title='m|d' title='Item {{ item }}'></div>
|
||||
|
@ -1068,9 +998,9 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('should add i18n attributes on self-closing tags', () => {
|
||||
loadTranslations({'Hello {$INTERPOLATION}': 'Bonjour {$INTERPOLATION}'});
|
||||
const fixture = initWithTemplate(
|
||||
AppComp, `<img src="logo.png" i18n-title title="Hello {{ name }}">`);
|
||||
loadTranslations({'3771704108176831903': 'Bonjour {$INTERPOLATION}'});
|
||||
const fixture =
|
||||
initWithTemplate(AppComp, `<img src="logo.png" i18n-title title="Hello {{ name }}">`);
|
||||
|
||||
const element = fixture.nativeElement.firstChild;
|
||||
expect(element.title).toBe('Bonjour Angular');
|
||||
|
@ -1114,8 +1044,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
|
||||
it('with complex expressions', () => {
|
||||
loadTranslations({
|
||||
'{$INTERPOLATION} - {$INTERPOLATION_1} - {$INTERPOLATION_2}':
|
||||
'{$INTERPOLATION} - {$INTERPOLATION_1} - {$INTERPOLATION_2} (fr)'
|
||||
'305276527729153743': '{$INTERPOLATION} - {$INTERPOLATION_1} - {$INTERPOLATION_2} (fr)'
|
||||
});
|
||||
const fixture = initWithTemplate(AppComp, `
|
||||
<div i18n-title title="{{ name | uppercase }} - {{ obj?.a?.b }} - {{ obj?.getA()?.b }}"></div>
|
||||
|
@ -1129,8 +1058,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
getA: () => ({b: 'value 2'}),
|
||||
};
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.firstChild.title)
|
||||
.toEqual(`ANGULAR - value 1 - value 2 (fr)`);
|
||||
expect(fixture.nativeElement.firstChild.title).toEqual(`ANGULAR - value 1 - value 2 (fr)`);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1163,12 +1091,11 @@ onlyInIvy('Ivy i18n logic')
|
|||
|
||||
TestBed.configureTestingModule({declarations: [ClsDir, MyApp]});
|
||||
loadTranslations({
|
||||
// Not that this translation switches the order of the expressions!
|
||||
'start {$INTERPOLATION} middle {$INTERPOLATION_1} end':
|
||||
'début {$INTERPOLATION_1} milieu {$INTERPOLATION} fin',
|
||||
'{VAR_PLURAL, plural, =0 {no {START_BOLD_TEXT}emails{CLOSE_BOLD_TEXT}!} =1 {one {START_ITALIC_TEXT}email{CLOSE_ITALIC_TEXT}} other {{INTERPOLATION} emails}}':
|
||||
// Note that this translation switches the order of the expressions!
|
||||
'2244013204777604001': 'début {$INTERPOLATION_1} milieu {$INTERPOLATION} fin',
|
||||
'7297507129788731971':
|
||||
'{VAR_PLURAL, plural, =0 {aucun {START_BOLD_TEXT}email{CLOSE_BOLD_TEXT}!} =1 {un {START_ITALIC_TEXT}email{CLOSE_ITALIC_TEXT}} other {{INTERPOLATION} emails}}',
|
||||
' trad: {$ICU} ': ' traduction: {$ICU} '
|
||||
'7694415136422535717': ' traduction: {$ICU} '
|
||||
});
|
||||
const fixture = TestBed.createComponent(MyApp);
|
||||
fixture.detectChanges();
|
||||
|
@ -1210,8 +1137,10 @@ onlyInIvy('Ivy i18n logic')
|
|||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [AppComp, MyComp]});
|
||||
loadTranslations(
|
||||
{'Hello {$INTERPOLATION}': 'Bonjour {$INTERPOLATION}', 'works': 'fonctionne'});
|
||||
loadTranslations({
|
||||
'3299467052279745802': 'Bonjour {$INTERPOLATION}',
|
||||
'694232821652669635': 'fonctionne',
|
||||
});
|
||||
const fixture = initWithTemplate(
|
||||
AppComp,
|
||||
`<my-comp i18n i18n-title title="works" i18n-value="hi" value="Hello {{name}}"></my-comp>`);
|
||||
|
@ -1226,7 +1155,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
|
||||
it('should support adding/moving/removing nodes', () => {
|
||||
loadTranslations({
|
||||
'{$START_TAG_DIV2}{$CLOSE_TAG_DIV2}{$START_TAG_DIV3}{$CLOSE_TAG_DIV3}{$START_TAG_DIV4}{$CLOSE_TAG_DIV4}{$START_TAG_DIV5}{$CLOSE_TAG_DIV5}{$START_TAG_DIV6}{$CLOSE_TAG_DIV6}{$START_TAG_DIV7}{$CLOSE_TAG_DIV7}{$START_TAG_DIV8}{$CLOSE_TAG_DIV8}':
|
||||
'3934630822967503512':
|
||||
'{$START_TAG_DIV2}{$CLOSE_TAG_DIV2}{$START_TAG_DIV8}{$CLOSE_TAG_DIV8}{$START_TAG_DIV4}{$CLOSE_TAG_DIV4}{$START_TAG_DIV5}{$CLOSE_TAG_DIV5}Bonjour monde{$START_TAG_DIV3}{$CLOSE_TAG_DIV3}{$START_TAG_DIV7}{$CLOSE_TAG_DIV7}'
|
||||
});
|
||||
const fixture = initWithTemplate(AppComp, `
|
||||
|
@ -1266,9 +1195,8 @@ onlyInIvy('Ivy i18n logic')
|
|||
}
|
||||
TestBed.configureTestingModule({declarations: [Parent, Child]});
|
||||
loadTranslations({
|
||||
|
||||
'Child of {$INTERPOLATION}': 'Enfant de {$INTERPOLATION}',
|
||||
'{$START_TAG_CHILD}I am projected from {$START_BOLD_TEXT}{$INTERPOLATION}{$START_TAG_REMOVE_ME_1}{$CLOSE_TAG_REMOVE_ME_1}{$CLOSE_BOLD_TEXT}{$START_TAG_REMOVE_ME_2}{$CLOSE_TAG_REMOVE_ME_2}{$CLOSE_TAG_CHILD}{$START_TAG_REMOVE_ME_3}{$CLOSE_TAG_REMOVE_ME_3}':
|
||||
'7180841260895623479': 'Enfant de {$INTERPOLATION}',
|
||||
'2325314462315226487':
|
||||
'{$START_TAG_CHILD}Je suis projeté depuis {$START_BOLD_TEXT}{$INTERPOLATION}{$CLOSE_BOLD_TEXT}{$CLOSE_TAG_CHILD}'
|
||||
});
|
||||
const fixture = TestBed.createComponent(Parent);
|
||||
|
@ -1299,9 +1227,8 @@ onlyInIvy('Ivy i18n logic')
|
|||
}
|
||||
TestBed.configureTestingModule({declarations: [Parent, Child]});
|
||||
loadTranslations({
|
||||
|
||||
'Child of {$INTERPOLATION}': 'Enfant de {$INTERPOLATION}',
|
||||
'I am projected from {$INTERPOLATION}': 'Je suis projeté depuis {$INTERPOLATION}'
|
||||
'7180841260895623479': 'Enfant de {$INTERPOLATION}',
|
||||
'7230149585615622873': 'Je suis projeté depuis {$INTERPOLATION}'
|
||||
});
|
||||
const fixture = TestBed.createComponent(Parent);
|
||||
fixture.detectChanges();
|
||||
|
@ -1325,46 +1252,12 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('should re-project translations when multiple projections', () => {
|
||||
@Component(
|
||||
{selector: 'grand-child', template: '<div><ng-content></ng-content></div>'})
|
||||
@Component({selector: 'grand-child', template: '<div><ng-content></ng-content></div>'})
|
||||
class GrandChild {
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'child',
|
||||
template: '<grand-child><ng-content></ng-content></grand-child>'
|
||||
})
|
||||
class Child {
|
||||
}
|
||||
|
||||
@Component({selector: 'parent', template: `<child i18n><b>Hello</b> World!</child>`})
|
||||
class Parent {
|
||||
name: string = 'Parent';
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [Parent, Child, GrandChild]});
|
||||
loadTranslations({
|
||||
|
||||
'{$START_BOLD_TEXT}Hello{$CLOSE_BOLD_TEXT} World!':
|
||||
'{$START_BOLD_TEXT}Bonjour{$CLOSE_BOLD_TEXT} monde!'
|
||||
});
|
||||
const fixture = TestBed.createComponent(Parent);
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.innerHTML)
|
||||
.toEqual(
|
||||
'<child><grand-child><div><b>Bonjour</b> monde!</div></grand-child></child>');
|
||||
});
|
||||
|
||||
it('should be able to remove projected placeholders', () => {
|
||||
@Component(
|
||||
{selector: 'grand-child', template: '<div><ng-content></ng-content></div>'})
|
||||
class GrandChild {
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'child',
|
||||
template: '<grand-child><ng-content></ng-content></grand-child>'
|
||||
})
|
||||
{selector: 'child', template: '<grand-child><ng-content></ng-content></grand-child>'})
|
||||
class Child {
|
||||
}
|
||||
|
||||
|
@ -1375,7 +1268,30 @@ onlyInIvy('Ivy i18n logic')
|
|||
|
||||
TestBed.configureTestingModule({declarations: [Parent, Child, GrandChild]});
|
||||
loadTranslations(
|
||||
{'{$START_BOLD_TEXT}Hello{$CLOSE_BOLD_TEXT} World!': 'Bonjour monde!'});
|
||||
{'9156403697449779168': '{$START_BOLD_TEXT}Bonjour{$CLOSE_BOLD_TEXT} monde!'});
|
||||
const fixture = TestBed.createComponent(Parent);
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.innerHTML)
|
||||
.toEqual('<child><grand-child><div><b>Bonjour</b> monde!</div></grand-child></child>');
|
||||
});
|
||||
|
||||
it('should be able to remove projected placeholders', () => {
|
||||
@Component({selector: 'grand-child', template: '<div><ng-content></ng-content></div>'})
|
||||
class GrandChild {
|
||||
}
|
||||
|
||||
@Component(
|
||||
{selector: 'child', template: '<grand-child><ng-content></ng-content></grand-child>'})
|
||||
class Child {
|
||||
}
|
||||
|
||||
@Component({selector: 'parent', template: `<child i18n><b>Hello</b> World!</child>`})
|
||||
class Parent {
|
||||
name: string = 'Parent';
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [Parent, Child, GrandChild]});
|
||||
loadTranslations({'9156403697449779168': 'Bonjour monde!'});
|
||||
const fixture = TestBed.createComponent(Parent);
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.innerHTML)
|
||||
|
@ -1383,7 +1299,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('should project translations with selectors', () => {
|
||||
@Component({selector: 'child', template: `<ng-content select="span"></ng-content>`})
|
||||
@Component({selector: 'child', template: `<ng-content select='span'></ng-content>`})
|
||||
class Child {
|
||||
}
|
||||
|
||||
|
@ -1400,11 +1316,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [Parent, Child]});
|
||||
loadTranslations({
|
||||
|
||||
'{$START_TAG_SPAN}{$CLOSE_TAG_SPAN}{$START_TAG_SPAN_1}{$CLOSE_TAG_SPAN}':
|
||||
'{$START_TAG_SPAN}Contenu{$CLOSE_TAG_SPAN}'
|
||||
});
|
||||
loadTranslations({'2827528023268681613': '{$START_TAG_SPAN}Contenu{$CLOSE_TAG_SPAN}'});
|
||||
const fixture = TestBed.createComponent(Parent);
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.innerHTML)
|
||||
|
@ -1425,8 +1337,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
}
|
||||
TestBed.configureTestingModule({declarations: [Parent, Child]});
|
||||
loadTranslations({
|
||||
|
||||
'Content projected from {$START_TAG_NG_CONTENT}{$CLOSE_TAG_NG_CONTENT}':
|
||||
'4431461951818971024':
|
||||
'Contenu projeté depuis {$START_TAG_NG_CONTENT}{$CLOSE_TAG_NG_CONTENT}'
|
||||
});
|
||||
|
||||
|
@ -1455,9 +1366,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
}
|
||||
TestBed.configureTestingModule({declarations: [Parent, Child]});
|
||||
loadTranslations({
|
||||
|
||||
'Content projected from {$START_TAG_NG_CONTENT}{$CLOSE_TAG_NG_CONTENT}':
|
||||
'{$START_TAG_NG_CONTENT}{$CLOSE_TAG_NG_CONTENT} a projeté le contenu'
|
||||
'4431461951818971024': '{$START_TAG_NG_CONTENT}{$CLOSE_TAG_NG_CONTENT} a projeté le contenu'
|
||||
});
|
||||
const fixture = TestBed.createComponent(Parent);
|
||||
fixture.detectChanges();
|
||||
|
@ -1466,26 +1375,19 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('should project translated content in i18n blocks', () => {
|
||||
@Component({
|
||||
selector: 'child',
|
||||
template: `<div i18n>Child content <ng-content></ng-content></div>`
|
||||
})
|
||||
@Component(
|
||||
{selector: 'child', template: `<div i18n>Child content <ng-content></ng-content></div>`})
|
||||
class Child {
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'parent',
|
||||
template: `<child i18n>and projection from {{name}}</child>`
|
||||
})
|
||||
@Component({selector: 'parent', template: `<child i18n>and projection from {{name}}</child>`})
|
||||
class Parent {
|
||||
name: string = 'Parent';
|
||||
}
|
||||
TestBed.configureTestingModule({declarations: [Parent, Child]});
|
||||
loadTranslations({
|
||||
|
||||
'Child content {$START_TAG_NG_CONTENT}{$CLOSE_TAG_NG_CONTENT}':
|
||||
'Contenu enfant {$START_TAG_NG_CONTENT}{$CLOSE_TAG_NG_CONTENT}',
|
||||
'and projection from {$INTERPOLATION}': 'et projection depuis {$INTERPOLATION}'
|
||||
'3861221266941684467': 'Contenu enfant {$START_TAG_NG_CONTENT}{$CLOSE_TAG_NG_CONTENT}',
|
||||
'6186458652454735259': 'et projection depuis {$INTERPOLATION}'
|
||||
});
|
||||
const fixture = TestBed.createComponent(Parent);
|
||||
fixture.detectChanges();
|
||||
|
@ -1521,10 +1423,8 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it('should project ICUs in i18n blocks', () => {
|
||||
@Component({
|
||||
selector: 'child',
|
||||
template: `<div i18n>Child content <ng-content></ng-content></div>`
|
||||
})
|
||||
@Component(
|
||||
{selector: 'child', template: `<div i18n>Child content <ng-content></ng-content></div>`})
|
||||
class Child {
|
||||
}
|
||||
|
||||
|
@ -1538,10 +1438,8 @@ onlyInIvy('Ivy i18n logic')
|
|||
}
|
||||
TestBed.configureTestingModule({declarations: [Parent, Child]});
|
||||
loadTranslations({
|
||||
|
||||
'Child content {$START_TAG_NG_CONTENT}{$CLOSE_TAG_NG_CONTENT}':
|
||||
'Contenu enfant {$START_TAG_NG_CONTENT}{$CLOSE_TAG_NG_CONTENT}',
|
||||
'and projection from {$ICU}': 'et projection depuis {$ICU}'
|
||||
'3861221266941684467': 'Contenu enfant {$START_TAG_NG_CONTENT}{$CLOSE_TAG_NG_CONTENT}',
|
||||
'4986299685320703675': 'et projection depuis {$ICU}'
|
||||
});
|
||||
const fixture = TestBed.createComponent(Parent);
|
||||
fixture.detectChanges();
|
||||
|
@ -1557,30 +1455,23 @@ onlyInIvy('Ivy i18n logic')
|
|||
});
|
||||
|
||||
it(`shouldn't project deleted projections in i18n blocks`, () => {
|
||||
@Component({
|
||||
selector: 'child',
|
||||
template: `<div i18n>Child content <ng-content></ng-content></div>`
|
||||
})
|
||||
@Component(
|
||||
{selector: 'child', template: `<div i18n>Child content <ng-content></ng-content></div>`})
|
||||
class Child {
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'parent',
|
||||
template: `<child i18n>and projection from {{name}}</child>`
|
||||
})
|
||||
@Component({selector: 'parent', template: `<child i18n>and projection from {{name}}</child>`})
|
||||
class Parent {
|
||||
name: string = 'Parent';
|
||||
}
|
||||
TestBed.configureTestingModule({declarations: [Parent, Child]});
|
||||
loadTranslations({
|
||||
|
||||
'Child content {$START_TAG_NG_CONTENT}{$CLOSE_TAG_NG_CONTENT}': 'Contenu enfant',
|
||||
'and projection from {$INTERPOLATION}': 'et projection depuis {$INTERPOLATION}'
|
||||
'3861221266941684467': 'Contenu enfant',
|
||||
'6186458652454735259': 'et projection depuis {$INTERPOLATION}'
|
||||
});
|
||||
const fixture = TestBed.createComponent(Parent);
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.innerHTML)
|
||||
.toEqual(`<child><div>Contenu enfant</div></child>`);
|
||||
expect(fixture.nativeElement.innerHTML).toEqual(`<child><div>Contenu enfant</div></child>`);
|
||||
});
|
||||
|
||||
it('should display/destroy projected i18n content', () => {
|
||||
|
@ -1662,11 +1553,8 @@ onlyInIvy('Ivy i18n logic')
|
|||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [TextDirective, DivQuery]});
|
||||
loadTranslations({
|
||||
|
||||
'{$START_TAG_NG_TEMPLATE}{$START_TAG_DIV_1}{$START_TAG_DIV}{$START_TAG_SPAN}Content{$CLOSE_TAG_SPAN}{$CLOSE_TAG_DIV}{$CLOSE_TAG_DIV}{$CLOSE_TAG_NG_TEMPLATE}':
|
||||
'{$START_TAG_NG_TEMPLATE}Contenu{$CLOSE_TAG_NG_TEMPLATE}'
|
||||
});
|
||||
loadTranslations(
|
||||
{'3395826043214005257': '{$START_TAG_NG_TEMPLATE}Contenu{$CLOSE_TAG_NG_TEMPLATE}'});
|
||||
const fixture = initWithTemplate(AppComp, `
|
||||
<div-query #q i18n>
|
||||
<ng-template>
|
||||
|
@ -1712,8 +1600,7 @@ onlyInIvy('Ivy i18n logic')
|
|||
data = false;
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [DialogDir, CloseBtn, ContentElementDialog]});
|
||||
TestBed.configureTestingModule({declarations: [DialogDir, CloseBtn, ContentElementDialog]});
|
||||
|
||||
const fixture = TestBed.createComponent(ContentElementDialog);
|
||||
fixture.detectChanges();
|
||||
|
|
|
@ -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}'
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue