diff --git a/packages/compiler-cli/test/compliance/r3_view_compiler_i18n_spec.ts b/packages/compiler-cli/test/compliance/r3_view_compiler_i18n_spec.ts
index 533046c8ef..9ccb7a2cbe 100644
--- a/packages/compiler-cli/test/compliance/r3_view_compiler_i18n_spec.ts
+++ b/packages/compiler-cli/test/compliance/r3_view_compiler_i18n_spec.ts
@@ -182,6 +182,104 @@ const verify = (input: string, output: string, extra: any = {}): void => {
}
};
+// Describes a simple key-value object.
+type KVList = {
+ [key: string]: string
+};
+
+// Describes placeholder type used in tests. Note: the type is an array (not an object), since it's
+// important to preserve the order of placeholders (so that we can compare it with generated
+// output).
+type Placeholder = string[];
+
+// Unique message id index that is needed to avoid different i18n vars with the same name to appear
+// in the i18n block while generating an output string (used to verify compiler-generated code).
+let msgIndex = 0;
+
+// Wraps a string into quotes is needed.
+// Note: if a string starts with `$` is a special case in tests when ICU reference
+// is used as a placeholder value, this we should not wrap it in quotes.
+const quotedValue = (value: string) => value.startsWith('$') ? value : `"${value}"`;
+
+// Generates a string that represents expected Closure metadata output.
+const i18nMsgClosureMeta = (meta?: KVList): string => {
+ if (!meta || !(meta.desc || meta.meaning)) return '';
+ return `
+ /**
+ ${meta.desc ? '* @desc ' + meta.desc : ''}
+ ${meta.meaning ? '* @meaning ' + meta.meaning : ''}
+ */
+ `;
+};
+
+// Converts a set of placeholders to a string (as it's expected from compiler).
+const i18nPlaceholdersToString = (placeholders: Placeholder[]): string => {
+ if (placeholders.length === 0) return '';
+ const result = placeholders.map(([key, value]) => `"${key}": ${quotedValue(value)}`);
+ return `, { ${result.join(',')} }`;
+};
+
+// Generates a string that represents expected $localize metadata output.
+const i18nMsgLocalizeMeta = (meta?: KVList): string => {
+ if (!meta) return '';
+ let localizeMeta = '';
+ if (meta.meaning) localizeMeta += `${meta.meaning}|`;
+ if (meta.desc) localizeMeta += meta.desc;
+ if (meta.id) localizeMeta += `@@${meta.id}`;
+ return `:${localizeMeta}:`;
+};
+
+// Transforms a message in a Closure format to a $localize version.
+const i18nMsgInsertLocalizePlaceholders =
+ (message: string, placeholders: Placeholder[]): string => {
+ if (placeholders.length > 0) {
+ message = message.replace(/{\$(.*?)}/g, function(_, name) {
+ const value = placeholders.find(([k, _]) => k === name)![1];
+ // e.g. startDivTag -> START_DIV_TAG
+ const key = name.replace(/[A-Z]/g, (ch: string) => '_' + ch).toUpperCase();
+ return '$' + String.raw`{${quotedValue(value)}}:${key}:`;
+ });
+ }
+ return message;
+ };
+
+// Generates a string that represents expected i18n block content for simple message.
+const i18nMsg = (message: string, placeholders: Placeholder[] = [], meta?: KVList) => {
+ const varName = `$I18N_${msgIndex++}$`;
+ const closurePlaceholders = i18nPlaceholdersToString(placeholders);
+ const locMessageWithPlaceholders = i18nMsgInsertLocalizePlaceholders(message, placeholders);
+ return String.raw`
+ var ${varName};
+ if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
+ ${i18nMsgClosureMeta(meta)}
+ const $MSG_EXTERNAL_${msgIndex}$ = goog.getMsg("${message}"${closurePlaceholders});
+ ${varName} = $MSG_EXTERNAL_${msgIndex}$;
+ }
+ else {
+ ${varName} = $localize \`${i18nMsgLocalizeMeta(meta)}${locMessageWithPlaceholders}\`;
+ }`;
+};
+
+// Generates a string that represents expected i18n block content for a message that requires
+// post-processing (thus includes `ɵɵi18nPostprocess` in generated code).
+const i18nMsgWithPostprocess =
+ (message: string, placeholders: Placeholder[] = [], meta?: KVList,
+ postprocessPlaceholders?: Placeholder[]) => {
+ const varName = `$I18N_${msgIndex}$`;
+ const ppPaceholders =
+ postprocessPlaceholders ? i18nPlaceholdersToString(postprocessPlaceholders) : '';
+ return String.raw`
+ ${i18nMsg(message, placeholders, meta)}
+ ${varName} = $r3$.ɵɵi18nPostprocess($${varName}$${ppPaceholders});
+ `;
+ };
+
+// Generates a string that represents expected i18n block content for an ICU.
+const i18nIcuMsg =
+ (message: string, placeholders: string[][] = []) => {
+ return i18nMsgWithPostprocess(message, [], undefined, placeholders);
+ }
+
describe('i18n support in the template compiler', () => {
describe('element attributes', () => {
it('should add the meaning and description as JsDoc comments and metadata blocks', () => {
@@ -196,109 +294,66 @@ describe('i18n support in the template compiler', () => {
Content H
`;
- const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- /**
- * @desc descA
- * @meaning meaningA
- */
- const $MSG_EXTERNAL_idA$$APP_SPEC_TS_1$ = goog.getMsg("Content A");
- $I18N_0$ = $MSG_EXTERNAL_idA$$APP_SPEC_TS_1$;
- }
- else {
- $I18N_0$ = $localize \`:meaningA|descA@@idA:Content A\`;
- }
- var $I18N_3$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- /**
- * @desc descB
- * @meaning meaningB
- */
- const $MSG_EXTERNAL_idB$$APP_SPEC_TS_4$ = goog.getMsg("Title B");
- $I18N_3$ = $MSG_EXTERNAL_idB$$APP_SPEC_TS_4$;
- }
- else {
- $I18N_3$ = $localize \`:meaningB|descB@@idB:Title B\`;
- }
- const $_c5$ = ["title", $I18N_3$];
- var $I18N_7$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- /**
- * @meaning meaningC
- */
- 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 \`:meaningC|:Title C\`;
- }
- const $_c9$ = ["title", $I18N_7$];
- var $I18N_11$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- /**
- * @desc descD
- * @meaning meaningD
- */
- const $MSG_EXTERNAL_5200291527729162531$$APP_SPEC_TS_12$ = goog.getMsg("Title D");
- $I18N_11$ = $MSG_EXTERNAL_5200291527729162531$$APP_SPEC_TS_12$;
- }
- else {
- $I18N_11$ = $localize \`:meaningD|descD:Title D\`;
- }
- const $_c13$ = ["title", $I18N_11$];
- var $I18N_15$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- /**
- * @desc meaningE
- */
- const $MSG_EXTERNAL_idE$$APP_SPEC_TS_16$ = goog.getMsg("Title E");
- $I18N_15$ = $MSG_EXTERNAL_idE$$APP_SPEC_TS_16$;
- }
- else {
- $I18N_15$ = $localize \`:meaningE@@idE:Title E\`;
- }
- const $_c17$ = ["title", $I18N_15$];
- var $I18N_19$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_idF$$APP_SPEC_TS_20$ = goog.getMsg("Title F");
- $I18N_19$ = $MSG_EXTERNAL_idF$$APP_SPEC_TS_20$;
- }
- else {
- $I18N_19$ = $localize \`:@@idF:Title F\`;
- }
- const $_c21$ = ["title", $I18N_19$];
+ const i18n_0 = i18nMsg('Content A', [], {id: 'idA', meaning: 'meaningA', desc: 'descA'});
+ const i18n_1 = i18nMsg('Title B', [], {id: 'idB', meaning: 'meaningB', desc: 'descB'});
+ const i18n_2 = i18nMsg('Title C', [], {meaning: 'meaningC'});
+ const i18n_3 = i18nMsg('Title D', [], {meaning: 'meaningD', desc: 'descD'});
+ const i18n_4 = i18nMsg('Title E', [], {id: 'idE', desc: 'meaningE'});
+ const i18n_5 = i18nMsg('Title F', [], {id: 'idF'});
+
+ // Keeping this block as a raw string, since it checks escaping of special chars.
+ const i18n_6 = String.raw`
var $I18N_23$;
if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- /**
- * @desc [BACKUP_$` +
+ /**
+ * @desc [BACKUP_$` +
String.raw`{MESSAGE}_ID:idH]` +
'`' + String.raw`desc
- */
- const $MSG_EXTERNAL_idG$$APP_SPEC_TS_24$ = goog.getMsg("Title G");
- $I18N_23$ = $MSG_EXTERNAL_idG$$APP_SPEC_TS_24$;
+ */
+ const $MSG_EXTERNAL_idG$$APP_SPEC_TS_24$ = goog.getMsg("Title G");
+ $I18N_23$ = $MSG_EXTERNAL_idG$$APP_SPEC_TS_24$;
}
else {
$I18N_23$ = $localize \`:[BACKUP_$\{MESSAGE}_ID\:idH]\\\`desc@@idG:Title G\`;
}
- const $_c25$ = ["title", $I18N_23$];
- var $I18N_20$;
+ `;
+
+ // Keeping this block as a raw string, since it checks escaping of special chars.
+ const i18n_7 = String.raw`
+ var $i18n_7$;
if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- /**
- * @desc Some text \' [BACKUP_MESSAGE_ID: xxx]
- */
- const $MSG_EXTERNAL_idG$$APP_SPEC_TS_21$ = goog.getMsg("Content H");
- $I18N_20$ = $MSG_EXTERNAL_idG$$APP_SPEC_TS_21$;
+ /**
+ * @desc Some text \' [BACKUP_MESSAGE_ID: xxx]
+ */
+ const $MSG_EXTERNAL_idG$$APP_SPEC_TS_21$ = goog.getMsg("Content H");
+ $i18n_7$ = $MSG_EXTERNAL_idG$$APP_SPEC_TS_21$;
}
else {
- $I18N_20$ = $localize \`:Some text \\' [BACKUP_MESSAGE_ID\: xxx]:Content H\`;
+ $i18n_7$ = $localize \`:Some text \\' [BACKUP_MESSAGE_ID\: xxx]:Content H\`;
}
+ `;
+
+ const output = String.raw`
+ ${i18n_0}
+ ${i18n_1}
+ const $_c5$ = ["title", $i18n_1$];
+ ${i18n_2}
+ const $_c9$ = ["title", $i18n_2$];
+ ${i18n_3}
+ const $_c13$ = ["title", $i18n_3$];
+ ${i18n_4}
+ const $_c17$ = ["title", $i18n_4$];
+ ${i18n_5}
+ const $_c21$ = ["title", $i18n_5$];
+ ${i18n_6}
+ const $_c25$ = ["title", $i18n_6$];
+ ${i18n_7}
…
consts: [[${AttributeMarker.I18n}, "title"]],
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18n(1, $I18N_0$);
+ $r3$.ɵɵi18n(1, $i18n_0$);
$r3$.ɵɵelementEnd();
$r3$.ɵɵelementStart(2, "div", 0);
$r3$.ɵɵi18nAttributes(3, $_c5$);
@@ -325,7 +380,7 @@ describe('i18n support in the template compiler', () => {
$r3$.ɵɵtext(19, "Content G");
$r3$.ɵɵelementEnd();
$r3$.ɵɵelementStart(20, "div");
- $r3$.ɵɵi18n(21, $I18N_20$);
+ $r3$.ɵɵi18n(21, $i18n_7$);
$r3$.ɵɵelementEnd();
}
}
@@ -339,16 +394,10 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nMsg('Hello');
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_6616505470450179563$$APP_SPEC_TS_1$ = goog.getMsg("Hello");
- $I18N_0$ = $MSG_EXTERNAL_6616505470450179563$$APP_SPEC_TS_1$;
- }
- else {
- $I18N_0$ = $localize \`Hello\`;
- }
- const $_c2$ = ["title", $I18N_0$];
+ ${i18n_0}
+ const $_c2$ = ["title", $i18n_0$];
…
consts: [[${AttributeMarker.I18n}, "title"]],
template: function MyComponent_Template(rf, ctx) {
@@ -367,16 +416,10 @@ describe('i18n support in the template compiler', () => {
Test
`;
+ const i18n_0 = i18nMsg('Hello');
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_6616505470450179563$$APP_SPEC_TS_1$ = goog.getMsg("Hello");
- $I18N_0$ = $MSG_EXTERNAL_6616505470450179563$$APP_SPEC_TS_1$;
- }
- else {
- $I18N_0$ = $localize \`Hello\`;
- }
- const $_c2$ = ["title", $I18N_0$];
+ ${i18n_0}
+ const $_c2$ = ["title", $i18n_0$];
function MyComponent_0_ng_template_0_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵtext(0, "Test");
@@ -408,19 +451,11 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 =
+ i18nMsg('Hello {$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]]);
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_3771704108176831903$$APP_SPEC_TS_1$ = goog.getMsg("Hello {$interpolation}", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_0$ = $MSG_EXTERNAL_3771704108176831903$$APP_SPEC_TS_1$;
- }
- else {
- $I18N_0$ = $localize \`Hello $` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
- }
- const $_c2$ = ["title", $I18N_0$];
+ ${i18n_0}
+ const $_c2$ = ["title", $i18n_0$];
…
consts: [[${AttributeMarker.Bindings}, "title"]],
template: function MyComponent_Template(rf, ctx) {
@@ -443,19 +478,11 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 =
+ i18nMsg('Hello {$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]]);
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_3771704108176831903$$APP_SPEC_TS__1$ = goog.getMsg("Hello {$interpolation}", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_0$ = $MSG_EXTERNAL_3771704108176831903$$APP_SPEC_TS__1$;
- }
- else {
- $I18N_0$ = $localize \`Hello $` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
- }
- const $_c2$ = ["title", $I18N_0$];
+ ${i18n_0}
+ const $_c2$ = ["title", $i18n_0$];
…
function MyComponent_0_Template(rf, ctx) {
if (rf & 1) {
@@ -530,20 +557,10 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nMsg('introduction', [], {meaning: 'm', desc: 'd'});
const output = String.raw`
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && 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:introduction\`;
- }
- const $_c1$ = ["title", $I18N_1$];
+ ${i18n_0}
+ const $_c1$ = ["title", $i18n_0$];
…
consts: [["id", "static", ${AttributeMarker.I18n}, "title"]],
template: function MyComponent_Template(rf, ctx) {
@@ -571,89 +588,45 @@ describe('i18n support in the template compiler', () => {
>
`;
+ const i18n_0 = i18nMsg('static text');
+ const i18n_1 = i18nMsg(
+ 'intro {$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]],
+ {meaning: 'm', desc: 'd'});
+ const i18n_2 = i18nMsg(
+ '{$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]],
+ {meaning: 'm1', desc: 'd1'});
+ const i18n_3 = i18nMsg(
+ '{$interpolation} and {$interpolation_1} and again {$interpolation_2}',
+ [
+ ['interpolation', String.raw`\uFFFD0\uFFFD`],
+ ['interpolation_1', String.raw`\uFFFD1\uFFFD`],
+ ['interpolation_2', String.raw`\uFFFD2\uFFFD`]
+ ],
+ {meaning: 'm2', desc: 'd2'});
+ const i18n_4 = i18nMsg('{$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]]);
+
const output = String.raw`
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_5526535577705876535$$APP_SPEC_TS_1$ = goog.getMsg("static text");
- $I18N_1$ = $MSG_EXTERNAL_5526535577705876535$$APP_SPEC_TS_1$;
- }
- else {
- $I18N_1$ = $localize \`static text\`;
- }
- var $I18N_2$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- /**
- * @desc d
- * @meaning m
- */
- const $MSG_EXTERNAL_8977039798304050198$$APP_SPEC_TS_2$ = goog.getMsg("intro {$interpolation}", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_2$ = $MSG_EXTERNAL_8977039798304050198$$APP_SPEC_TS_2$;
- }
- else {
- $I18N_2$ = $localize \`:m|d:intro $` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
- }
- var $I18N_3$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- /**
- * @desc d1
- * @meaning m1
- */
- const $MSG_EXTERNAL_7432761130955693041$$APP_SPEC_TS_3$ = goog.getMsg("{$interpolation}", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_3$ = $MSG_EXTERNAL_7432761130955693041$$APP_SPEC_TS_3$;
- }
- else {
- $I18N_3$ = $localize \`:m1|d1:$` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
- }
+ ${i18n_0}
+ ${i18n_1}
+ ${i18n_2}
const $_c1$ = [
- "aria-roledescription", $I18N_1$,
- "title", $I18N_2$,
- "aria-label", $I18N_3$
+ "aria-roledescription", $i18n_0$,
+ "title", $i18n_1$,
+ "aria-label", $i18n_2$
];
- var $I18N_6$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- /**
- * @desc d2
- * @meaning m2
- */
- const $MSG_EXTERNAL_7566208596013750546$$APP_SPEC_TS_6$ = goog.getMsg("{$interpolation} and {$interpolation_1} and again {$interpolation_2}", {
- "interpolation": "\uFFFD0\uFFFD", "interpolation_1": "\uFFFD1\uFFFD", "interpolation_2": "\uFFFD2\uFFFD"
- });
- $I18N_6$ = $MSG_EXTERNAL_7566208596013750546$$APP_SPEC_TS_6$;
- }
- else {
- $I18N_6$ = $localize \`:m2|d2:$` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION: and $` +
- String.raw`{"\uFFFD1\uFFFD"}:INTERPOLATION_1: and again $` +
- String.raw`{"\uFFFD2\uFFFD"}:INTERPOLATION_2:\`;
- }
- var $I18N_7$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_6639222533406278123$$APP_SPEC_TS_7$ = goog.getMsg("{$interpolation}", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_7$ = $MSG_EXTERNAL_6639222533406278123$$APP_SPEC_TS_7$;
- }
- else {
- $I18N_7$ = $localize \`$` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
- }
+ ${i18n_3}
+ ${i18n_4}
const $_c3$ = [
- "title", $I18N_6$,
- "aria-roledescription", $I18N_7$
+ "title", $i18n_3$,
+ "aria-roledescription", $i18n_4$
];
…
decls: 5,
vars: 8,
consts: [["id", "dynamic-1", ${
- AttributeMarker
- .I18n}, "aria-roledescription", "title", "aria-label"], ["id", "dynamic-2", ${
- AttributeMarker.I18n}, "title", "aria-roledescription"]],
+ AttributeMarker
+ .I18n}, "aria-roledescription", "title", "aria-label"], ["id", "dynamic-2", ${
+ AttributeMarker.I18n}, "title", "aria-roledescription"]],
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div", 0);
@@ -682,23 +655,12 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nMsg(
+ 'intro {$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]],
+ {meaning: 'm', desc: 'd'});
const output = String.raw`
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- /**
- * @desc d
- * @meaning m
- */
- const $MSG_EXTERNAL_8977039798304050198$ = goog.getMsg("intro {$interpolation}", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_1$ = $MSG_EXTERNAL_8977039798304050198$;
- }
- else {
- $I18N_1$ = $localize \`:m|d:intro $` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
- }
- const $_c3$ = ["title", $I18N_1$];
+ ${i18n_0}
+ const $_c3$ = ["title", $i18n_0$];
…
consts: [[${AttributeMarker.I18n}, "title"]],
template: function MyComponent_Template(rf, ctx) {
@@ -724,23 +686,13 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nMsg(
+ 'different scope {$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]],
+ {meaning: 'm', desc: 'd'});
+
const output = String.raw`
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- /**
- * @desc d
- * @meaning m
- */
- const $MSG_EXTERNAL_8538466649243975456$$APP_SPEC_TS__1$ = goog.getMsg("different scope {$interpolation}", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_1$ = $MSG_EXTERNAL_8538466649243975456$$APP_SPEC_TS__1$;
- }
- else {
- $I18N_1$ = $localize \`:m|d:different scope $` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
- }
- const $_c2$ = ["title", $I18N_1$];
+ ${i18n_0}
+ const $_c2$ = ["title", $i18n_0$];
function MyComponent_div_0_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
@@ -761,7 +713,7 @@ describe('i18n support in the template compiler', () => {
decls: 1,
vars: 1,
consts: [[${AttributeMarker.Template}, "ngFor", "ngForOf"], [${
- AttributeMarker.I18n}, "title"]],
+ AttributeMarker.I18n}, "title"]],
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵtemplate(0, MyComponent_div_0_Template, 4, 3, "div", 0);
@@ -780,19 +732,12 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 =
+ i18nMsg('{$interpolation} title', [['interpolation', String.raw`\uFFFD0\uFFFD`]]);
+
const output = String.raw`
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_3462388422673575127$$APP_SPEC_TS_2$ = goog.getMsg("{$interpolation} title", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_1$ = $MSG_EXTERNAL_3462388422673575127$$APP_SPEC_TS_2$;
- }
- else {
- $I18N_1$ = $localize \`$` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION: title\`;
- }
- const $_c3$ = ["title", $I18N_1$];
+ ${i18n_0}
+ const $_c3$ = ["title", $i18n_0$];
…
decls: 2,
vars: 1,
@@ -827,81 +772,37 @@ describe('i18n support in the template compiler', () => {
>
`;
+ const i18n_0 = i18nMsg('static text');
+ const i18n_1 = i18nMsg(
+ 'intro {$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]],
+ {meaning: 'm', desc: 'd'});
+ const i18n_2 = i18nMsg(
+ '{$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]],
+ {meaning: 'm1', desc: 'd1'});
+ const i18n_3 = i18nMsg(
+ '{$interpolation} and {$interpolation_1} and again {$interpolation_2}',
+ [
+ ['interpolation', String.raw`\uFFFD0\uFFFD`],
+ ['interpolation_1', String.raw`\uFFFD1\uFFFD`],
+ ['interpolation_2', String.raw`\uFFFD2\uFFFD`]
+ ],
+ {meaning: 'm2', desc: 'd2'});
+ const i18n_4 = i18nMsg('{$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]]);
+
const output = String.raw`
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_5526535577705876535$$APP_SPEC_TS_1$ = goog.getMsg("static text");
- $I18N_1$ = $MSG_EXTERNAL_5526535577705876535$$APP_SPEC_TS_1$;
- }
- else {
- $I18N_1$ = $localize \`static text\`;
- }
- var $I18N_2$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- /**
- * @desc d
- * @meaning m
- */
- const $MSG_EXTERNAL_8977039798304050198$$APP_SPEC_TS_2$ = goog.getMsg("intro {$interpolation}", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_2$ = $MSG_EXTERNAL_8977039798304050198$$APP_SPEC_TS_2$;
- }
- else {
- $I18N_2$ = $localize \`:m|d:intro $` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
- }
- var $I18N_3$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- /**
- * @desc d1
- * @meaning m1
- */
- const $MSG_EXTERNAL_7432761130955693041$$APP_SPEC_TS_3$ = goog.getMsg("{$interpolation}", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_3$ = $MSG_EXTERNAL_7432761130955693041$$APP_SPEC_TS_3$;
- }
- else {
- $I18N_3$ = $localize \`:m1|d1:$` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
- }
+ ${i18n_0}
+ ${i18n_1}
+ ${i18n_2}
const $_c1$ = [
- "aria-roledescription", $I18N_1$,
- "title", $I18N_2$,
- "aria-label", $I18N_3$
+ "aria-roledescription", $i18n_0$,
+ "title", $i18n_1$,
+ "aria-label", $i18n_2$
];
- var $I18N_6$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- /**
- * @desc d2
- * @meaning m2
- */
- const $MSG_EXTERNAL_7566208596013750546$$APP_SPEC_TS_6$ = goog.getMsg("{$interpolation} and {$interpolation_1} and again {$interpolation_2}", {
- "interpolation": "\uFFFD0\uFFFD", "interpolation_1": "\uFFFD1\uFFFD", "interpolation_2": "\uFFFD2\uFFFD"
- });
- $I18N_6$ = $MSG_EXTERNAL_7566208596013750546$$APP_SPEC_TS_6$;
- }
- else {
- $I18N_6$ = $localize \`:m2|d2:$` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION: and $` +
- String.raw`{"\uFFFD1\uFFFD"}:INTERPOLATION_1: and again $` +
- String.raw`{"\uFFFD2\uFFFD"}:INTERPOLATION_2:\`;
- }
- var $I18N_7$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_6639222533406278123$$APP_SPEC_TS_7$ = goog.getMsg("{$interpolation}", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_7$ = $MSG_EXTERNAL_6639222533406278123$$APP_SPEC_TS_7$;
- }
- else {
- $I18N_7$ = $localize \`$` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
- }
+ ${i18n_3}
+ ${i18n_4}
const $_c3$ = [
- "title", $I18N_6$,
- "aria-roledescription", $I18N_7$
+ "title", $i18n_3$,
+ "aria-roledescription", $i18n_4$
];
…
decls: 5,
@@ -940,23 +841,13 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nMsg(
+ 'different scope {$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]],
+ {meaning: 'm', desc: 'd'});
+
const output = String.raw`
- var $I18N_2$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- /**
- * @desc d
- * @meaning m
- */
- const $MSG_EXTERNAL_8538466649243975456$$APP_SPEC_TS__3$ = goog.getMsg("different scope {$interpolation}", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_2$ = $MSG_EXTERNAL_8538466649243975456$$APP_SPEC_TS__3$;
- }
- else {
- $I18N_2$ = $localize \`:m|d:different scope $` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
- }
- const $_c4$ = ["title", $I18N_2$];
+ ${i18n_0}
+ const $_c4$ = ["title", $i18n_0$];
function MyComponent_div_0_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
@@ -977,7 +868,7 @@ describe('i18n support in the template compiler', () => {
decls: 1,
vars: 1,
consts: [[${AttributeMarker.Template}, "ngFor", "ngForOf"], [${
- AttributeMarker.I18n}, "title"]],
+ AttributeMarker.I18n}, "title"]],
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵtemplate(0, MyComponent_div_0_Template, 4, 3, "div", 0);
@@ -996,35 +887,20 @@ describe('i18n support in the template compiler', () => {
Some content
`;
+ const i18n_0 = i18nMsg('Element title', [], {meaning: 'm', desc: 'd'});
+ const i18n_1 = i18nMsg('Some content');
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- /**
- * @desc d
- * @meaning m
- */
- const $MSG_EXTERNAL_7727043314656808423$$APP_SPEC_TS_0$ = goog.getMsg("Element title");
- $I18N_0$ = $MSG_EXTERNAL_7727043314656808423$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \`:m|d:Element title\`;
- }
- const $_c1$ = ["title", $I18N_0$];
- var $I18N_2$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_4969674997806975147$$APP_SPEC_TS_2$ = goog.getMsg("Some content");
- $I18N_2$ = $MSG_EXTERNAL_4969674997806975147$$APP_SPEC_TS_2$;
- }
- else {
- $I18N_2$ = $localize \`Some content\`;
- }
+ ${i18n_0}
+ const $_c1$ = ["title", $i18n_0$];
+ ${i18n_1}
…
consts: [[${AttributeMarker.I18n}, "title"]],
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div", 0);
$r3$.ɵɵi18nAttributes(1, $_c1$);
- $r3$.ɵɵi18n(2, $I18N_2$);
+ $r3$.ɵɵi18n(2, $i18n_1$);
$r3$.ɵɵelementEnd();
}
}
@@ -1039,6 +915,7 @@ describe('i18n support in the template compiler', () => {
`;
+ // Keeping raw content (avoiding `i18nMsg`) to illustrate message id sanitization.
const output = String.raw`
var $I18N_0$;
if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
@@ -1096,20 +973,8 @@ describe('i18n support in the template compiler', () => {
});
it('should ignore HTML comments within translated text', () => {
- const input = `
- Some text
- `;
-
- const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_APP_SPEC_TS_1$ = goog.getMsg("Some text");
- $I18N_0$ = $MSG_APP_SPEC_TS_1$;
- }
- else {
- $I18N_0$ = $localize \`Some text\`;
- }
- `;
+ const input = `Some text
`;
+ const output = i18nMsg('Some text');
verify(input, output);
});
@@ -1118,6 +983,7 @@ describe('i18n support in the template compiler', () => {
Some text 'with single quotes', "with double quotes", \`with backticks\` and without quotes.
`;
+ // Keeping raw content (avoiding `i18nMsg`) to illustrate quotes escaping.
const output = String.raw`
var $I18N_0$;
if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
@@ -1135,6 +1001,7 @@ describe('i18n support in the template compiler', () => {
it('should handle interpolations wrapped in backticks', () => {
const input = '`{{ count }}`
';
+ // Keeping raw content (avoiding `i18nMsg`) to illustrate backticks escaping.
const output = String.raw`
var $I18N_0$;
if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
@@ -1158,48 +1025,31 @@ describe('i18n support in the template compiler', () => {
My i18n block #3
`;
+ const i18n_0 = i18nMsg('My i18n block #1');
+ const i18n_1 = i18nMsg('My i18n block #2');
+ const i18n_2 = i18nMsg('My i18n block #3');
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_4890179241114413722$$APP_SPEC_TS_0$ = goog.getMsg("My i18n block #1");
- $I18N_0$ = $MSG_EXTERNAL_4890179241114413722$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \`My i18n block #1\`;
- }
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_2413150872298537152$$APP_SPEC_TS_1$ = goog.getMsg("My i18n block #2");
- $I18N_1$ = $MSG_EXTERNAL_2413150872298537152$$APP_SPEC_TS_1$;
- }
- else {
- $I18N_1$ = $localize \`My i18n block #2\`;
- }
- var $I18N_2$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_5023003143537152794$$APP_SPEC_TS_2$ = goog.getMsg("My i18n block #3");
- $I18N_2$ = $MSG_EXTERNAL_5023003143537152794$$APP_SPEC_TS_2$;
- }
- else {
- $I18N_2$ = $localize \`My i18n block #3\`;
- }
+ ${i18n_0}
+ ${i18n_1}
+ ${i18n_2}
…
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18n(1, $I18N_0$);
+ $r3$.ɵɵi18n(1, $i18n_0$);
$r3$.ɵɵelementEnd();
$r3$.ɵɵelementStart(2, "div");
$r3$.ɵɵtext(3, "My non-i18n block #1");
$r3$.ɵɵelementEnd();
$r3$.ɵɵelementStart(4, "div");
- $r3$.ɵɵi18n(5, $I18N_1$);
+ $r3$.ɵɵi18n(5, $i18n_1$);
$r3$.ɵɵelementEnd();
$r3$.ɵɵelementStart(6, "div");
$r3$.ɵɵtext(7, "My non-i18n block #2");
$r3$.ɵɵelementEnd();
$r3$.ɵɵelementStart(8, "div");
- $r3$.ɵɵi18n(9, $I18N_2$);
+ $r3$.ɵɵi18n(9, $i18n_2$);
$r3$.ɵɵelementEnd();
}
}
@@ -1216,6 +1066,8 @@ describe('i18n support in the template compiler', () => {
`;
+ // Keeping raw content (avoiding `i18nMsg`) to illustrate how named interpolations are
+ // generated.
const output = String.raw`
var $I18N_0$;
if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
@@ -1255,23 +1107,15 @@ describe('i18n support in the template compiler', () => {
{% valueA %}
`;
+ const i18n_0 = i18nMsg('{$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_6749967533321674787$$APP_SPEC_TS_0$ = goog.getMsg("{$interpolation}", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_0$ = $MSG_EXTERNAL_6749967533321674787$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \`$` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
- }
+ ${i18n_0}
…
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18n(1, $I18N_0$);
+ $r3$.ɵɵi18n(1, $i18n_0$);
$r3$.ɵɵelementEnd();
}
if (rf & 2) {
@@ -1293,34 +1137,28 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nMsg(' {$interpolation} {$interpolation_1} {$interpolation_2} ', [
+ ['interpolation', String.raw`\uFFFD0\uFFFD`],
+ ['interpolation_1', String.raw`\uFFFD1\uFFFD`],
+ ['interpolation_2', String.raw`\uFFFD2\uFFFD`]
+ ]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- 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_APP_SPEC_TS_1$$APP_SPEC_TS_1$;
- }
- else {
- $I18N_0$ = $localize \` $` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION: $` +
- String.raw`{"\uFFFD1\uFFFD"}:INTERPOLATION_1: $` +
- String.raw`{"\uFFFD2\uFFFD"}:INTERPOLATION_2: \`;
- }
+ ${i18n_0}
…
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18n(1, $I18N_0$);
+ $r3$.ɵɵi18n(1, $i18n_0$);
$r3$.ɵɵpipe(2, "async");
$r3$.ɵɵelementEnd();
}
if (rf & 2) {
var $tmp_2_0$ = null;
$r3$.ɵɵadvance(2);
- $r3$.ɵɵi18nExp($r3$.ɵɵpipeBind1(2, 3, ctx.valueA))(ctx.valueA == null ? null : ctx.valueA.a == null ? null : ctx.valueA.a.b)(($tmp_2_0$ = ctx.valueA.getRawValue()) == null ? null : $tmp_2_0$.getTitle());
+ $r3$.ɵɵi18nExp($r3$.ɵɵpipeBind1(2, 3, ctx.valueA))
+ (ctx.valueA == null ? null : ctx.valueA.a == null ? null : ctx.valueA.a.b)
+ (($tmp_2_0$ = ctx.valueA.getRawValue()) == null ? null : $tmp_2_0$.getTitle());
$r3$.ɵɵi18nApply(1);
}
}
@@ -1335,54 +1173,31 @@ describe('i18n support in the template compiler', () => {
My i18n block #{{ three + four + five }}
`;
+ const i18n_0 = i18nMsg(
+ 'My i18n block #{$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]]);
+ const i18n_1 = i18nMsg(
+ 'My i18n block #{$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]]);
+ const i18n_2 = i18nMsg(
+ 'My i18n block #{$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_572579892698764378$$APP_SPEC_TS_0$ = goog.getMsg("My i18n block #{$interpolation}", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_0$ = $MSG_EXTERNAL_572579892698764378$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \`My i18n block #$` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
- }
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_609623417156596326$$APP_SPEC_TS_1$ = goog.getMsg("My i18n block #{$interpolation}", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_1$ = $MSG_EXTERNAL_609623417156596326$$APP_SPEC_TS_1$;
- }
- else {
- $I18N_1$ = $localize \`My i18n block #$` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
- }
- var $I18N_2$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_3998119318957372120$$APP_SPEC_TS_2$ = goog.getMsg("My i18n block #{$interpolation}", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_2$ = $MSG_EXTERNAL_3998119318957372120$$APP_SPEC_TS_2$;
- }
- else {
- $I18N_2$ = $localize \`My i18n block #$` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
- }
+ ${i18n_0}
+ ${i18n_1}
+ ${i18n_2}
…
decls: 7,
vars: 5,
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18n(1, $I18N_0$);
+ $r3$.ɵɵi18n(1, $i18n_0$);
$r3$.ɵɵelementEnd();
$r3$.ɵɵelementStart(2, "div");
- $r3$.ɵɵi18n(3, $I18N_1$);
+ $r3$.ɵɵi18n(3, $i18n_1$);
$r3$.ɵɵpipe(4, "uppercase");
$r3$.ɵɵelementEnd();
$r3$.ɵɵelementStart(5, "div");
- $r3$.ɵɵi18n(6, $I18N_2$);
+ $r3$.ɵɵi18n(6, $i18n_2$);
$r3$.ɵɵelementEnd();
}
if (rf & 2) {
@@ -1420,58 +1235,39 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nMsg(
+ ' My i18n block #{$interpolation} {$startTagSpan}Plain text in nested element{$closeTagSpan}',
+ [
+ ['interpolation', String.raw`\uFFFD0\uFFFD`],
+ ['startTagSpan', String.raw`\uFFFD#2\uFFFD`],
+ ['closeTagSpan', String.raw`\uFFFD/#2\uFFFD`]
+ ]);
+ const i18n_1 = i18nMsgWithPostprocess(
+ ' My i18n block #{$interpolation} {$startTagDiv}{$startTagDiv}{$startTagSpan} More bindings in more nested element: {$interpolation_1} {$closeTagSpan}{$closeTagDiv}{$closeTagDiv}',
+ [
+ ['interpolation', String.raw`\uFFFD0\uFFFD`],
+ ['startTagDiv', String.raw`[\uFFFD#6\uFFFD|\uFFFD#7\uFFFD]`],
+ ['startTagSpan', String.raw`\uFFFD#8\uFFFD`],
+ ['interpolation_1', String.raw`\uFFFD1\uFFFD`],
+ ['closeTagSpan', String.raw`\uFFFD/#8\uFFFD`],
+ ['closeTagDiv', String.raw`[\uFFFD/#7\uFFFD|\uFFFD/#6\uFFFD]`]
+ ]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_7905233330103651696$$APP_SPEC_TS_0$ = goog.getMsg(" My i18n block #{$interpolation} {$startTagSpan}Plain text in nested element{$closeTagSpan}", {
- "interpolation": "\uFFFD0\uFFFD",
- "startTagSpan": "\uFFFD#2\uFFFD",
- "closeTagSpan": "\uFFFD/#2\uFFFD"
- });
- $I18N_0$ = $MSG_EXTERNAL_7905233330103651696$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \` 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:\`;
- }
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_5788821996131681377$$APP_SPEC_TS_1$ = goog.getMsg(" My i18n block #{$interpolation} {$startTagDiv}{$startTagDiv}{$startTagSpan} More bindings in more nested element: {$interpolation_1} {$closeTagSpan}{$closeTagDiv}{$closeTagDiv}", {
- "interpolation": "\uFFFD0\uFFFD",
- "startTagDiv": "[\uFFFD#6\uFFFD|\uFFFD#7\uFFFD]",
- "startTagSpan": "\uFFFD#8\uFFFD",
- "interpolation_1": "\uFFFD1\uFFFD",
- "closeTagSpan": "\uFFFD/#8\uFFFD",
- "closeTagDiv": "[\uFFFD/#7\uFFFD|\uFFFD/#6\uFFFD]"
- });
- $I18N_1$ = $MSG_EXTERNAL_5788821996131681377$$APP_SPEC_TS_1$;
- }
- else {
- $I18N_1$ = $localize \` 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
- `{"\uFFFD#8\uFFFD"}:START_TAG_SPAN: More bindings in more nested element: $` +
- String.raw`{"\uFFFD1\uFFFD"}:INTERPOLATION_1: $` +
- String.raw`{"\uFFFD/#8\uFFFD"}:CLOSE_TAG_SPAN:$` +
- String.raw`{"[\uFFFD/#7\uFFFD|\uFFFD/#6\uFFFD]"}:CLOSE_TAG_DIV:$` +
- String.raw`{"[\uFFFD/#7\uFFFD|\uFFFD/#6\uFFFD]"}:CLOSE_TAG_DIV:\`;
- }
- $I18N_1$ = $r3$.ɵɵi18nPostprocess($I18N_1$);
+ ${i18n_0}
+ ${i18n_1}
…
decls: 9,
vars: 5,
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18nStart(1, $I18N_0$);
+ $r3$.ɵɵi18nStart(1, $i18n_0$);
$r3$.ɵɵelement(2, "span");
$r3$.ɵɵi18nEnd();
$r3$.ɵɵelementEnd();
$r3$.ɵɵelementStart(3, "div");
- $r3$.ɵɵi18nStart(4, $I18N_1$);
+ $r3$.ɵɵi18nStart(4, $i18n_1$);
$r3$.ɵɵpipe(5, "uppercase");
$r3$.ɵɵelementStart(6, "div");
$r3$.ɵɵelementStart(7, "div");
@@ -1511,63 +1307,33 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nMsg('Span title {$interpolation} and {$interpolation_1}', [
+ ['interpolation', String.raw`\uFFFD0\uFFFD`], ['interpolation_1', String.raw`\uFFFD1\uFFFD`]
+ ]);
+ const i18n_1 = i18nMsg(
+ ' My i18n block #1 with value: {$interpolation} {$startTagSpan} Plain text in nested element (block #1) {$closeTagSpan}',
+ [
+ ['interpolation', String.raw`\uFFFD0\uFFFD`],
+ ['startTagSpan', String.raw`\uFFFD#2\uFFFD`],
+ ['closeTagSpan', String.raw`\uFFFD/#2\uFFFD`]
+ ]);
+ const i18n_2 =
+ i18nMsg('Span title {$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]]);
+ const i18n_3 = i18nMsg(
+ ' My i18n block #2 with value {$interpolation} {$startTagSpan} Plain text in nested element (block #2) {$closeTagSpan}',
+ [
+ ['interpolation', String.raw`\uFFFD0\uFFFD`],
+ ['startTagSpan', String.raw`\uFFFD#7\uFFFD`],
+ ['closeTagSpan', String.raw`\uFFFD/#7\uFFFD`]
+ ]);
+
const output = String.raw`
- var $I18N_2$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_4782264005467235841$$APP_SPEC_TS_3$ = goog.getMsg("Span title {$interpolation} and {$interpolation_1}", {
- "interpolation": "\uFFFD0\uFFFD",
- "interpolation_1": "\uFFFD1\uFFFD"
- });
- $I18N_2$ = $MSG_EXTERNAL_4782264005467235841$$APP_SPEC_TS_3$;
- }
- else {
- $I18N_2$ = $localize \`Span title $` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION: and $` +
- String.raw`{"\uFFFD1\uFFFD"}:INTERPOLATION_1:\`;
- }
- const $_c4$ = ["title", $I18N_2$];
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_4446430594603971069$$APP_SPEC_TS_5$ = goog.getMsg(" My i18n block #1 with value: {$interpolation} {$startTagSpan} Plain text in nested element (block #1) {$closeTagSpan}", {
- "interpolation": "\uFFFD0\uFFFD",
- "startTagSpan": "\uFFFD#2\uFFFD",
- "closeTagSpan": "\uFFFD/#2\uFFFD"
- });
- $I18N_0$ = $MSG_EXTERNAL_4446430594603971069$$APP_SPEC_TS_5$;
- }
- else {
- $I18N_0$ = $localize \` 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:\`;
- }
- var $I18N_7$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_2719594642740200058$$APP_SPEC_TS_8$ = goog.getMsg("Span title {$interpolation}", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_7$ = $MSG_EXTERNAL_2719594642740200058$$APP_SPEC_TS_8$;
- }
- else {
- $I18N_7$ = $localize \`Span title $` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
- }
- const $_c9$ = ["title", $I18N_7$];
- var $I18N_6$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_2778714953278357902$$APP_SPEC_TS_10$ = goog.getMsg(" My i18n block #2 with value {$interpolation} {$startTagSpan} Plain text in nested element (block #2) {$closeTagSpan}", {
- "interpolation": "\uFFFD0\uFFFD",
- "startTagSpan": "\uFFFD#7\uFFFD",
- "closeTagSpan": "\uFFFD/#7\uFFFD"
- });
- $I18N_6$ = $MSG_EXTERNAL_2778714953278357902$$APP_SPEC_TS_10$;
- }
- else {
- $I18N_6$ = $localize \` 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:\`;
- }
+ ${i18n_0}
+ const $_c4$ = ["title", $i18n_0$];
+ ${i18n_1}
+ ${i18n_2}
+ const $_c9$ = ["title", $i18n_2$];
+ ${i18n_3}
…
decls: 9,
vars: 7,
@@ -1575,14 +1341,14 @@ describe('i18n support in the template compiler', () => {
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18nStart(1, $I18N_0$);
+ $r3$.ɵɵi18nStart(1, $i18n_1$);
$r3$.ɵɵelementStart(2, "span", 0);
$r3$.ɵɵi18nAttributes(3, $_c4$);
$r3$.ɵɵelementEnd();
$r3$.ɵɵi18nEnd();
$r3$.ɵɵelementEnd();
$r3$.ɵɵelementStart(4, "div");
- $r3$.ɵɵi18nStart(5, $I18N_6$);
+ $r3$.ɵɵi18nStart(5, $i18n_3$);
$r3$.ɵɵpipe(6, "uppercase");
$r3$.ɵɵelementStart(7, "span", 0);
$r3$.ɵɵi18nAttributes(8, $_c9$);
@@ -1625,30 +1391,23 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nMsg(
+ ' Some other content {$interpolation} {$startTagDiv} More nested levels with bindings {$interpolation_1} {$closeTagDiv}',
+ [
+ ['interpolation', String.raw`\uFFFD0\uFFFD`],
+ ['startTagDiv', String.raw`\uFFFD#3\uFFFD`],
+ ['interpolation_1', String.raw`\uFFFD1\uFFFD`],
+ ['closeTagDiv', String.raw`\uFFFD/#3\uFFFD`]
+ ]);
+
const output = String.raw`
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_7679414751795588050$$APP_SPEC_TS__1$ = goog.getMsg(" Some other content {$interpolation} {$startTagDiv} More nested levels with bindings {$interpolation_1} {$closeTagDiv}", {
- "interpolation": "\uFFFD0\uFFFD",
- "startTagDiv": "\uFFFD#3\uFFFD",
- "interpolation_1": "\uFFFD1\uFFFD",
- "closeTagDiv": "\uFFFD/#3\uFFFD"
- });
- $I18N_1$ = $MSG_EXTERNAL_7679414751795588050$$APP_SPEC_TS__1$;
- }
- else {
- $I18N_1$ = $localize \` 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: $` +
- String.raw`{"\uFFFD/#3\uFFFD"}:CLOSE_TAG_DIV:\`;
- }
+ ${i18n_0}
…
function MyComponent_div_2_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
$r3$.ɵɵelementStart(1, "div");
- $r3$.ɵɵi18nStart(2, $I18N_1$);
+ $r3$.ɵɵi18nStart(2, $i18n_0$);
$r3$.ɵɵelement(3, "div");
$r3$.ɵɵpipe(4, "uppercase");
$r3$.ɵɵi18nEnd();
@@ -1690,24 +1449,17 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 =
+ i18nMsg('App logo #{$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]]);
+
const output = String.raw`
function MyComponent_img_1_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelement(0, "img", 0);
}
}
- var $I18N_2$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_2367729185105559721$$APP_SPEC_TS__2$ = goog.getMsg("App logo #{$interpolation}", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_2$ = $MSG_EXTERNAL_2367729185105559721$$APP_SPEC_TS__2$;
- }
- else {
- $I18N_2$ = $localize \`App logo #$` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
- }
- const $_c4$ = ["title", $I18N_2$];
+ ${i18n_0}
+ const $_c4$ = ["title", $i18n_0$];
function MyComponent_img_2_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "img", 3);
@@ -1724,10 +1476,10 @@ describe('i18n support in the template compiler', () => {
decls: 3,
vars: 2,
consts: [["src", "logo.png"], ["src", "logo.png", ${
- AttributeMarker.Template}, "ngIf"], ["src", "logo.png", ${
- AttributeMarker.Bindings}, "title", ${
- AttributeMarker.Template}, "ngIf"], ["src", "logo.png", ${
- AttributeMarker.I18n}, "title"]],
+ AttributeMarker.Template}, "ngIf"], ["src", "logo.png", ${
+ AttributeMarker.Bindings}, "title", ${
+ AttributeMarker.Template}, "ngIf"], ["src", "logo.png", ${
+ AttributeMarker.I18n}, "title"]],
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelement(0, "img", 0);
@@ -1771,6 +1523,26 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nMsgWithPostprocess(
+ ' Some content {$startTagDiv_2} Some other content {$interpolation} {$startTagDiv} More nested levels with bindings {$interpolation_1} {$startTagDiv_1} Content inside sub-template {$interpolation_2} {$startTagDiv} Bottom level element {$interpolation_3} {$closeTagDiv}{$closeTagDiv}{$closeTagDiv}{$closeTagDiv}{$startTagDiv_3} Some other content {$interpolation_4} {$startTagDiv} More nested levels with bindings {$interpolation_5} {$closeTagDiv}{$closeTagDiv}',
+ [
+ ['startTagDiv_2', String.raw`\uFFFD*2:1\uFFFD\uFFFD#1:1\uFFFD`],
+ [
+ 'closeTagDiv',
+ String
+ .raw`[\uFFFD/#2:2\uFFFD|\uFFFD/#1:2\uFFFD\uFFFD/*4:2\uFFFD|\uFFFD/#2:1\uFFFD|\uFFFD/#1:1\uFFFD\uFFFD/*2:1\uFFFD|\uFFFD/#2:3\uFFFD|\uFFFD/#1:3\uFFFD\uFFFD/*3:3\uFFFD]`
+ ],
+ ['startTagDiv_3', String.raw`\uFFFD*3:3\uFFFD\uFFFD#1:3\uFFFD`],
+ ['interpolation', String.raw`\uFFFD0:1\uFFFD`],
+ ['startTagDiv', String.raw`[\uFFFD#2:1\uFFFD|\uFFFD#2:2\uFFFD|\uFFFD#2:3\uFFFD]`],
+ ['interpolation_1', String.raw`\uFFFD1:1\uFFFD`],
+ ['startTagDiv_1', String.raw`\uFFFD*4:2\uFFFD\uFFFD#1:2\uFFFD`],
+ ['interpolation_2', String.raw`\uFFFD0:2\uFFFD`],
+ ['interpolation_3', String.raw`\uFFFD1:2\uFFFD`],
+ ['interpolation_4', String.raw`\uFFFD0:3\uFFFD`],
+ ['interpolation_5', String.raw`\uFFFD1:3\uFFFD`]
+ ]);
+
const output = String.raw`
function MyComponent_div_2_div_4_Template(rf, ctx) {
if (rf & 1) {
@@ -1806,51 +1578,7 @@ describe('i18n support in the template compiler', () => {
$r3$.ɵɵi18nApply(0);
}
}
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_1221890473527419724$$APP_SPEC_TS_0$ = goog.getMsg(" Some content {$startTagDiv_2} Some other content {$interpolation} {$startTagDiv} More nested levels with bindings {$interpolation_1} {$startTagDiv_1} Content inside sub-template {$interpolation_2} {$startTagDiv} Bottom level element {$interpolation_3} {$closeTagDiv}{$closeTagDiv}{$closeTagDiv}{$closeTagDiv}{$startTagDiv_3} Some other content {$interpolation_4} {$startTagDiv} More nested levels with bindings {$interpolation_5} {$closeTagDiv}{$closeTagDiv}", {
- "startTagDiv_2": "\uFFFD*2:1\uFFFD\uFFFD#1:1\uFFFD",
- "closeTagDiv": "[\uFFFD/#2:2\uFFFD|\uFFFD/#1:2\uFFFD\uFFFD/*4:2\uFFFD|\uFFFD/#2:1\uFFFD|\uFFFD/#1:1\uFFFD\uFFFD/*2:1\uFFFD|\uFFFD/#2:3\uFFFD|\uFFFD/#1:3\uFFFD\uFFFD/*3:3\uFFFD]",
- "startTagDiv_3": "\uFFFD*3:3\uFFFD\uFFFD#1:3\uFFFD",
- "interpolation": "\uFFFD0:1\uFFFD",
- "startTagDiv": "[\uFFFD#2:1\uFFFD|\uFFFD#2:2\uFFFD|\uFFFD#2:3\uFFFD]",
- "interpolation_1": "\uFFFD1:1\uFFFD",
- "startTagDiv_1": "\uFFFD*4:2\uFFFD\uFFFD#1:2\uFFFD",
- "interpolation_2": "\uFFFD0:2\uFFFD",
- "interpolation_3": "\uFFFD1:2\uFFFD",
- "interpolation_4": "\uFFFD0:3\uFFFD",
- "interpolation_5": "\uFFFD1:3\uFFFD"
- });
- $I18N_0$ = $MSG_EXTERNAL_1221890473527419724$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \` 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
- `{"[\uFFFD#2:1\uFFFD|\uFFFD#2:2\uFFFD|\uFFFD#2:3\uFFFD]"}:START_TAG_DIV: More nested levels with bindings $` +
- String.raw`{"\uFFFD1:1\uFFFD"}:INTERPOLATION_1: $` + String.raw
- `{"\uFFFD*4:2\uFFFD\uFFFD#1:2\uFFFD"}:START_TAG_DIV_1: Content inside sub-template $` +
- String.raw`{"\uFFFD0:2\uFFFD"}:INTERPOLATION_2: $` + String.raw
- `{"[\uFFFD#2:1\uFFFD|\uFFFD#2:2\uFFFD|\uFFFD#2:3\uFFFD]"}:START_TAG_DIV: Bottom level element $` +
- String.raw`{"\uFFFD1:2\uFFFD"}:INTERPOLATION_3: $` + String.raw
- `{"[\uFFFD/#2:2\uFFFD|\uFFFD/#1:2\uFFFD\uFFFD/*4:2\uFFFD|\uFFFD/#2:1\uFFFD|\uFFFD/#1:1\uFFFD\uFFFD/*2:1\uFFFD|\uFFFD/#2:3\uFFFD|\uFFFD/#1:3\uFFFD\uFFFD/*3:3\uFFFD]"}:CLOSE_TAG_DIV:$` +
- String.raw
- `{"[\uFFFD/#2:2\uFFFD|\uFFFD/#1:2\uFFFD\uFFFD/*4:2\uFFFD|\uFFFD/#2:1\uFFFD|\uFFFD/#1:1\uFFFD\uFFFD/*2:1\uFFFD|\uFFFD/#2:3\uFFFD|\uFFFD/#1:3\uFFFD\uFFFD/*3:3\uFFFD]"}:CLOSE_TAG_DIV:$` +
- String.raw
- `{"[\uFFFD/#2:2\uFFFD|\uFFFD/#1:2\uFFFD\uFFFD/*4:2\uFFFD|\uFFFD/#2:1\uFFFD|\uFFFD/#1:1\uFFFD\uFFFD/*2:1\uFFFD|\uFFFD/#2:3\uFFFD|\uFFFD/#1:3\uFFFD\uFFFD/*3:3\uFFFD]"}:CLOSE_TAG_DIV:$` +
- String.raw
- `{"[\uFFFD/#2:2\uFFFD|\uFFFD/#1:2\uFFFD\uFFFD/*4:2\uFFFD|\uFFFD/#2:1\uFFFD|\uFFFD/#1:1\uFFFD\uFFFD/*2:1\uFFFD|\uFFFD/#2:3\uFFFD|\uFFFD/#1:3\uFFFD\uFFFD/*3:3\uFFFD]"}:CLOSE_TAG_DIV:$` +
- String.raw
- `{"\uFFFD*3:3\uFFFD\uFFFD#1:3\uFFFD"}:START_TAG_DIV_3: Some other content $` +
- String.raw`{"\uFFFD0:3\uFFFD"}:INTERPOLATION_4: $` + String.raw
- `{"[\uFFFD#2:1\uFFFD|\uFFFD#2:2\uFFFD|\uFFFD#2:3\uFFFD]"}:START_TAG_DIV: More nested levels with bindings $` +
- String.raw`{"\uFFFD1:3\uFFFD"}:INTERPOLATION_5: $` + String.raw
- `{"[\uFFFD/#2:2\uFFFD|\uFFFD/#1:2\uFFFD\uFFFD/*4:2\uFFFD|\uFFFD/#2:1\uFFFD|\uFFFD/#1:1\uFFFD\uFFFD/*2:1\uFFFD|\uFFFD/#2:3\uFFFD|\uFFFD/#1:3\uFFFD\uFFFD/*3:3\uFFFD]"}:CLOSE_TAG_DIV:$` +
- String.raw
- `{"[\uFFFD/#2:2\uFFFD|\uFFFD/#1:2\uFFFD\uFFFD/*4:2\uFFFD|\uFFFD/#2:1\uFFFD|\uFFFD/#1:1\uFFFD\uFFFD/*2:1\uFFFD|\uFFFD/#2:3\uFFFD|\uFFFD/#1:3\uFFFD\uFFFD/*3:3\uFFFD]"}:CLOSE_TAG_DIV:\`;
- }
- $I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$);
+ ${i18n_0}
function MyComponent_div_3_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵi18nStart(0, $I18N_0$, 3);
@@ -1897,27 +1625,18 @@ describe('i18n support in the template compiler', () => {
Some other content {{ valueA }}
`;
+ const i18n_0 = i18nMsg('Some other content {$startTagSpan}{$interpolation}{$closeTagSpan}', [
+ ['startTagSpan', String.raw`\uFFFD#2\uFFFD`], ['interpolation', String.raw`\uFFFD0\uFFFD`],
+ ['closeTagSpan', String.raw`\uFFFD/#2\uFFFD`]
+ ]);
+
const output = String.raw`
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_119975189388320493$$APP_SPEC_TS__1$ = goog.getMsg("Some other content {$startTagSpan}{$interpolation}{$closeTagSpan}", {
- "startTagSpan": "\uFFFD#2\uFFFD",
- "interpolation": "\uFFFD0\uFFFD",
- "closeTagSpan": "\uFFFD/#2\uFFFD"
- });
- $I18N_1$ = $MSG_EXTERNAL_119975189388320493$$APP_SPEC_TS__1$;
- }
- else {
- $I18N_1$ = $localize \`Some other content $` +
- String.raw`{"\uFFFD#2\uFFFD"}:START_TAG_SPAN:$` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:$` +
- String.raw`{"\uFFFD/#2\uFFFD"}:CLOSE_TAG_SPAN:\`;
- }
+ ${i18n_0}
…
function MyComponent_div_0_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18nStart(1, $I18N_1$);
+ $r3$.ɵɵi18nStart(1, $i18n_0$);
$r3$.ɵɵelement(2, "span");
$r3$.ɵɵi18nEnd();
$r3$.ɵɵelementEnd();
@@ -1951,22 +1670,17 @@ describe('i18n support in the template compiler', () => {
Hello
`;
+ const i18n_0 = i18nMsg('Hello');
+
const output = String.raw`
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_APP_SPEC_TS_2$ = goog.getMsg("Hello");
- $I18N_1$ = $MSG_APP_SPEC_TS_2$;
- }
- else {
- $I18N_1$ = $localize \`Hello\`;
- }
+ ${i18n_0}
…
consts: [[${AttributeMarker.Bindings}, "click"]],
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div", 0);
$r3$.ɵɵlistener("click", function MyComponent_Template_div_click_0_listener() { return ctx.onClick(); });
- $r3$.ɵɵi18n(1, $I18N_1$);
+ $r3$.ɵɵi18n(1, $i18n_0$);
$r3$.ɵɵelementEnd();
}
}
@@ -1982,20 +1696,15 @@ describe('i18n support in the template compiler', () => {
My i18n block #1
`;
+ const i18n_0 = i18nMsg('My i18n block #1');
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_4890179241114413722$$APP_SPEC_TS_0$ = goog.getMsg("My i18n block #1");
- $I18N_0$ = $MSG_EXTERNAL_4890179241114413722$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \`My i18n block #1\`;
- }
+ ${i18n_0}
…
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18n(1, $I18N_0$);
+ $r3$.ɵɵi18n(1, $i18n_0$);
$r3$.ɵɵelementEnd();
}
}
@@ -2009,18 +1718,12 @@ describe('i18n support in the template compiler', () => {
{age, select, 10 {ten} 20 {twenty} other {other}}
`;
+ const i18n_0 = i18nIcuMsg(
+ '{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}',
+ [['VAR_SELECT', String.raw`\uFFFD0\uFFFD`]]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}");
- $I18N_0$ = $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \`{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}\`;
- }
- $I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
- "VAR_SELECT": "\uFFFD0\uFFFD"
- });
+ ${i18n_0}
…
decls: 2,
vars: 1,
@@ -2047,26 +1750,15 @@ describe('i18n support in the template compiler', () => {
My i18n block #2
`;
+ const i18n_0 = i18nMsg('My i18n block #2');
+ const i18n_1 = i18nMsg('My i18n block #1');
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_2413150872298537152$$APP_SPEC_TS_0$ = goog.getMsg("My i18n block #2");
- $I18N_0$ = $MSG_EXTERNAL_2413150872298537152$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \`My i18n block #2\`;
- }
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_4890179241114413722$$APP_SPEC_TS__1$ = goog.getMsg("My i18n block #1");
- $I18N_1$ = $MSG_EXTERNAL_4890179241114413722$$APP_SPEC_TS__1$;
- }
- else {
- $I18N_1$ = $localize \`My i18n block #1\`;
- }
+ ${i18n_0}
+ ${i18n_1}
function MyComponent_ng_template_0_Template(rf, ctx) {
if (rf & 1) {
- $r3$.ɵɵi18n(0, $I18N_1$);
+ $r3$.ɵɵi18n(0, $i18n_1$);
}
}
…
@@ -2074,7 +1766,7 @@ describe('i18n support in the template compiler', () => {
if (rf & 1) {
$r3$.ɵɵtemplate(0, MyComponent_ng_template_0_Template, 1, 0, "ng-template");
$r3$.ɵɵelementContainerStart(1);
- $r3$.ɵɵi18n(2, $I18N_0$);
+ $r3$.ɵɵi18n(2, $i18n_0$);
$r3$.ɵɵelementContainerEnd();
}
}
@@ -2089,23 +1781,12 @@ describe('i18n support in the template compiler', () => {
Text #2
`;
+ const i18n_0 = i18nMsg('Text #1');
+ const i18n_1 = i18nMsg('Text #2');
+
const output = String.raw`
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_5295701706185791735$$APP_SPEC_TS_1$ = goog.getMsg("Text #1");
- $I18N_1$ = $MSG_EXTERNAL_5295701706185791735$$APP_SPEC_TS_1$;
- }
- else {
- $I18N_1$ = $localize \`Text #1\`;
- }
- var $I18N_3$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_4722270221386399294$$APP_SPEC_TS_3$ = goog.getMsg("Text #2");
- $I18N_3$ = $MSG_EXTERNAL_4722270221386399294$$APP_SPEC_TS_3$;
- }
- else {
- $I18N_3$ = $localize \`Text #2\`;
- }
+ ${i18n_0}
+ ${i18n_1}
…
decls: 4,
vars: 0,
@@ -2114,10 +1795,10 @@ describe('i18n support in the template compiler', () => {
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "span", 0);
- $r3$.ɵɵi18n(1, $I18N_1$);
+ $r3$.ɵɵi18n(1, $i18n_0$);
$r3$.ɵɵelementEnd();
$r3$.ɵɵelementStart(2, "span", 1);
- $r3$.ɵɵi18n(3, $I18N_3$);
+ $r3$.ɵɵi18n(3, $i18n_1$);
$r3$.ɵɵelementEnd();
}
}
@@ -2133,25 +1814,18 @@ describe('i18n support in the template compiler', () => {
Some content: {{ valueA | uppercase }}
`;
+ const i18n_0 =
+ i18nMsg('Some content: {$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_355394464191978948$$APP_SPEC_TS_0$ = goog.getMsg("Some content: {$interpolation}", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_0$ = $MSG_EXTERNAL_355394464191978948$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \`Some content: $` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
- }
+ ${i18n_0}
…
decls: 3,
vars: 3,
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementContainerStart(0);
- $r3$.ɵɵi18n(1, $I18N_0$);
+ $r3$.ɵɵi18n(1, $i18n_0$);
$r3$.ɵɵpipe(2, "uppercase");
$r3$.ɵɵelementContainerEnd();
}
@@ -2171,21 +1845,14 @@ describe('i18n support in the template compiler', () => {
Some content: {{ valueA | uppercase }}
`;
+ const i18n_0 =
+ i18nMsg('Some content: {$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_355394464191978948$$APP_SPEC_TS__0$ = goog.getMsg("Some content: {$interpolation}", {
- "interpolation": "\uFFFD0\uFFFD"
- });
- $I18N_0$ = $MSG_EXTERNAL_355394464191978948$$APP_SPEC_TS__0$;
- }
- else {
- $I18N_0$ = $localize \`Some content: $` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION:\`;
- }
+ ${i18n_0}
function MyComponent_ng_template_0_Template(rf, ctx) {
if (rf & 1) {
- $r3$.ɵɵi18n(0, $I18N_0$);
+ $r3$.ɵɵi18n(0, $i18n_0$);
$r3$.ɵɵpipe(1, "uppercase");
} if (rf & 2) {
const $ctx_r0$ = $r3$.ɵɵnextContext();
@@ -2215,28 +1882,19 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nMsg(
+ '{$startTagNgTemplate}Template content: {$interpolation}{$closeTagNgTemplate}{$startTagNgContainer}Container content: {$interpolation_1}{$closeTagNgContainer}',
+ [
+ ['startTagNgTemplate', String.raw`\uFFFD*2:1\uFFFD`],
+ ['closeTagNgTemplate', String.raw`\uFFFD/*2:1\uFFFD`],
+ ['startTagNgContainer', String.raw`\uFFFD#3\uFFFD`],
+ ['interpolation_1', String.raw`\uFFFD0\uFFFD`],
+ ['closeTagNgContainer', String.raw`\uFFFD/#3\uFFFD`],
+ ['interpolation', String.raw`\uFFFD0:1\uFFFD`]
+ ]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_702706566400598764$$APP_SPEC_TS_0$ = goog.getMsg("{$startTagNgTemplate}Template content: {$interpolation}{$closeTagNgTemplate}{$startTagNgContainer}Container content: {$interpolation_1}{$closeTagNgContainer}", {
- "startTagNgTemplate": "\uFFFD*2:1\uFFFD",
- "closeTagNgTemplate": "\uFFFD/*2:1\uFFFD",
- "startTagNgContainer": "\uFFFD#3\uFFFD",
- "interpolation_1": "\uFFFD0\uFFFD",
- "closeTagNgContainer": "\uFFFD/#3\uFFFD",
- "interpolation": "\uFFFD0:1\uFFFD"
- });
- $I18N_0$ = $MSG_EXTERNAL_702706566400598764$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \`$` +
- 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:$` +
- String.raw`{"\uFFFD#3\uFFFD"}:START_TAG_NG_CONTAINER:Container content: $` +
- String.raw`{"\uFFFD0\uFFFD"}:INTERPOLATION_1:$` +
- String.raw`{"\uFFFD/#3\uFFFD"}:CLOSE_TAG_NG_CONTAINER:\`;
- }
+ ${i18n_0}
function MyComponent_ng_template_2_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵi18n(0, $I18N_0$, 1);
@@ -2255,7 +1913,7 @@ describe('i18n support in the template compiler', () => {
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18nStart(1, $I18N_0$);
+ $r3$.ɵɵi18nStart(1, $i18n_0$);
$r3$.ɵɵtemplate(2, MyComponent_ng_template_2_Template, 2, 3, "ng-template");
$r3$.ɵɵelementContainer(3);
$r3$.ɵɵpipe(4, "uppercase");
@@ -2279,32 +1937,19 @@ describe('i18n support in the template compiler', () => {
{age, select, 10 {ten} 20 {twenty} other {other}}
`;
+ const i18n_0 = i18nIcuMsg(
+ '{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}',
+ [['VAR_SELECT', String.raw`\uFFFD0\uFFFD`]]);
+ const i18n_1 = i18nIcuMsg(
+ '{VAR_SELECT, select, male {male} female {female} other {other}}',
+ [['VAR_SELECT', String.raw`\uFFFD0\uFFFD`]]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}");
- $I18N_0$ = $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \`{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}\`;
- }
- $I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
- "VAR_SELECT": "\uFFFD0\uFFFD"
- });
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS__1$ = goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}");
- $I18N_1$ = $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS__1$;
- }
- else {
- $I18N_1$ = $localize \`{VAR_SELECT, select, male {male} female {female} other {other}}\`;
- }
- $I18N_1$ = $r3$.ɵɵi18nPostprocess($I18N_1$, {
- "VAR_SELECT": "\uFFFD0\uFFFD"
- });
+ ${i18n_0}
+ ${i18n_1}
function MyComponent_ng_template_0_Template(rf, ctx) {
if (rf & 1) {
- $r3$.ɵɵi18n(0, $I18N_1$);
+ $r3$.ɵɵi18n(0, $i18n_1$);
}
if (rf & 2) {
const $ctx_r0$ = $r3$.ɵɵnextContext();
@@ -2319,7 +1964,7 @@ describe('i18n support in the template compiler', () => {
if (rf & 1) {
$r3$.ɵɵtemplate(0, MyComponent_ng_template_0_Template, 1, 1, "ng-template");
$r3$.ɵɵelementContainerStart(1);
- $r3$.ɵɵi18n(2, $I18N_0$);
+ $r3$.ɵɵi18n(2, $i18n_0$);
$r3$.ɵɵelementContainerEnd();
}
if (rf & 2) {
@@ -2348,10 +1993,25 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nMsgWithPostprocess(
+ '{$startTagNgTemplate} Template A: {$interpolation} {$startTagNgTemplate} Template B: {$interpolation_1} {$startTagNgTemplate} Template C: {$interpolation_2} {$closeTagNgTemplate}{$closeTagNgTemplate}{$closeTagNgTemplate}',
+ [
+ [
+ 'startTagNgTemplate', String.raw`[\uFFFD*2:1\uFFFD|\uFFFD*2:2\uFFFD|\uFFFD*1:3\uFFFD]`
+ ],
+ [
+ 'closeTagNgTemplate',
+ String.raw`[\uFFFD/*1:3\uFFFD|\uFFFD/*2:2\uFFFD|\uFFFD/*2:1\uFFFD]`
+ ],
+ ['interpolation', String.raw`\uFFFD0:1\uFFFD`],
+ ['interpolation_1', String.raw`\uFFFD0:2\uFFFD`],
+ ['interpolation_2', String.raw`\uFFFD0:3\uFFFD`]
+ ]);
+
const output = String.raw`
function MyComponent_ng_template_2_ng_template_2_ng_template_1_Template(rf, ctx) {
if (rf & 1) {
- $r3$.ɵɵi18n(0, $I18N_0$, 3);
+ $r3$.ɵɵi18n(0, $i18n_0$, 3);
}
if (rf & 2) {
const $ctx_r2$ = $r3$.ɵɵnextContext(3);
@@ -2361,7 +2021,7 @@ describe('i18n support in the template compiler', () => {
}
function MyComponent_ng_template_2_ng_template_2_Template(rf, ctx) {
if (rf & 1) {
- $r3$.ɵɵi18nStart(0, $I18N_0$, 2);
+ $r3$.ɵɵi18nStart(0, $i18n_0$, 2);
$r3$.ɵɵtemplate(1, MyComponent_ng_template_2_ng_template_2_ng_template_1_Template, 1, 1, "ng-template");
$r3$.ɵɵi18nEnd();
}
@@ -2372,36 +2032,10 @@ describe('i18n support in the template compiler', () => {
$r3$.ɵɵi18nApply(0);
}
}
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_2051477021417799640$$APP_SPEC_TS_0$ = goog.getMsg("{$startTagNgTemplate} Template A: {$interpolation} {$startTagNgTemplate} Template B: {$interpolation_1} {$startTagNgTemplate} Template C: {$interpolation_2} {$closeTagNgTemplate}{$closeTagNgTemplate}{$closeTagNgTemplate}", {
- "startTagNgTemplate": "[\uFFFD*2:1\uFFFD|\uFFFD*2:2\uFFFD|\uFFFD*1:3\uFFFD]",
- "closeTagNgTemplate": "[\uFFFD/*1:3\uFFFD|\uFFFD/*2:2\uFFFD|\uFFFD/*2:1\uFFFD]",
- "interpolation": "\uFFFD0:1\uFFFD",
- "interpolation_1": "\uFFFD0:2\uFFFD",
- "interpolation_2": "\uFFFD0:3\uFFFD"
- });
- $I18N_0$ = $MSG_EXTERNAL_2051477021417799640$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \`$` +
- 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
- `{"[\uFFFD*2:1\uFFFD|\uFFFD*2:2\uFFFD|\uFFFD*1:3\uFFFD]"}:START_TAG_NG_TEMPLATE: Template B: $` +
- String.raw`{"\uFFFD0:2\uFFFD"}:INTERPOLATION_1: $` + String.raw
- `{"[\uFFFD*2:1\uFFFD|\uFFFD*2:2\uFFFD|\uFFFD*1:3\uFFFD]"}:START_TAG_NG_TEMPLATE: Template C: $` +
- String.raw`{"\uFFFD0:3\uFFFD"}:INTERPOLATION_2: $` + String.raw
- `{"[\uFFFD/*1:3\uFFFD|\uFFFD/*2:2\uFFFD|\uFFFD/*2:1\uFFFD]"}:CLOSE_TAG_NG_TEMPLATE:$` +
- String.raw
- `{"[\uFFFD/*1:3\uFFFD|\uFFFD/*2:2\uFFFD|\uFFFD/*2:1\uFFFD]"}:CLOSE_TAG_NG_TEMPLATE:$` +
- String.raw
- `{"[\uFFFD/*1:3\uFFFD|\uFFFD/*2:2\uFFFD|\uFFFD/*2:1\uFFFD]"}:CLOSE_TAG_NG_TEMPLATE:\`;
- }
- $I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$);
+ ${i18n_0}
function MyComponent_ng_template_2_Template(rf, ctx) {
if (rf & 1) {
- $r3$.ɵɵi18nStart(0, $I18N_0$, 1);
+ $r3$.ɵɵi18nStart(0, $i18n_0$, 1);
$r3$.ɵɵpipe(1, "uppercase");
$r3$.ɵɵtemplate(2, MyComponent_ng_template_2_ng_template_2_Template, 2, 1, "ng-template");
$r3$.ɵɵi18nEnd();
@@ -2419,7 +2053,7 @@ describe('i18n support in the template compiler', () => {
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18nStart(1, $I18N_0$);
+ $r3$.ɵɵi18nStart(1, $i18n_0$);
$r3$.ɵɵtemplate(2, MyComponent_ng_template_2_Template, 3, 3, "ng-template");
$r3$.ɵɵi18nEnd();
$r3$.ɵɵelementEnd();
@@ -2436,29 +2070,16 @@ describe('i18n support in the template compiler', () => {
{age, select, 10 {ten} 20 {twenty} other {other}}
`;
+ const i18n_0 = i18nIcuMsg(
+ '{VAR_SELECT, select, male {male} female {female} other {other}}',
+ [['VAR_SELECT', String.raw`\uFFFD0\uFFFD`]]);
+ const i18n_1 = i18nIcuMsg(
+ '{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}',
+ [['VAR_SELECT', String.raw`\uFFFD0\uFFFD`]]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}");
- $I18N_0$ = $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \`{VAR_SELECT, select, male {male} female {female} other {other}}\`;
- }
- $I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
- "VAR_SELECT": "\uFFFD0\uFFFD"
- });
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS__1$ = goog.getMsg("{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}");
- $I18N_1$ = $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS__1$;
- }
- else {
- $I18N_1$ = $localize \`{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}\`;
- }
- $I18N_1$ = $r3$.ɵɵi18nPostprocess($I18N_1$, {
- "VAR_SELECT": "\uFFFD0\uFFFD"
- });
+ ${i18n_0}
+ ${i18n_1}
function MyComponent_ng_template_2_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵi18n(0, $I18N_1$);
@@ -2475,7 +2096,7 @@ describe('i18n support in the template compiler', () => {
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementContainerStart(0);
- $r3$.ɵɵi18n(1, $I18N_0$);
+ $r3$.ɵɵi18n(1, $i18n_0$);
$r3$.ɵɵelementContainerEnd();
$r3$.ɵɵtemplate(2, MyComponent_ng_template_2_Template, 1, 1, "ng-template");
}
@@ -2500,32 +2121,17 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nMsg(
+ '{$tagImg} is my logo #1 ', [['tagImg', String.raw`\uFFFD#2\uFFFD\uFFFD/#2\uFFFD`]]);
+ const i18n_1 = i18nMsg(
+ '{$tagImg} is my logo #2 ', [['tagImg', String.raw`\uFFFD#1\uFFFD\uFFFD/#1\uFFFD`]]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_4891196282781544695$$APP_SPEC_TS_0$ = goog.getMsg("{$tagImg} is my logo #1 ", {
- "tagImg": "\uFFFD#2\uFFFD\uFFFD/#2\uFFFD"
- });
- $I18N_0$ = $MSG_EXTERNAL_4891196282781544695$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \`$` +
- String.raw`{"\uFFFD#2\uFFFD\uFFFD/#2\uFFFD"}:TAG_IMG: is my logo #1 \`;
- }
- var $I18N_2$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_461986953980355147$$APP_SPEC_TS__2$ = goog.getMsg("{$tagImg} is my logo #2 ", {
- "tagImg": "\uFFFD#1\uFFFD\uFFFD/#1\uFFFD"
- });
- $I18N_2$ = $MSG_EXTERNAL_461986953980355147$$APP_SPEC_TS__2$;
- }
- else {
- $I18N_2$ = $localize \`$` +
- String.raw`{"\uFFFD#1\uFFFD\uFFFD/#1\uFFFD"}:TAG_IMG: is my logo #2 \`;
- }
+ ${i18n_0}
+ ${i18n_1}
function MyComponent_ng_template_3_Template(rf, ctx) {
if (rf & 1) {
- $r3$.ɵɵi18nStart(0, $I18N_2$);
+ $r3$.ɵɵi18nStart(0, $i18n_1$);
$r3$.ɵɵelement(1, "img", 0);
$r3$.ɵɵi18nEnd();
}
@@ -2535,7 +2141,7 @@ describe('i18n support in the template compiler', () => {
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementContainerStart(0);
- $r3$.ɵɵi18nStart(1, $I18N_0$);
+ $r3$.ɵɵi18nStart(1, $i18n_0$);
$r3$.ɵɵelement(2, "img", 0);
$r3$.ɵɵi18nEnd();
$r3$.ɵɵelementContainerEnd();
@@ -2557,23 +2163,11 @@ describe('i18n support in the template compiler', () => {
`;
- const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_8537814667662432133$$APP_SPEC_TS__0$ = goog.getMsg(" Root content {$startTagNgContainer} Nested content {$closeTagNgContainer}", {
- "startTagNgContainer": "\uFFFD*1:1\uFFFD\uFFFD#1:1\uFFFD",
- "closeTagNgContainer": "\uFFFD/#1:1\uFFFD\uFFFD/*1:1\uFFFD"
- });
- $I18N_0$ = $MSG_EXTERNAL_8537814667662432133$$APP_SPEC_TS__0$;
- }
- else {
- $I18N_0$ = $localize \` 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:\`;
- }
- …
- `;
+ const output =
+ i18nMsg(' Root content {$startTagNgContainer} Nested content {$closeTagNgContainer}', [
+ ['startTagNgContainer', String.raw`\uFFFD*1:1\uFFFD\uFFFD#1:1\uFFFD`],
+ ['closeTagNgContainer', String.raw`\uFFFD/#1:1\uFFFD\uFFFD/*1:1\uFFFD`]
+ ]);
verify(input, output);
});
@@ -2586,25 +2180,10 @@ describe('i18n support in the template compiler', () => {
// TODO(FW-635): currently we generate unique consts for each i18n block even though it
// might contain the same content. This should be optimized by translation statements caching,
- // that can be implemented in the future within FW-635.
+ // that can be implemented in the future.
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_6563391987554512024$$APP_SPEC_TS_0$ = goog.getMsg("Test");
- $I18N_0$ = $MSG_EXTERNAL_6563391987554512024$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \`Test\`;
- }
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_6563391987554512024$$APP_SPEC_TS_1$ = goog.getMsg("Test");
- $I18N_1$ = $MSG_EXTERNAL_6563391987554512024$$APP_SPEC_TS_1$;
- }
- else {
- $I18N_1$ = $localize \`Test\`;
- }
- …
+ ${i18nMsg('Test')}
+ ${i18nMsg('Test')}
`;
verify(input, output);
@@ -2617,24 +2196,20 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nMsg(' Hello {$startTagNgContainer}there{$closeTagNgContainer}', [
+ ['startTagNgContainer', String.raw`\uFFFD#2\uFFFD`],
+ ['closeTagNgContainer', String.raw`\uFFFD/#2\uFFFD`]
+ ]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_APP_SPEC_TS_1$ = goog.getMsg(" Hello {$startTagNgContainer}there{$closeTagNgContainer}", { "startTagNgContainer": "\uFFFD#2\uFFFD", "closeTagNgContainer": "\uFFFD/#2\uFFFD" });
- $I18N_0$ = $MSG_APP_SPEC_TS_1$;
- }
- else {
- $I18N_0$ = $localize \` Hello $` +
- String.raw`{"\uFFFD#2\uFFFD"}:START_TAG_NG_CONTAINER:there$` +
- String.raw`{"\uFFFD/#2\uFFFD"}:CLOSE_TAG_NG_CONTAINER:\`;
- }
+ ${i18n_0}
…
decls: 3,
vars: 0,
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18nStart(1, I18N_0);
+ $r3$.ɵɵi18nStart(1, $i18n_0$);
$r3$.ɵɵelementContainer(2);
$r3$.ɵɵi18nEnd();
$r3$.ɵɵelementEnd();
@@ -2653,19 +2228,17 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nMsg(
+ ' Hello {$startTagNgContainer}there {$startTagStrong}!{$closeTagStrong}{$closeTagNgContainer}',
+ [
+ ['startTagNgContainer', String.raw`\uFFFD#2\uFFFD`],
+ ['startTagStrong', String.raw`\uFFFD#3\uFFFD`],
+ ['closeTagStrong', String.raw`\uFFFD/#3\uFFFD`],
+ ['closeTagNgContainer', String.raw`\uFFFD/#2\uFFFD`]
+ ]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_APP_SPEC_TS_1$ = goog.getMsg(" Hello {$startTagNgContainer}there {$startTagStrong}!{$closeTagStrong}{$closeTagNgContainer}", { "startTagNgContainer": "\uFFFD#2\uFFFD", "startTagStrong": "\uFFFD#3\uFFFD", "closeTagStrong": "\uFFFD/#3\uFFFD", "closeTagNgContainer": "\uFFFD/#2\uFFFD" });
- $I18N_0$ = $MSG_APP_SPEC_TS_1$;
- }
- else {
- $I18N_0$ = $localize \` 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:$` +
- String.raw`{"\uFFFD/#2\uFFFD"}:CLOSE_TAG_NG_CONTAINER:\`;
- }
+ ${i18n_0}
…
decls: 4,
vars: 0,
@@ -2685,25 +2258,22 @@ describe('i18n support in the template compiler', () => {
verify(input, output);
});
- // Note: applying structural directives to is typically user error, but it is
- // technically allowed, so we need to support it.
+ // Note: applying structural directives to is typically user error,
+ // but it is technically allowed, so we need to support it.
it('should handle structural directives', () => {
const input = `
Content A
Content B
`;
+ const i18n_0 = i18nMsg('Content A');
+ const i18n_1 = i18nMsg('Content B');
+
const output = String.raw`
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- 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_0}
function MyComponent_0_ng_template_0_Template(rf, ctx) {
if (rf & 1) {
- $r3$.ɵɵi18n(0, $I18N_1$);
+ $r3$.ɵɵi18n(0, $i18n_0$);
}
}
function MyComponent_0_Template(rf, ctx) {
@@ -2711,17 +2281,11 @@ describe('i18n support in the template compiler', () => {
$r3$.ɵɵtemplate(0, MyComponent_0_ng_template_0_Template, 1, 0, "ng-template");
}
}
- var $I18N_3$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- 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_1}
function MyComponent_ng_container_1_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementContainerStart(0);
- $r3$.ɵɵi18n(1, $I18N_3$);
+ $r3$.ɵɵi18n(1, $i18n_1$);
$r3$.ɵɵelementContainerEnd();
}
}
@@ -2754,6 +2318,8 @@ describe('i18n support in the template compiler', () => {
`;
+ // Keeping raw content (avoiding `i18nMsg`) to illustrate message layout
+ // in case of whitespace preserving mode.
const output = String.raw`
var $I18N_0$;
if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
@@ -2795,18 +2361,12 @@ describe('i18n support in the template compiler', () => {
{gender, select, male {male} female {female} other {other}}
`;
+ const i18n_0 = i18nIcuMsg(
+ '{VAR_SELECT, select, male {male} female {female} other {other}}',
+ [['VAR_SELECT', String.raw`\uFFFD0\uFFFD`]]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}");
- $I18N_0$ = $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \`{VAR_SELECT, select, male {male} female {female} other {other}}\`;
- }
- $I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
- "VAR_SELECT": "\uFFFD0\uFFFD"
- });
+ ${i18n_0}
…
decls: 2,
vars: 1,
@@ -2854,24 +2414,18 @@ describe('i18n support in the template compiler', () => {
{age, select, 10 {ten} 20 {twenty} other {other}}
`;
+ const i18n_0 = i18nIcuMsg(
+ '{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}',
+ [['VAR_SELECT', String.raw`\uFFFD0\uFFFD`]]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}");
- $I18N_0$ = $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \`{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}\`;
- }
- $I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
- "VAR_SELECT": "\uFFFD0\uFFFD"
- });
+ ${i18n_0}
…
decls: 1,
vars: 1,
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
- $r3$.ɵɵi18n(0, $I18N_0$);
+ $r3$.ɵɵi18n(0, $i18n_0$);
}
if (rf & 2) {
$r3$.ɵɵi18nExp(ctx.age);
@@ -2894,34 +2448,25 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nIcuMsg(
+ '{VAR_SELECT, select, male {male} female {female} other {other}}',
+ [['VAR_SELECT', String.raw`\uFFFD0\uFFFD`]]);
+ const i18n_1 = i18nIcuMsg(
+ '{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}',
+ [['VAR_SELECT', String.raw`\uFFFD0\uFFFD`]]);
+ const i18n_2 = i18nIcuMsg(
+ '{VAR_SELECT, select, 0 {no emails} 1 {one email} other {{INTERPOLATION} emails}}', [
+ ['VAR_SELECT', String.raw`\uFFFD0\uFFFD`], ['INTERPOLATION', String.raw`\uFFFD1\uFFFD`]
+ ]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}");
- $I18N_0$ = $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \`{VAR_SELECT, select, male {male} female {female} other {other}}\`;
- }
- $I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
- "VAR_SELECT": "\uFFFD0\uFFFD"
- });
- var $I18N_3$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS__3$ = goog.getMsg("{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}");
- $I18N_3$ = $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS__3$;
- }
- else {
- $I18N_3$ = $localize \`{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}\`;
- }
- $I18N_3$ = $r3$.ɵɵi18nPostprocess($I18N_3$, {
- "VAR_SELECT": "\uFFFD0\uFFFD"
- });
+ ${i18n_0}
+ ${i18n_1}
function MyComponent_div_2_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div", 2);
$r3$.ɵɵtext(1, " ");
- $r3$.ɵɵi18n(2, $I18N_3$);
+ $r3$.ɵɵi18n(2, $i18n_1$);
$r3$.ɵɵtext(3, " ");
$r3$.ɵɵelementEnd();
}
@@ -2932,23 +2477,12 @@ describe('i18n support in the template compiler', () => {
$r3$.ɵɵi18nApply(2);
}
}
- var $I18N_5$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_1922743304863699161$$APP_SPEC_TS__5$ = goog.getMsg("{VAR_SELECT, select, 0 {no emails} 1 {one email} other {{INTERPOLATION} emails}}");
- $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$ = $r3$.ɵɵi18nPostprocess($I18N_5$, {
- "VAR_SELECT": "\uFFFD0\uFFFD",
- "INTERPOLATION": "\uFFFD1\uFFFD"
- });
+ ${i18n_2}
function MyComponent_div_3_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div", 3);
$r3$.ɵɵtext(1, " You have ");
- $r3$.ɵɵi18n(2, $I18N_5$);
+ $r3$.ɵɵi18n(2, $i18n_2$);
$r3$.ɵɵtext(3, ". ");
$r3$.ɵɵelementEnd();
}
@@ -2968,7 +2502,7 @@ describe('i18n support in the template compiler', () => {
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18n(1, $I18N_0$);
+ $r3$.ɵɵi18n(1, $i18n_0$);
$r3$.ɵɵelementEnd();
$r3$.ɵɵtemplate(2, MyComponent_div_2_Template, 4, 1, "div", 0);
$r3$.ɵɵtemplate(3, MyComponent_div_3_Template, 4, 2, "div", 1);
@@ -2993,24 +2527,18 @@ describe('i18n support in the template compiler', () => {
{age, select, 10 {ten} 20 {twenty} other {{% other %}}}
`;
+ const i18n_0 =
+ i18nIcuMsg('{VAR_SELECT, select, 10 {ten} 20 {twenty} other {{INTERPOLATION}}}', [
+ ['VAR_SELECT', String.raw`\uFFFD0\uFFFD`], ['INTERPOLATION', String.raw`\uFFFD1\uFFFD`]
+ ]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_2949673783721159566$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, 10 {ten} 20 {twenty} other {{INTERPOLATION}}}");
- $I18N_0$ = $MSG_EXTERNAL_2949673783721159566$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \`{VAR_SELECT, select, 10 {ten} 20 {twenty} other {{INTERPOLATION}}}\`;
- }
- $I18N_0$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
- "VAR_SELECT": "\uFFFD0\uFFFD",
- "INTERPOLATION": "\uFFFD1\uFFFD"
- });
+ ${i18n_0}
…
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18n(1, $I18N_0$);
+ $r3$.ɵɵi18n(1, $i18n_0$);
$r3$.ɵɵelementEnd();
}
if (rf & 2) {
@@ -3033,47 +2561,33 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nIcuMsg(
+ '{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}}}',
+ [
+ ['VAR_SELECT', String.raw`\uFFFD0\uFFFD`],
+ ['START_BOLD_TEXT', ''],
+ ['CLOSE_BOLD_TEXT', ''],
+ ['START_ITALIC_TEXT', ''],
+ ['CLOSE_ITALIC_TEXT', ''],
+ ['START_TAG_DIV', ''],
+ ['CLOSE_TAG_DIV', '
'],
+ ]);
+
+ const i18n_1 = i18nMsg(
+ ' {$icu} {$startBoldText}Other content{$closeBoldText}{$startTagDiv}{$startItalicText}Another content{$closeItalicText}{$closeTagDiv}',
+ [
+ ['startBoldText', String.raw`\uFFFD#2\uFFFD`],
+ ['closeBoldText', String.raw`\uFFFD/#2\uFFFD`],
+ ['startTagDiv', String.raw`\uFFFD#3\uFFFD`],
+ ['startItalicText', String.raw`\uFFFD#4\uFFFD`],
+ ['closeItalicText', String.raw`\uFFFD/#4\uFFFD`],
+ ['closeTagDiv', String.raw`\uFFFD/#3\uFFFD`],
+ ['icu', '$I18N_0$'],
+ ]);
+
const output = String.raw`
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_2417296354340576868$$APP_SPEC_TS_1$ = goog.getMsg("{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$ = $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$ = $r3$.ɵɵi18nPostprocess($I18N_1$, {
- "VAR_SELECT": "\uFFFD0\uFFFD",
- "START_BOLD_TEXT": "",
- "CLOSE_BOLD_TEXT": "",
- "START_ITALIC_TEXT": "",
- "CLOSE_ITALIC_TEXT": "",
- "START_TAG_DIV": "",
- "CLOSE_TAG_DIV": "
"
- });
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_5791551881115084301$$APP_SPEC_TS_0$ = goog.getMsg(" {$icu} {$startBoldText}Other content{$closeBoldText}{$startTagDiv}{$startItalicText}Another content{$closeItalicText}{$closeTagDiv}", {
- "startBoldText": "\uFFFD#2\uFFFD",
- "closeBoldText": "\uFFFD/#2\uFFFD",
- "startTagDiv": "\uFFFD#3\uFFFD",
- "startItalicText": "\uFFFD#4\uFFFD",
- "closeItalicText": "\uFFFD/#4\uFFFD",
- "closeTagDiv": "\uFFFD/#3\uFFFD",
- "icu": $I18N_1$
- });
- $I18N_0$ = $MSG_EXTERNAL_5791551881115084301$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \` $` +
- String.raw`{$I18N_1$}:ICU: $` +
- String.raw`{"\uFFFD#2\uFFFD"}:START_BOLD_TEXT:Other content$` +
- String.raw`{"\uFFFD/#2\uFFFD"}:CLOSE_BOLD_TEXT:$` +
- String.raw`{"\uFFFD#3\uFFFD"}:START_TAG_DIV:$` +
- String.raw`{"\uFFFD#4\uFFFD"}:START_ITALIC_TEXT:Another content$` +
- String.raw`{"\uFFFD/#4\uFFFD"}:CLOSE_ITALIC_TEXT:$` +
- String.raw`{"\uFFFD/#3\uFFFD"}:CLOSE_TAG_DIV:\`;
- }
+ ${i18n_0}
+ ${i18n_1}
…
decls: 5,
vars: 1,
@@ -3081,7 +2595,7 @@ describe('i18n support in the template compiler', () => {
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18nStart(1, $I18N_0$);
+ $r3$.ɵɵi18nStart(1, $i18n_1$);
$r3$.ɵɵelement(2, "b");
$r3$.ɵɵelementStart(3, "div", 0);
$r3$.ɵɵelement(4, "i");
@@ -3105,26 +2619,22 @@ describe('i18n support in the template compiler', () => {
{gender, select, male {male of age: {{ ageA + ageB + ageC }}} female {female} other {other}}
`;
+ const i18n_0 = i18nIcuMsg(
+ '{VAR_SELECT, select, male {male of age: {INTERPOLATION}} female {female} other {other}}',
+ [
+ ['VAR_SELECT', String.raw`\uFFFD0\uFFFD`],
+ ['INTERPOLATION', String.raw`\uFFFD1\uFFFD`],
+ ]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_6879461626778511059$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, male {male of age: {INTERPOLATION}} female {female} other {other}}");
- $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$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
- "VAR_SELECT": "\uFFFD0\uFFFD",
- "INTERPOLATION": "\uFFFD1\uFFFD"
- });
+ ${i18n_0}
…
decls: 2,
vars: 2,
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18n(1, $I18N_0$);
+ $r3$.ɵɵi18n(1, $i18n_0$);
$r3$.ɵɵelementEnd();
}
if (rf & 2) {
@@ -3146,48 +2656,28 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nIcuMsg(
+ '{VAR_SELECT, select, male {male} female {female} other {other}}',
+ [['VAR_SELECT', String.raw`\uFFFD0\uFFFD`]]);
+ const i18n_1 = i18nIcuMsg(
+ '{VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other}}',
+ [['VAR_SELECT', String.raw`\uFFFD1\uFFFD`]]);
+ const i18n_2 = i18nMsg(' {$icu} {$icu_1} ', [
+ ['icu', '$i18n_0$'],
+ ['icu_1', '$i18n_1$'],
+ ]);
+
const output = String.raw`
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_1$ = goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}");
- $I18N_1$ = $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_1$;
- }
- else {
- $I18N_1$ = $localize \`{VAR_SELECT, select, male {male} female {female} other {other}}\`;
- }
- $I18N_1$ = $r3$.ɵɵi18nPostprocess($I18N_1$, {
- "VAR_SELECT": "\uFFFD0\uFFFD"
- });
- var $I18N_2$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_7068143081688428291$$APP_SPEC_TS_2$ = goog.getMsg("{VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other}}");
- $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$ = $r3$.ɵɵi18nPostprocess($I18N_2$, {
- "VAR_SELECT": "\uFFFD1\uFFFD"
- });
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_2967249209167308918$$APP_SPEC_TS_0$ = goog.getMsg(" {$icu} {$icu_1} ", {
- "icu": $I18N_1$,
- "icu_1": $I18N_2$
- });
- $I18N_0$ = $MSG_EXTERNAL_2967249209167308918$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \` $` +
- String.raw`{$I18N_1$}:ICU: $` + String.raw`{$I18N_2$}:ICU_1: \`;
- }
+ ${i18n_0}
+ ${i18n_1}
+ ${i18n_2}
…
decls: 2,
vars: 2,
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18n(1, $I18N_0$);
+ $r3$.ɵɵi18n(1, $i18n_2$);
$r3$.ɵɵelementEnd();
}
if (rf & 2) {
@@ -3306,9 +2796,9 @@ describe('i18n support in the template compiler', () => {
}
`;
- // TODO(akushnir): this use-case is currently supported with
+ // TODO(FW-635): this use-case is currently supported with
// file-based prefix for translation const names. Translation statements
- // caching is required to support this use-case (FW-635) with id-based consts.
+ // caching is required to support this use-case with id-based consts.
verify(input, output, {skipIdBasedCheck: true});
});
@@ -3323,34 +2813,21 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nIcuMsg(
+ '{VAR_SELECT_1, select, male {male of age: {VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other}}} female {female} other {other}}',
+ [['VAR_SELECT', String.raw`\uFFFD0\uFFFD`], ['VAR_SELECT_1', String.raw`\uFFFD1\uFFFD`]]);
+ const i18n_1 = i18nMsg(' {$icu} ', [['icu', '$i18n_0$']]);
+
const output = String.raw`
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_343563413083115114$$APP_SPEC_TS_0$ = goog.getMsg("{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$ = $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$ = $r3$.ɵɵi18nPostprocess($I18N_1$, {
- "VAR_SELECT": "\uFFFD0\uFFFD",
- "VAR_SELECT_1": "\uFFFD1\uFFFD"
- });
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_3052001905251380936$$APP_SPEC_TS_3$ = goog.getMsg(" {$icu} ", { "icu": $I18N_1$ });
- $I18N_0$ = $MSG_EXTERNAL_3052001905251380936$$APP_SPEC_TS_3$;
- }
- else {
- $I18N_0$ = $localize \` $` +
- String.raw`{$I18N_1$}:ICU: \`;
- } …
+ ${i18n_0}
+ ${i18n_1}
+ …
decls: 2,
vars: 2,
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18n(1, $I18N_0$);
+ $r3$.ɵɵi18n(1, $i18n_1$);
$r3$.ɵɵelementEnd();
}
if (rf & 2) {
@@ -3379,27 +2856,23 @@ describe('i18n support in the template compiler', () => {
}
`;
+ const i18n_0 = i18nIcuMsg(
+ '{VAR_PLURAL, plural, =0 {zero} =2 {{INTERPOLATION} {VAR_SELECT, select, cat {cats} dog {dogs} other {animals}} !} other {other - {INTERPOLATION}}}',
+ [
+ ['VAR_SELECT', String.raw`\uFFFD0\uFFFD`],
+ ['VAR_PLURAL', String.raw`\uFFFD1\uFFFD`],
+ ['INTERPOLATION', String.raw`\uFFFD2\uFFFD`],
+ ]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_6870293071705078389$$APP_SPEC_TS_1$ = goog.getMsg("{VAR_PLURAL, plural, =0 {zero} =2 {{INTERPOLATION} {VAR_SELECT, select, cat {cats} dog {dogs} other {animals}} !} other {other - {INTERPOLATION}}}");
- $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$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
- "VAR_SELECT": "\uFFFD0\uFFFD",
- "VAR_PLURAL": "\uFFFD1\uFFFD",
- "INTERPOLATION": "\uFFFD2\uFFFD"
- });
+ ${i18n_0}
…
decls: 2,
vars: 3,
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18n(1, $I18N_0$);
+ $r3$.ɵɵi18n(1, $i18n_0$);
$r3$.ɵɵelementEnd();
}
if (rf & 2) {
@@ -3423,49 +2896,27 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nIcuMsg(
+ '{VAR_SELECT, select, male {male} female {female} other {other}}',
+ [['VAR_SELECT', String.raw`\uFFFD0\uFFFD`]]);
+ const i18n_1 = i18nIcuMsg(
+ '{VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other}}',
+ [['VAR_SELECT', String.raw`\uFFFD0:1\uFFFD`]]);
+ const i18n_2 = i18nMsg(' {$icu} {$startTagSpan} {$icu_1} {$closeTagSpan}', [
+ ['startTagSpan', String.raw`\uFFFD*2:1\uFFFD\uFFFD#1:1\uFFFD`],
+ ['closeTagSpan', String.raw`\uFFFD/#1:1\uFFFD\uFFFD/*2:1\uFFFD`],
+ ['icu', '$i18n_0$'],
+ ['icu_1', '$i18n_1$'],
+ ]);
+
const output = String.raw`
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_1$ = goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}");
- $I18N_1$ = $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_1$;
- }
- else {
- $I18N_1$ = $localize \`{VAR_SELECT, select, male {male} female {female} other {other}}\`;
- }
- $I18N_1$ = $r3$.ɵɵi18nPostprocess($I18N_1$, {
- "VAR_SELECT": "\uFFFD0\uFFFD"
- });
- var $I18N_3$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_7068143081688428291$$APP_SPEC_TS__3$ = goog.getMsg("{VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other}}");
- $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$ = $r3$.ɵɵi18nPostprocess($I18N_3$, {
- "VAR_SELECT": "\uFFFD0:1\uFFFD"
- });
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_1194472282609532229$$APP_SPEC_TS_0$ = goog.getMsg(" {$icu} {$startTagSpan} {$icu_1} {$closeTagSpan}", {
- "startTagSpan": "\uFFFD*2:1\uFFFD\uFFFD#1:1\uFFFD",
- "closeTagSpan": "\uFFFD/#1:1\uFFFD\uFFFD/*2:1\uFFFD",
- "icu": $I18N_1$,
- "icu_1": $I18N_3$
- });
- $I18N_0$ = $MSG_EXTERNAL_1194472282609532229$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \` $` +
- String.raw`{$I18N_1$}:ICU: $` +
- String.raw`{"\uFFFD*2:1\uFFFD\uFFFD#1:1\uFFFD"}:START_TAG_SPAN: $` +
- String.raw`{$I18N_3$}:ICU_1: $` +
- String.raw`{"\uFFFD/#1:1\uFFFD\uFFFD/*2:1\uFFFD"}:CLOSE_TAG_SPAN:\`;
- }
+ ${i18n_0}
+ ${i18n_1}
+ ${i18n_2}
+ …
function MyComponent_span_2_Template(rf, ctx) {
if (rf & 1) {
- $r3$.ɵɵi18nStart(0, $I18N_0$, 1);
+ $r3$.ɵɵi18nStart(0, $i18n_2$, 1);
$r3$.ɵɵelement(1, "span");
$r3$.ɵɵi18nEnd();
}
@@ -3483,7 +2934,7 @@ describe('i18n support in the template compiler', () => {
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18nStart(1, $I18N_0$);
+ $r3$.ɵɵi18nStart(1, $i18n_2$);
$r3$.ɵɵtemplate(2, MyComponent_span_2_Template, 2, 1, "span", 0);
$r3$.ɵɵi18nEnd();
$r3$.ɵɵelementEnd();
@@ -3510,52 +2961,32 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nIcuMsg(
+ '{VAR_SELECT, select, male {male {INTERPOLATION}} female {female {INTERPOLATION_1}} other {other}}',
+ [
+ ['VAR_SELECT', String.raw`\uFFFD0\uFFFD`],
+ ['INTERPOLATION', String.raw`\uFFFD1\uFFFD`],
+ ['INTERPOLATION_1', String.raw`\uFFFD2\uFFFD`],
+ ]);
+ const i18n_1 = i18nIcuMsg(
+ '{VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other: {INTERPOLATION}}}', [
+ ['VAR_SELECT', String.raw`\uFFFD0:1\uFFFD`],
+ ['INTERPOLATION', String.raw`\uFFFD1:1\uFFFD`],
+ ]);
+ const i18n_2 = i18nMsg(' {$icu} {$startTagSpan} {$icu_1} {$closeTagSpan}', [
+ ['startTagSpan', String.raw`\uFFFD*2:1\uFFFD\uFFFD#1:1\uFFFD`],
+ ['closeTagSpan', String.raw`\uFFFD/#1:1\uFFFD\uFFFD/*2:1\uFFFD`],
+ ['icu', '$i18n_0$'],
+ ['icu_1', '$i18n_1$'],
+ ]);
+
const output = String.raw`
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_7825031864601787094$$APP_SPEC_TS_1$ = goog.getMsg("{VAR_SELECT, select, male {male {INTERPOLATION}} female {female {INTERPOLATION_1}} other {other}}");
- $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$ = $r3$.ɵɵi18nPostprocess($I18N_1$, {
- "VAR_SELECT": "\uFFFD0\uFFFD",
- "INTERPOLATION": "\uFFFD1\uFFFD",
- "INTERPOLATION_1": "\uFFFD2\uFFFD"
- });
- var $I18N_3$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_2310343208266678305$$APP_SPEC_TS__3$ = goog.getMsg("{VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other: {INTERPOLATION}}}");
- $I18N_3$ = $MSG_EXTERNAL_2310343208266678305$$APP_SPEC_TS__3$;
- }
- else {
- $I18N_4$ = $localize \`{VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other: {INTERPOLATION}}}\`;
- }
- $I18N_3$ = $r3$.ɵɵi18nPostprocess($I18N_3$, {
- "VAR_SELECT": "\uFFFD0:1\uFFFD",
- "INTERPOLATION": "\uFFFD1:1\uFFFD"
- });
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_7186042105600518133$$APP_SPEC_TS_0$ = goog.getMsg(" {$icu} {$startTagSpan} {$icu_1} {$closeTagSpan}", {
- "startTagSpan": "\uFFFD*2:1\uFFFD\uFFFD#1:1\uFFFD",
- "closeTagSpan": "\uFFFD/#1:1\uFFFD\uFFFD/*2:1\uFFFD",
- "icu": $I18N_1$,
- "icu_1": $I18N_3$
- });
- $I18N_0$ = $MSG_EXTERNAL_7186042105600518133$$APP_SPEC_TS_0$;
- }
- else {
- $I18N_0$ = $localize \` $` +
- String.raw`{I18N_1}:ICU: $` +
- String.raw`{"\uFFFD*2:1\uFFFD\uFFFD#1:1\uFFFD"}:START_TAG_SPAN: $` +
- String.raw`{I18N_3}:ICU_1: $` +
- String.raw`{"\uFFFD/#1:1\uFFFD\uFFFD/*2:1\uFFFD"}:CLOSE_TAG_SPAN:\`;
- }
+ ${i18n_0}
+ ${i18n_1}
+ ${i18n_2}
function MyComponent_span_2_Template(rf, ctx) {
if (rf & 1) {
- $r3$.ɵɵi18nStart(0, $I18N_0$, 1);
+ $r3$.ɵɵi18nStart(0, $i18n_2$, 1);
$r3$.ɵɵelement(1, "span");
$r3$.ɵɵi18nEnd();
}
@@ -3573,7 +3004,7 @@ describe('i18n support in the template compiler', () => {
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18nStart(1, $I18N_0$);
+ $r3$.ɵɵi18nStart(1, $i18n_2$);
$r3$.ɵɵtemplate(2, MyComponent_span_2_Template, 2, 2, "span", 0);
$r3$.ɵɵi18nEnd();
$r3$.ɵɵelementEnd();
@@ -3601,28 +3032,24 @@ describe('i18n support in the template compiler', () => {
}
`;
+ const i18n_0 = i18nIcuMsg(
+ '{VAR_SELECT, select, male {male {PH_A}} female {female {PH_B}} other {other {PH_WITH_SPACES}}}',
+ [
+ ['VAR_SELECT', String.raw`\uFFFD0\uFFFD`],
+ ['PH_A', String.raw`\uFFFD1\uFFFD`],
+ ['PH_B', String.raw`\uFFFD2\uFFFD`],
+ ['PH_WITH_SPACES', String.raw`\uFFFD3\uFFFD`],
+ ]);
+
const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_6318060397235942326$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, male {male {PH_A}} female {female {PH_B}} other {other {PH_WITH_SPACES}}}");
- $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$ = $r3$.ɵɵi18nPostprocess($I18N_0$, {
- "VAR_SELECT": "\uFFFD0\uFFFD",
- "PH_A": "\uFFFD1\uFFFD",
- "PH_B": "\uFFFD2\uFFFD",
- "PH_WITH_SPACES": "\uFFFD3\uFFFD"
- });
+ ${i18n_0}
…
decls: 2,
vars: 4,
template: function MyComponent_Template(rf, ctx) {
if (rf & 1) {
$r3$.ɵɵelementStart(0, "div");
- $r3$.ɵɵi18n(1, $I18N_0$);
+ $r3$.ɵɵi18n(1, $i18n_0$);
$r3$.ɵɵelementEnd();
}
if (rf & 2) {
@@ -3641,21 +3068,10 @@ describe('i18n support in the template compiler', () => {
{count, select, 1 {one} other {more than one}}
`;
- const output = String.raw`
- var $I18N_0$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- /**
- * @desc descA
- * @meaning meaningA
- */
- const $MSG_EXTERNAL_idA$$APP_SPEC_TS_1$ = goog.getMsg("{VAR_SELECT, select, 1 {one} other {more than one}}");
- $I18N_0$ = $MSG_EXTERNAL_idA$$APP_SPEC_TS_1$;
- }
- else {
- $I18N_0$ = $localize \`:meaningA|descA@@idA:{VAR_SELECT, select, 1 {one} other {more than one}}\`;
- }
- $I18N_0$ = i0.ɵɵi18nPostprocess($I18N_0$, { "VAR_SELECT": "\uFFFD0\uFFFD" });
- `;
+ const output = i18nMsgWithPostprocess(
+ '{VAR_SELECT, select, 1 {one} other {more than one}}', [],
+ {meaning: 'meaningA', desc: 'descA', id: 'idA'},
+ [['VAR_SELECT', String.raw`\uFFFD0\uFFFD`]]);
verify(input, output);
});
@@ -3669,25 +3085,16 @@ describe('i18n support in the template compiler', () => {
`;
+ const i18n_0 = i18nIcuMsg(
+ '{VAR_SELECT , select , 1 {one} other {more than one}}',
+ [['VAR_SELECT', String.raw`\uFFFD0\uFFFD`]]);
+ const i18n_1 = i18nIcuMsg(
+ '{VAR_PLURAL , plural , =1 {one} other {more than one}}',
+ [['VAR_PLURAL', String.raw`\uFFFD1\uFFFD`]]);
+
const output = String.raw`
- var $I18N_1$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_199763560911211963$$APP_SPEC_TS_2$ = goog.getMsg("{VAR_SELECT , select , 1 {one} other {more than one}}");
- $I18N_1$ = $MSG_EXTERNAL_199763560911211963$$APP_SPEC_TS_2$;
- }
- else {
- $I18N_1$ = $localize \`{VAR_SELECT , select , 1 {one} other {more than one}}\`;
- }
- $I18N_1$ = i0.ɵɵi18nPostprocess($I18N_1$, { "VAR_SELECT": "\uFFFD0\uFFFD" });
- var $I18N_3$;
- if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
- const $MSG_EXTERNAL_3383986062053865025$$APP_SPEC_TS_4$ = goog.getMsg("{VAR_PLURAL , plural , =1 {one} other {more than one}}");
- $I18N_3$ = $MSG_EXTERNAL_3383986062053865025$$APP_SPEC_TS_4$;
- }
- else {
- $I18N_3$ = $localize \`{VAR_PLURAL , plural , =1 {one} other {more than one}}\`;
- }
- $I18N_3$ = i0.ɵɵi18nPostprocess($I18N_3$, { "VAR_PLURAL": "\uFFFD1\uFFFD" });
+ ${i18n_0}
+ ${i18n_1}
`;
verify(input, output);