Skip to content

Commit e22a302

Browse files
ocombemhevery
authored andcommitted
feat(ivy): support for i18n & ICU expressions (angular#27101)
PR Close angular#27101
1 parent 92b0565 commit e22a302

25 files changed

+2775
-2332
lines changed

packages/compiler-cli/test/compliance/r3_view_compiler_i18n_spec.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,23 @@ describe('i18n support in the view compiler', () => {
8383
$r3$.ɵi18nEnd();
8484
$r3$.ɵelementEnd();
8585
$r3$.ɵelementStart(2, "div");
86-
$r3$.ɵi18nAttribute(3, $_c2$);
86+
$r3$.ɵi18nAttributes(3, $_c2$);
8787
$r3$.ɵtext(4, "Content B");
8888
$r3$.ɵelementEnd();
8989
$r3$.ɵelementStart(5, "div");
90-
$r3$.ɵi18nAttribute(6, $_c4$);
90+
$r3$.ɵi18nAttributes(6, $_c4$);
9191
$r3$.ɵtext(7, "Content C");
9292
$r3$.ɵelementEnd();
9393
$r3$.ɵelementStart(8, "div");
94-
$r3$.ɵi18nAttribute(9, $_c6$);
94+
$r3$.ɵi18nAttributes(9, $_c6$);
9595
$r3$.ɵtext(10, "Content D");
9696
$r3$.ɵelementEnd();
9797
$r3$.ɵelementStart(11, "div");
98-
$r3$.ɵi18nAttribute(12, $_c8$);
98+
$r3$.ɵi18nAttributes(12, $_c8$);
9999
$r3$.ɵtext(13, "Content E");
100100
$r3$.ɵelementEnd();
101101
$r3$.ɵelementStart(14, "div");
102-
$r3$.ɵi18nAttribute(15, $_c10$);
102+
$r3$.ɵi18nAttributes(15, $_c10$);
103103
$r3$.ɵtext(16, "Content F");
104104
$r3$.ɵelementEnd();
105105
}
@@ -142,7 +142,7 @@ describe('i18n support in the view compiler', () => {
142142
template: function MyComponent_Template(rf, ctx) {
143143
if (rf & 1) {
144144
$r3$.ɵelementStart(0, "div", $_c0$);
145-
$r3$.ɵi18nAttribute(1, $_c2$);
145+
$r3$.ɵi18nAttributes(1, $_c2$);
146146
$r3$.ɵelementEnd();
147147
}
148148
}
@@ -207,10 +207,10 @@ describe('i18n support in the view compiler', () => {
207207
if (rf & 1) {
208208
$r3$.ɵelementStart(0, "div", $_c0$);
209209
$r3$.ɵpipe(1, "uppercase");
210-
$r3$.ɵi18nAttribute(2, $_c4$);
210+
$r3$.ɵi18nAttributes(2, $_c4$);
211211
$r3$.ɵelementEnd();
212212
$r3$.ɵelementStart(3, "div", $_c5$);
213-
$r3$.ɵi18nAttribute(4, $_c8$);
213+
$r3$.ɵi18nAttributes(4, $_c8$);
214214
$r3$.ɵelementEnd();
215215
}
216216
if (rf & 2) {
@@ -265,7 +265,7 @@ describe('i18n support in the view compiler', () => {
265265
$r3$.ɵelementStart(0, "div");
266266
$r3$.ɵelementStart(1, "div");
267267
$r3$.ɵpipe(2, "uppercase");
268-
$r3$.ɵi18nAttribute(3, $_c2$);
268+
$r3$.ɵi18nAttributes(3, $_c2$);
269269
$r3$.ɵelementEnd();
270270
$r3$.ɵelementEnd();
271271
}
@@ -345,10 +345,10 @@ describe('i18n support in the view compiler', () => {
345345
if (rf & 1) {
346346
$r3$.ɵelementStart(0, "div", $_c0$);
347347
$r3$.ɵpipe(1, "uppercase");
348-
$r3$.ɵi18nAttribute(2, $_c4$);
348+
$r3$.ɵi18nAttributes(2, $_c4$);
349349
$r3$.ɵelementEnd();
350350
$r3$.ɵelementStart(3, "div", $_c5$);
351-
$r3$.ɵi18nAttribute(4, $_c8$);
351+
$r3$.ɵi18nAttributes(4, $_c8$);
352352
$r3$.ɵelementEnd();
353353
}
354354
if (rf & 2) {
@@ -403,7 +403,7 @@ describe('i18n support in the view compiler', () => {
403403
$r3$.ɵelementStart(0, "div");
404404
$r3$.ɵelementStart(1, "div");
405405
$r3$.ɵpipe(2, "uppercase");
406-
$r3$.ɵi18nAttribute(3, $_c2$);
406+
$r3$.ɵi18nAttributes(3, $_c2$);
407407
$r3$.ɵelementEnd();
408408
$r3$.ɵelementEnd();
409409
}
@@ -693,15 +693,15 @@ describe('i18n support in the view compiler', () => {
693693
$r3$.ɵelementStart(0, "div");
694694
$r3$.ɵi18nStart(1, $MSG_APP_SPEC_TS_0$);
695695
$r3$.ɵelementStart(2, "span");
696-
$r3$.ɵi18nAttribute(3, $_c2$);
696+
$r3$.ɵi18nAttributes(3, $_c2$);
697697
$r3$.ɵelementEnd();
698698
$r3$.ɵi18nEnd();
699699
$r3$.ɵelementEnd();
700700
$r3$.ɵelementStart(4, "div");
701701
$r3$.ɵi18nStart(5, $MSG_APP_SPEC_TS_3$);
702702
$r3$.ɵpipe(6, "uppercase");
703703
$r3$.ɵelementStart(7, "span");
704-
$r3$.ɵi18nAttribute(8, $_c5$);
704+
$r3$.ɵi18nAttributes(8, $_c5$);
705705
$r3$.ɵelementEnd();
706706
$r3$.ɵi18nEnd();
707707
$r3$.ɵelementEnd();

packages/compiler/src/render3/r3_identifiers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class Identifiers {
9595
static pipeBind4: o.ExternalReference = {name: 'ɵpipeBind4', moduleName: CORE};
9696
static pipeBindV: o.ExternalReference = {name: 'ɵpipeBindV', moduleName: CORE};
9797

98-
static i18nAttribute: o.ExternalReference = {name: 'ɵi18nAttribute', moduleName: CORE};
98+
static i18nAttributes: o.ExternalReference = {name: 'ɵi18nAttributes', moduleName: CORE};
9999
static i18nExp: o.ExternalReference = {name: 'ɵi18nExp', moduleName: CORE};
100100
static i18nStart: o.ExternalReference = {name: 'ɵi18nStart', moduleName: CORE};
101101
static i18nEnd: o.ExternalReference = {name: 'ɵi18nEnd', moduleName: CORE};

packages/compiler/src/render3/view/template.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
490490
if (i18nAttrArgs.length) {
491491
const index: o.Expression = o.literal(this.allocateDataSlot());
492492
const args = this.constantPool.getConstLiteral(o.literalArr(i18nAttrArgs), true);
493-
this.creationInstruction(element.sourceSpan, R3.i18nAttribute, [index, args]);
493+
this.creationInstruction(element.sourceSpan, R3.i18nAttributes, [index, args]);
494494
if (hasBindings) {
495495
this.updateInstruction(element.sourceSpan, R3.i18nApply, [index]);
496496
}

packages/core/src/core_render3_private_export.ts

+2-14
Original file line numberDiff line numberDiff line change
@@ -108,24 +108,12 @@ export {
108108
PipeDef as ɵPipeDef,
109109
PipeDefWithMeta as ɵPipeDefWithMeta,
110110
whenRendered as ɵwhenRendered,
111-
i18nAttribute as ɵi18nAttribute,
111+
i18nAttributes as ɵi18nAttributes,
112112
i18nExp as ɵi18nExp,
113113
i18nStart as ɵi18nStart,
114114
i18nEnd as ɵi18nEnd,
115115
i18nApply as ɵi18nApply,
116-
i18nExpMapping as ɵi18nExpMapping,
117-
i18nInterpolation1 as ɵi18nInterpolation1,
118-
i18nInterpolation2 as ɵi18nInterpolation2,
119-
i18nInterpolation3 as ɵi18nInterpolation3,
120-
i18nInterpolation4 as ɵi18nInterpolation4,
121-
i18nInterpolation5 as ɵi18nInterpolation5,
122-
i18nInterpolation6 as ɵi18nInterpolation6,
123-
i18nInterpolation7 as ɵi18nInterpolation7,
124-
i18nInterpolation8 as ɵi18nInterpolation8,
125-
i18nInterpolationV as ɵi18nInterpolationV,
126-
i18nMapping as ɵi18nMapping,
127-
I18nInstruction as ɵI18nInstruction,
128-
I18nExpInstruction as ɵI18nExpInstruction,
116+
i18nIcuReplaceVars as ɵi18nIcuReplaceVars,
129117
WRAP_RENDERER_FACTORY2 as ɵWRAP_RENDERER_FACTORY2,
130118
setClassMetadata as ɵsetClassMetadata,
131119
} from './render3/index';

packages/core/src/render3/STATUS.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,12 @@ The goal is for the `@Component` (and friends) to be the compiler of template. S
205205
### I18N
206206
| Feature | Runtime | Spec | Compiler |
207207
| ----------------------------------- | ------- | -------- | -------- |
208-
| i18nStart | |||
209-
| i18nEnd | |||
210-
| i18nAttributes | |||
211-
| i18nExp | |||
212-
| i18nApply | |||
213-
| ICU expressions | |||
208+
| i18nStart | |||
209+
| i18nEnd | |||
210+
| i18nAttributes | |||
211+
| i18nExp | |||
212+
| i18nApply | |||
213+
| ICU expressions | |||
214214
| closure support for g3 ||||
215215
| runtime service for external world ||||
216216
| migration tool ||||

packages/core/src/render3/VIEW_DATA.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ For example index `123` may point to a component instance in the `LViewData` but
1111

1212
The layout is as such:
1313

14-
| Section | `LViewData` | `TView.data`
15-
| ---------- | --------------------------------------------- | --------------------------------------------------
16-
| `HEADER` | contextual data | mostly `null`
17-
| `CONSTS` | DOM, pipe, and local ref instances |
18-
| `VARS` | binding values | property names
19-
| `EXPANDO` | host bindings; directive instances; providers | host prop names; directive tokens; provider tokens
14+
| Section | `LViewData` | `TView.data`
15+
| ---------- | ------------------------------------------------------------ | --------------------------------------------------
16+
| `HEADER` | contextual data | mostly `null`
17+
| `CONSTS` | DOM, pipe, and local ref instances |
18+
| `VARS` | binding values | property names
19+
| `EXPANDO` | host bindings; directive instances; providers; dynamic nodes | host prop names; directive tokens; provider tokens; `null`
2020

2121

2222
## `HEADER`

0 commit comments

Comments
 (0)