angular-docs-cn/packages/core/test/render3
Andrew Kushnir cb05c0102f fix(core): move generated i18n statements to the `consts` field of ComponentDef (#38404)
This commit updates the code to move generated i18n statements into the `consts` field of
ComponentDef to avoid invoking `$localize` function before component initialization (to better
support runtime translations) and also avoid problems with lazy-loading when i18n defs may not
be present in a chunk where it's referenced.

Prior to this change the i18n statements were generated at the top leve:

```
var I18N_0;
if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
    var MSG_X = goog.getMsg(“…”);
    I18N_0 = MSG_X;
} else {
    I18N_0 = $localize('...');
}

defineComponent({
    // ...
    template: function App_Template(rf, ctx) {
        i0.ɵɵi18n(2, I18N_0);
    }
});
```

This commit updates the logic to generate the following code instead:

```
defineComponent({
    // ...
    consts: function() {
        var I18N_0;
        if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
            var MSG_X = goog.getMsg(“…”);
            I18N_0 = MSG_X;
        } else {
            I18N_0 = $localize('...');
        }
        return [
            I18N_0
        ];
    },
    template: function App_Template(rf, ctx) {
        i0.ɵɵi18n(2, 0);
    }
});
```

Also note that i18n template instructions now refer to the `consts` array using an index
(similar to other template instructions).

PR Close #38404
2020-08-17 10:13:57 -07:00
..
instructions build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
interfaces refactor(core): add debug ranges to `LViewDebug` with matchers (#38359) 2020-08-06 16:58:11 -07:00
ivy build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
jit build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
perf refactor(dev-infra): ng_rollup_bundle rule should leverage `@bazel/rollup` (#37623) 2020-06-22 10:55:28 -07:00
styling_next build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
util build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
BUILD.bazel refactor(core): add debug ranges to `LViewDebug` with matchers (#38359) 2020-08-06 16:58:11 -07:00
change_detection_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
common_with_def.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
component_ref_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
component_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
di_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
domino.d.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
global_utils_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
i18n_debug_spec.ts refactor(core): break `i18n.ts` into smaller files (#38368) 2020-08-10 15:07:42 -07:00
i18n_spec.ts fix(core): move generated i18n statements to the `consts` field of ComponentDef (#38404) 2020-08-17 10:13:57 -07:00
imported_renderer2.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
instructions_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
integration_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
is_shape_of.ts refactor(core): add debug ranges to `LViewDebug` with matchers (#38359) 2020-08-06 16:58:11 -07:00
is_shape_of_spec.ts refactor(core): add debug ranges to `LViewDebug` with matchers (#38359) 2020-08-06 16:58:11 -07:00
jit_environment_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
listeners_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
load_domino.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
matchers.ts refactor(core): add debug ranges to `LViewDebug` with matchers (#38359) 2020-08-06 16:58:11 -07:00
matchers_spec.ts refactor(core): add debug ranges to `LViewDebug` with matchers (#38359) 2020-08-06 16:58:11 -07:00
metadata_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
node_selector_matcher_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
perfCounter_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
pipe_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
providers_spec.ts fix(core): infinite loop if injectable using inheritance has a custom decorator (#37022) 2020-06-03 13:16:25 -07:00
query_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
render_util.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
renderer_factory_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
testing_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
utils.ts refactor(core): add human readable `debug` for i18n (#38154) 2020-08-06 15:20:17 -07:00
view_container_ref_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
view_utils_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00