forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(compiler): Initial support for i18n attributes
Add support for i18n attributes: - Generate i18n contexts from i18n attributes, and extract the eventual messages into the constant pool. - Emit I18nAttributes config instructions when needed. - Use the generated i18n variable in the appropriate places, including extracted attribute instructions, as well as I18nAttributes config arrays.
- Loading branch information
Showing
26 changed files
with
631 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
34 changes: 34 additions & 0 deletions
34
...t_cases/r3_view_compiler_i18n/element_attributes/interpolation_basic_template.pipeline.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
decls: 5, | ||
vars: 8, | ||
consts: () => { | ||
__i18nMsg__('static text', [], {}, {}) | ||
__i18nMsg__('intro {$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]], {original_code: {'interpolation': '{{ valueA | uppercase }}'}}, {meaning: 'm', desc: 'd'}) | ||
__i18nMsg__('{$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]], {original_code: {'interpolation': '{{ valueB }}'}}, {meaning: 'm1', desc: 'd1'}) | ||
__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`]], {original_code: {'interpolation': '{{ valueA }}', 'interpolation_1': '{{ valueB }}', 'interpolation_2': '{{ valueA + valueB }}'}}, {meaning: 'm2', desc: 'd2'}) | ||
__i18nMsg__('{$interpolation}', [['interpolation', String.raw`\uFFFD0\uFFFD`]], {original_code: {'interpolation': '{{ valueC }}'}}, {}) | ||
return [ | ||
["title", $i18n_1$, "aria-label", $i18n_2$], | ||
["title", $i18n_3$, "aria-roledescription", $i18n_4$], | ||
["id", "dynamic-1", "aria-roledescription", $i18n_0$, __AttributeMarker.I18n__, | ||
"title", "aria-label"], | ||
["id", "dynamic-2", __AttributeMarker.I18n__, "title", "aria-roledescription"] | ||
]; | ||
}, | ||
template: function MyComponent_Template(rf, ctx) { | ||
if (rf & 1) { | ||
$r3$.ɵɵelementStart(0, "div", 2); | ||
$r3$.ɵɵpipe(1, "uppercase"); | ||
$r3$.ɵɵi18nAttributes(2, 0); | ||
$r3$.ɵɵelementEnd(); | ||
$r3$.ɵɵelementStart(3, "div", 3); | ||
$r3$.ɵɵi18nAttributes(4, 1); | ||
$r3$.ɵɵelementEnd(); | ||
} | ||
if (rf & 2) { | ||
$r3$.ɵɵi18nExp($r3$.ɵɵpipeBind1(1, 6, ctx.valueA))(ctx.valueB); | ||
$r3$.ɵɵi18nApply(2); | ||
$r3$.ɵɵadvance(3); | ||
$r3$.ɵɵi18nExp(ctx.valueA)(ctx.valueB)(ctx.valueA + ctx.valueB)(ctx.valueC); | ||
$r3$.ɵɵi18nApply(4); | ||
} | ||
} |
File renamed without changes.
21 changes: 21 additions & 0 deletions
21
...w_compiler_i18n/element_attributes/interpolation_complex_expressions_template.pipeline.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
decls: 2, | ||
vars: 1, | ||
consts: () => { | ||
__i18nMsg__('{$interpolation} title', [['interpolation', String.raw`\uFFFD0\uFFFD`]], {original_code: {'interpolation': '{{valueA.getRawValue()?.getTitle()}}'}}, {}) | ||
return [ | ||
["title", $i18n_0$], | ||
[__AttributeMarker.I18n__, "title"] | ||
]; | ||
}, | ||
template: function MyComponent_Template(rf, ctx) { | ||
if (rf & 1) { | ||
$r3$.ɵɵelementStart(0, "div", 1); | ||
$r3$.ɵɵi18nAttributes(1, 0); | ||
$r3$.ɵɵelementEnd(); | ||
} | ||
if (rf & 2) { | ||
let $tmp_0_0$; | ||
$r3$.ɵɵi18nExp(($tmp_0_0$ = ctx.valueA.getRawValue()) == null ? null : $tmp_0_0$.getTitle()); | ||
$r3$.ɵɵi18nApply(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.