Skip to content

feat(web): supports lynx.getI18nResource() and onI18nResourceReady ev…#1088

Merged
Sherry-hue merged 1 commit intolynx-family:mainfrom
Sherry-hue:feat/lynx-get-i18n-resouce
Jun 18, 2025
Merged

feat(web): supports lynx.getI18nResource() and onI18nResourceReady ev…#1088
Sherry-hue merged 1 commit intolynx-family:mainfrom
Sherry-hue:feat/lynx-get-i18n-resouce

Conversation

@Sherry-hue
Copy link
Collaborator

…ent in bts.

Summary

feat: supports lynx.getI18nResource() and onI18nResourceReady event in bts.

  • lynx.getI18nResource() can be used to get i18nResource in bts, it has two data sources:
    • the result of _I18nResourceTranslation()
    • lynx-view updateI18nResources(data: InitI18nResources, options: I18nResourceTranslationOptions), it will be matched to the correct i8nResource as a result of lynx.getI18nResource()
  • onI18nResourceReady event can be used to listen _I18nResourceTranslation and lynx-view updateI18nResources execution.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@changeset-bot
Copy link

changeset-bot bot commented Jun 16, 2025

🦋 Changeset detected

Latest commit: 43164a2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@lynx-js/web-mainthread-apis Patch
@lynx-js/web-worker-runtime Patch
@lynx-js/web-constants Patch
@lynx-js/web-core Patch
@lynx-js/web-core-server Patch
@lynx-js/web-worker-rpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov
Copy link

codecov bot commented Jun 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link

codspeed-hq bot commented Jun 16, 2025

CodSpeed Performance Report

Merging #1088 will not alter performance

Comparing Sherry-hue:feat/lynx-get-i18n-resouce (43164a2) with main (b372d7b)

Summary

✅ 8 untouched benchmarks

@relativeci
Copy link

relativeci bot commented Jun 16, 2025

React Example

#1716 Bundle Size — 232.61KiB (0%).

43164a2(current) vs b372d7b main#1706(baseline)

Bundle metrics  no changes
                 Current
#1716
     Baseline
#1706
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 143 143
No change  Duplicate Modules 55 55
No change  Duplicate Code 45.68% 45.68%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#1716
     Baseline
#1706
No change  IMG 145.76KiB 145.76KiB
No change  Other 86.86KiB 86.86KiB

Bundle analysis reportBranch Sherry-hue:feat/lynx-get-i18n-re...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link

relativeci bot commented Jun 16, 2025

Web Explorer

#1704 Bundle Size — 257.66KiB (+0.28%).

43164a2(current) vs b372d7b main#1694(baseline)

Bundle metrics  Change 4 changes Regression 1 regression
                 Current
#1704
     Baseline
#1694
Regression  Initial JS 139.89KiB(+0.18%) 139.64KiB
No change  Initial CSS 31.82KiB 31.82KiB
Change  Cache Invalidation 87.62% 0%
No change  Chunks 4 4
No change  Assets 4 4
Change  Modules 205(-0.49%) 206
No change  Duplicate Modules 15 15
Change  Duplicate Code 3.41%(+1.79%) 3.35%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#1704
     Baseline
#1694
Regression  JS 225.84KiB (+0.32%) 225.11KiB
No change  CSS 31.82KiB 31.82KiB

Bundle analysis reportBranch Sherry-hue:feat/lynx-get-i18n-re...Project dashboard


Generated by RelativeCIDocumentationReport issue

