alibaba / react-intl-universal

Internationalize React apps. Not only for Component but also for Vanilla JS.
1.33k stars 153 forks source link

feat(cache): implement caching for intl data #235

Open dvlin-dev opened 10 months ago

dvlin-dev commented 10 months ago

Description

add cache

Fixes https://github.com/alibaba/react-intl-universal/issues/232

Type of change

New feature (non-breaking change which adds functionality)

Test

First call intl.get once, and then check if there is a corresponding value in the cache.

cwtuan commented 10 months ago

First of all, thanks for spending time on this project.

Is it possible to make the cache feature optional by parameter? I would like it to be disabled by default for the following reasons:

  1. The cached messages may consume more memory.
  2. I would like it maintain the same behavior of the previous version.
cwtuan commented 10 months ago

Additionally, is it possible to use the cache mechanism offered by https://formatjs.io/docs/intl/#createintlcache?

dvlin-dev commented 10 months ago

I submitted the code again, according to your request, make cache optional, refer to formatjs

dvlin-dev commented 10 months ago

The changes to the init method parameters need to be synchronized in the README.md file, just like defined in index.d.ts. However, the README.md file is ignored in the .gitignore file.

Should I delete the README.md option in the .gitignore file, or should you synchronize the changes of the init parameter?

dvlin-dev commented 10 months ago

I am very happy to be able to contribute (:

dvlin-dev commented 10 months ago

hi bro, maybe you can have a look at of this,I will use the feature plz.

luxsush commented 5 months ago

Bump