@Sherry-hue Sherry-hue force-pushed the feat/lynx-get-i18n-resouce branch from 9393311 to 47343fe Compare June 18, 2025 02:32
@Sherry-hue Sherry-hue force-pushed the feat/lynx-get-i18n-resouce branch from 47343fe to 43164a2 Compare June 18, 2025 02:35
@Sherry-hue Sherry-hue requested a review from PupilTong June 18, 2025 02:58
@Sherry-hue Sherry-hue enabled auto-merge June 18, 2025 03:11
@PupilTong PupilTong requested a review from Copilot June 18, 2025 03:56
@Sherry-hue Sherry-hue added this pull request to the merge queue Jun 18, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for retrieving internationalization resources via lynx.getI18nResource() and for listening to i18n resource updates through the onI18nResourceReady event in the background thread service (bts). Key changes include:

  • Registering new cross-thread handlers for updating and dispatching i18n resources.
  • Enhancing native app creation to include i18nResource initialization and exposure.
  • Updating tests and related APIs to validate both the direct and lynx-view mediated paths for i18n resource updates.

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/web-platform/web-worker-runtime/src/backgroundThread/background-apis/crossThreadHandlers/registerUpdateI18nResource.ts Registers handlers for update and dispatch of i18n resources.
packages/web-platform/web-worker-runtime/src/backgroundThread/background-apis/createNativeApp.ts Instantiates and registers the new I18nResource functionality.
packages/web-platform/web-worker-runtime/src/backgroundThread/background-apis/createBackgroundLynx.ts Adds getI18nResource API to retrieve the current i18n resource data.
packages/web-platform/web-tests/tests/web-core.test.ts Adds tests to validate both the mts and lynx-view update methods.
packages/web-platform/web-mainthread-apis/src/prepareMainThreadAPIs.ts Updates main thread API to dispatch new i18n resource events.
packages/web-platform/web-core/src/uiThread/startUIThread.ts & startBackground.ts Updates UI thread and background initialization to handle i18n resource changes.
packages/web-platform/web-core/src/apis/createLynxView.ts & LynxView.ts Updates LynxView API to include i18n resource update options.
packages/web-platform/web-constants/src/types/I18n.ts & endpoints.ts Defines new i18n resource types and RPC endpoints.
.changeset/heavy-sides-enter.md Documents the new i18n resource feature and event support.

expect(second).toBeTruthy();
});
test('api-get-i18n-resource-by-mts', async ({ page, browserName }) => {
// firefox dose not support this.
Copy link

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in comment: 'dose' should be 'does'.

Suggested change
// firefox dose not support this.
// firefox does not support this.

Copilot uses AI. Check for mistakes.
expect(second).toBeTruthy();
});
test('api-get-i18n-resource-by-lynx-update', async ({ page, browserName }) => {
// firefox dose not support this.
Copy link

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in comment: 'dose' should be 'does'.

Suggested change
// firefox dose not support this.
// firefox does not support this.

Copilot uses AI. Check for mistakes.
Comment on lines +91 to +93
updateI18nResources: (...args) => {
updateI18nResourcesMainThread(args[0] as Cloneable);
updateI18nResourceBackground(...args);
Copy link

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider explicitly naming the parameters for the updateI18nResources function instead of using rest parameters, to improve clarity and maintainability.

Suggested change
updateI18nResources: (...args) => {
updateI18nResourcesMainThread(args[0] as Cloneable);
updateI18nResourceBackground(...args);
updateI18nResources: (resource: Cloneable, ...additionalArgs) => {
updateI18nResourcesMainThread(resource);
updateI18nResourceBackground(resource, ...additionalArgs);

Copilot uses AI. Check for mistakes.
Merged via the queue into lynx-family:main with commit f99de1e Jun 18, 2025
39 of 40 checks passed
@Sherry-hue Sherry-hue deleted the feat/lynx-get-i18n-resouce branch June 18, 2025 04:12
colinaaa pushed a commit that referenced this pull request Jun 20, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @lynx-js/react@0.110.0

### Minor Changes

- Fixed closure variable capture issue in effect hooks to prevent stale
values and ensured proper execution order between refs, effects, and
event handlers.
([#770](#770))

    **Breaking Changes**:

- The execution timing of `ref`, `useEffect()` callback,
`componentDidMount`, `componentDidUpdate`, `componentWillUnmount` and
the callback of `setState` have been moved forward. These effects will
now execute before hydration is complete, rather than waiting for the
main thread update to complete.
- For components inside `<list />`, `ref` callbacks will now be
triggered during background thread rendering, regardless of component
visibility. If your code depends on component visibility timing, use
`main-thread:ref` instead of regular `ref`.

### Patch Changes

- Fixed two memory leaks:
([#1071](#1071))

1. When JSX is rendered on the main thread and removed, FiberElement can
still be referenced by `__root.__jsx` through `props.children`;

2. When the SnapshotInstance tree is removed from the root node, its
child nodes form a cycle reference because the `__previousSibling` and
`__nextSibling` properties point to each other, thus causing a
FiberElement leak.

- Optimize the error message when snapshots cannot be found in the main
thread. ([#1083](#1083))

- Fix a problem causing `MainThreadRef`s to not be updated correctly
during hydration when they are set to `main-thread:ref`s.
([#1001](#1001))

- Add snapshot id report when throwing `snapshotPatchApply failed: ctx
not found` error.
([#1107](#1107))

- Fix a bug in ReactLynx Testing Library that rendered snapshot of
inline style was normalized incorrectly (eg. `flex:1` was normalized to
`flex: 1 1 0%;` incorrectly).
([#1040](#1040))

## @lynx-js/web-core@0.14.0

### Minor Changes

- refactor: the default thread-strategy will be all on ui
([#1105](#1105))

    **This is a breaking change!!!**

### Patch Changes

- feat: add `_SetSourceMapRelease(errInfo)` MTS API.
([#1118](#1118))

You can get `errInfo.release` through `e.detail.release` in the error
event callback of lynx-view.

The `_SetSourceMapRelease` function is not complete yet, because it is
currently limited by the Web platform and some functions and some props
such as `err.stack` do not need to be supported for the time being.

- feat: add `_I18nResourceTranslation` api in mts &&
`init-i18n-resources` attr, `i18nResourceMissed` event of lynx-view.
([#1065](#1065))

`init-i18n-resource` is the complete set of i18nResources that need to
be maintained on the container side. Note: You need to pass this value
when lynx-view is initialized.

You can use `_I18nResourceTranslation` in MTS to get the corresponding
i18nResource from `init-i18n-resources`. If it is undefined, the
`i18nResourceMissed` event will be dispatched.

    ```js
    // ui thread
    lynxView.initI18nResources = [
      {
        options: {
          locale: "en",
          channel: "1",
          fallback_url: "",
        },
        resource: {
          hello: "hello",
          lynx: "lynx web platform1",
        },
      },
    ];
    lynxView.addEventListener("i18nResourceMissed", (e) => {
      console.log(e);
    });

    // mts
    _I18nResourceTranslation({
      locale: "en",
      channel: "1",
      fallback_url: "",
    });
    ```

- fix: lynx-view `updateGlobalProps` method will also update
globalProps, so `reload()` will use the latest updated globalProps.
([#1119](#1119))

- feat: supports `lynx.getI18nResource()` and `onI18nResourceReady`
event in bts.
([#1088](#1088))

- `lynx.getI18nResource()` can be used to get i18nResource in bts, it
has two data sources:
        -   the result of `_I18nResourceTranslation()`
- lynx-view `updateI18nResources(data: InitI18nResources, options:
I18nResourceTranslationOptions)`, it will be matched to the correct
i8nResource as a result of `lynx.getI18nResource()`
- `onI18nResourceReady` event can be used to listen
`_I18nResourceTranslation` and lynx-view `updateI18nResources`
execution.

- refactor: make the opcode be a plain array
([#1051](#1051))

    \#1042

- feat: The error event return value detail of lynx-view adds
`sourceMap` value, the type is as follows:
([#1058](#1058))

        CustomEvent<{
          error: Error;
          sourceMap: {
            offset: {
              line: number;
              col: number;
            };
          };
        }>;

This is because web-core adds wrapper at runtime, which causes the stack
offset to be different. Now you can calculate the real offset based on
it.

- feat: add `updateI18nResources` method of lynx-view.
([#1085](#1085))

Now you can use `updateI18nResources` to update i18nResources, and then
use \_I18nResourceTranslation() to get the updated result.

- fix: --lynx-color will be removed, and if color contains `gradient` it
will be processed as transparent.
([#1069](#1069))

- Updated dependencies
\[[`42ed2e3`](42ed2e3),
[`25a04c9`](25a04c9),
[`0dbb8b1`](0dbb8b1),
[`f99de1e`](f99de1e),
[`873a285`](873a285),
[`afacb2c`](afacb2c),
[`1861cbe`](1861cbe)]:
    -   @lynx-js/web-worker-runtime@0.14.0
    -   @lynx-js/web-mainthread-apis@0.14.0
    -   @lynx-js/web-constants@0.14.0
    -   @lynx-js/offscreen-document@0.1.2
    -   @lynx-js/web-worker-rpc@0.14.0

## @lynx-js/css-extract-webpack-plugin@0.6.0

### Minor Changes

- Fix CSS HMR crash issues by using the same encode options with the
main template.
([#1033](#1033))

## @lynx-js/template-webpack-plugin@0.8.0

### Minor Changes

- Remove `EncodeCSSOptions` and `encodeCSS` to ensure consistent
encoding options are used across CSS HMR updates and the main template.
([#1033](#1033))

### Patch Changes

- Avoid generating lazy bundles when there are no chunk name.
([#1090](#1090))

    E.g.: using `import.meta.webpackContext`.

## create-rspeedy@0.9.10

### Patch Changes

- Enable TypeScript check in templates.
([#1093](#1093))

- Fix a bug in ReactLynx Testing Library that rendered snapshot of
inline style was normalized incorrectly (eg. `flex:1` was normalized to
`flex: 1 1 0%;` incorrectly).
([#1040](#1040))

## @lynx-js/react-rsbuild-plugin@0.10.4

### Patch Changes

- Support `@lynx-js/react` v0.110.0.
([#770](#770))

- Updated dependencies
\[[`f84a1cc`](f84a1cc),
[`0d151db`](0d151db),
[`0d151db`](0d151db),
[`51676ed`](51676ed),
[`0d151db`](0d151db),
[`a43ae05`](a43ae05),
[`0a0ef40`](0a0ef40),
[`9b61210`](9b61210)]:
    -   @lynx-js/react-alias-rsbuild-plugin@0.10.4
    -   @lynx-js/react-webpack-plugin@0.6.16
    -   @lynx-js/css-extract-webpack-plugin@0.6.0
    -   @lynx-js/template-webpack-plugin@0.8.0
    -   @lynx-js/react-refresh-webpack-plugin@0.3.3
    -   @lynx-js/use-sync-external-store@1.5.0

## @lynx-js/react-alias-rsbuild-plugin@0.10.4

### Patch Changes

- Replace `enhanced-resolve` with `unrs-resolver`
([#936](#936))

## @lynx-js/testing-environment@0.1.1

### Patch Changes

- Fix `getJSContext` or `getCoreContext` is not a function.
([#1122](#1122))

## @lynx-js/tailwind-preset@0.0.4

### Patch Changes

- Avoid publishing test files.
([#1125](#1125))

## @lynx-js/offscreen-document@0.1.2

### Patch Changes

- refactor: make the opcode be a plain array
([#1051](#1051))

    \#1042

## @lynx-js/web-constants@0.14.0

### Patch Changes

- feat: add `_SetSourceMapRelease(errInfo)` MTS API.
([#1118](#1118))

You can get `errInfo.release` through `e.detail.release` in the error
event callback of lynx-view.

The `_SetSourceMapRelease` function is not complete yet, because it is
currently limited by the Web platform and some functions and some props
such as `err.stack` do not need to be supported for the time being.

- feat: add `_I18nResourceTranslation` api in mts &&
`init-i18n-resources` attr, `i18nResourceMissed` event of lynx-view.
([#1065](#1065))

`init-i18n-resource` is the complete set of i18nResources that need to
be maintained on the container side. Note: You need to pass this value
when lynx-view is initialized.

You can use `_I18nResourceTranslation` in MTS to get the corresponding
i18nResource from `init-i18n-resources`. If it is undefined, the
`i18nResourceMissed` event will be dispatched.

    ```js
    // ui thread
    lynxView.initI18nResources = [
      {
        options: {
          locale: "en",
          channel: "1",
          fallback_url: "",
        },
        resource: {
          hello: "hello",
          lynx: "lynx web platform1",
        },
      },
    ];
    lynxView.addEventListener("i18nResourceMissed", (e) => {
      console.log(e);
    });

    // mts
    _I18nResourceTranslation({
      locale: "en",
      channel: "1",
      fallback_url: "",
    });
    ```

- feat: supports `lynx.getI18nResource()` and `onI18nResourceReady`
event in bts.
([#1088](#1088))

- `lynx.getI18nResource()` can be used to get i18nResource in bts, it
has two data sources:
        -   the result of `_I18nResourceTranslation()`
- lynx-view `updateI18nResources(data: InitI18nResources, options:
I18nResourceTranslationOptions)`, it will be matched to the correct
i8nResource as a result of `lynx.getI18nResource()`
- `onI18nResourceReady` event can be used to listen
`_I18nResourceTranslation` and lynx-view `updateI18nResources`
execution.

- refactor: make the opcode be a plain array
([#1051](#1051))

    \#1042

- feat: add `updateI18nResources` method of lynx-view.
([#1085](#1085))

Now you can use `updateI18nResources` to update i18nResources, and then
use \_I18nResourceTranslation() to get the updated result.

-   Updated dependencies \[]:
    -   @lynx-js/web-worker-rpc@0.14.0

## @lynx-js/web-core-server@0.14.0

### Patch Changes

- feat: add `_SetSourceMapRelease(errInfo)` MTS API.
([#1118](#1118))

You can get `errInfo.release` through `e.detail.release` in the error
event callback of lynx-view.

The `_SetSourceMapRelease` function is not complete yet, because it is
currently limited by the Web platform and some functions and some props
such as `err.stack` do not need to be supported for the time being.

- feat: add `_I18nResourceTranslation` api in mts &&
`init-i18n-resources` attr, `i18nResourceMissed` event of lynx-view.
([#1065](#1065))

`init-i18n-resource` is the complete set of i18nResources that need to
be maintained on the container side. Note: You need to pass this value
when lynx-view is initialized.

You can use `_I18nResourceTranslation` in MTS to get the corresponding
i18nResource from `init-i18n-resources`. If it is undefined, the
`i18nResourceMissed` event will be dispatched.

    ```js
    // ui thread
    lynxView.initI18nResources = [
      {
        options: {
          locale: "en",
          channel: "1",
          fallback_url: "",
        },
        resource: {
          hello: "hello",
          lynx: "lynx web platform1",
        },
      },
    ];
    lynxView.addEventListener("i18nResourceMissed", (e) => {
      console.log(e);
    });

    // mts
    _I18nResourceTranslation({
      locale: "en",
      channel: "1",
      fallback_url: "",
    });
    ```

## @lynx-js/web-elements@0.7.6

### Patch Changes

- fix: incorrect syntax for x-canvas part
([#1067](#1067))

- feat: x-input && x-textarea add attribute input-filter, which can
filter input value.
([#1037](#1037))

- fix: incorrect top style of x-foldview-slot-ng if the toolbar is
wrapped in lynx-wrapper
([#1101](#1101))

- perf: add loading="lazy" for image element
([#1056](#1056))


<https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img#loading>

- fix: --lynx-color will be removed, and if color contains `gradient` it
will be processed as transparent.
([#1069](#1069))

- Updated dependencies
\[[`62d1078`](62d1078)]:
    -   @lynx-js/web-elements-template@0.7.6

## @lynx-js/web-elements-template@0.7.6

### Patch Changes

- perf: add loading="lazy" for image element
([#1056](#1056))


<https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img#loading>

## @lynx-js/web-mainthread-apis@0.14.0

### Patch Changes

- feat: add `_SetSourceMapRelease(errInfo)` MTS API.
([#1118](#1118))

You can get `errInfo.release` through `e.detail.release` in the error
event callback of lynx-view.

The `_SetSourceMapRelease` function is not complete yet, because it is
currently limited by the Web platform and some functions and some props
such as `err.stack` do not need to be supported for the time being.

- feat: add `_I18nResourceTranslation` api in mts &&
`init-i18n-resources` attr, `i18nResourceMissed` event of lynx-view.
([#1065](#1065))

`init-i18n-resource` is the complete set of i18nResources that need to
be maintained on the container side. Note: You need to pass this value
when lynx-view is initialized.

You can use `_I18nResourceTranslation` in MTS to get the corresponding
i18nResource from `init-i18n-resources`. If it is undefined, the
`i18nResourceMissed` event will be dispatched.

    ```js
    // ui thread
    lynxView.initI18nResources = [
      {
        options: {
          locale: "en",
          channel: "1",
          fallback_url: "",
        },
        resource: {
          hello: "hello",
          lynx: "lynx web platform1",
        },
      },
    ];
    lynxView.addEventListener("i18nResourceMissed", (e) => {
      console.log(e);
    });

    // mts
    _I18nResourceTranslation({
      locale: "en",
      channel: "1",
      fallback_url: "",
    });
    ```

- feat: supports `lynx.getI18nResource()` and `onI18nResourceReady`
event in bts.
([#1088](#1088))

- `lynx.getI18nResource()` can be used to get i18nResource in bts, it
has two data sources:
        -   the result of `_I18nResourceTranslation()`
- lynx-view `updateI18nResources(data: InitI18nResources, options:
I18nResourceTranslationOptions)`, it will be matched to the correct
i8nResource as a result of `lynx.getI18nResource()`
- `onI18nResourceReady` event can be used to listen
`_I18nResourceTranslation` and lynx-view `updateI18nResources`
execution.

- feat: add `updateI18nResources` method of lynx-view.
([#1085](#1085))

Now you can use `updateI18nResources` to update i18nResources, and then
use \_I18nResourceTranslation() to get the updated result.

- fix: `decodeCssInJs` will not throw error.
([#1120](#1120))

Before this pr, decoding css will be strictly executed according to
cssInfo, and an error will be thrown if data that does not meet the
requirements is encountered. Now it is changed to console.warn, which
will not block rendering.

- Updated dependencies
\[[`25a04c9`](25a04c9),
[`0dbb8b1`](0dbb8b1),
[`f99de1e`](f99de1e),
[`873a285`](873a285),
[`afacb2c`](afacb2c),
[`7e73450`](7e73450)]:
    -   @lynx-js/web-constants@0.14.0
    -   @lynx-js/web-style-transformer@0.3.1

## @lynx-js/web-platform-rsbuild-plugin@0.1.1

### Patch Changes

- Fix build on Windows
([#1048](#1048))

## @lynx-js/web-style-transformer@0.3.1

### Patch Changes

- fix: --lynx-color will be removed, and if color contains `gradient` it
will be processed as transparent.
([#1069](#1069))

## @lynx-js/web-worker-runtime@0.14.0

### Patch Changes

- fix: The parameter config of loadCard needs to add updateData,
otherwise some event binding will fail when enableJSDataProcessor is
turned on.
([#1077](#1077))

- feat: add `_I18nResourceTranslation` api in mts &&
`init-i18n-resources` attr, `i18nResourceMissed` event of lynx-view.
([#1065](#1065))

`init-i18n-resource` is the complete set of i18nResources that need to
be maintained on the container side. Note: You need to pass this value
when lynx-view is initialized.

You can use `_I18nResourceTranslation` in MTS to get the corresponding
i18nResource from `init-i18n-resources`. If it is undefined, the
`i18nResourceMissed` event will be dispatched.

    ```js
    // ui thread
    lynxView.initI18nResources = [
      {
        options: {
          locale: "en",
          channel: "1",
          fallback_url: "",
        },
        resource: {
          hello: "hello",
          lynx: "lynx web platform1",
        },
      },
    ];
    lynxView.addEventListener("i18nResourceMissed", (e) => {
      console.log(e);
    });

    // mts
    _I18nResourceTranslation({
      locale: "en",
      channel: "1",
      fallback_url: "",
    });
    ```

- feat: supports `lynx.getI18nResource()` and `onI18nResourceReady`
event in bts.
([#1088](#1088))

- `lynx.getI18nResource()` can be used to get i18nResource in bts, it
has two data sources:
        -   the result of `_I18nResourceTranslation()`
- lynx-view `updateI18nResources(data: InitI18nResources, options:
I18nResourceTranslationOptions)`, it will be matched to the correct
i8nResource as a result of `lynx.getI18nResource()`
- `onI18nResourceReady` event can be used to listen
`_I18nResourceTranslation` and lynx-view `updateI18nResources`
execution.

- feat: add `updateI18nResources` method of lynx-view.
([#1085](#1085))

Now you can use `updateI18nResources` to update i18nResources, and then
use \_I18nResourceTranslation() to get the updated result.

- Updated dependencies
\[[`25a04c9`](25a04c9),
[`0dbb8b1`](0dbb8b1),
[`f99de1e`](f99de1e),
[`873a285`](873a285),
[`afacb2c`](afacb2c),
[`1861cbe`](1861cbe)]:
    -   @lynx-js/web-mainthread-apis@0.14.0
    -   @lynx-js/web-constants@0.14.0
    -   @lynx-js/offscreen-document@0.1.2
    -   @lynx-js/web-worker-rpc@0.14.0

## @lynx-js/react-webpack-plugin@0.6.16

### Patch Changes

- Supports `@lynx-js/template-webpack-plugin` 0.8.0.
([#1033](#1033))

- Support `@lynx-js/react` v0.110.0.
([#770](#770))

- Keep snapshot id unchanged on Windows.
([#1050](#1050))

- Fix lazy bundle name on Windows.
([#1060](#1060))

## @lynx-js/rspeedy@0.9.10



## upgrade-rspeedy@0.9.10



## @lynx-js/web-worker-rpc@0.14.0

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants