Releases: alibaba/react-intl-universal
Load Multiple Locale Data
Suppport Typescript
Typescript declaration file added.
Thanks @giespaepen for the contribution.
Load Common Locale Data from CDN on Demand
For browser rendering, the common locale data such as date, currency, and number format are automatically loaded from CDN on demand.
For server-side rendering, they should be added in your application as shown in the example.
// For Node.js
import IntlPolyfill from "intl";
global.Intl = IntlPolyfill;
require('intl/locale-data/jsonp/en.js');
require('intl/locale-data/jsonp/zh.js');
require('intl/locale-data/jsonp/fr.js');
require('intl/locale-data/jsonp/ja.js');
Add getInitOptions() function
Some developers would like to get the initial options such as currentLocale
at some other files. Here you are.
FileA.js
import intl from 'react-intl-universal';
intl.init({ locales, currentLocale: "en-US" });
FileB.js
import intl from 'react-intl-universal';
const { currentLocale } = intl.getInitOptions();
console.log(currentLocale); // "en-US"
Support non-nested locale json file for key with dot
Upgrade intl-messageformat to v2.2.0.
To fix values for 0 issue.
Support non-nested locale json file for key with dot.
In v1.4.3, the nested locale file is supported,
{
"page1": {
"hello": "Hello world",
}
}
Then, it will get the nested json correctly.
intl.get('page1.hello'); // "Hello world"
However, some developer like to use dot as separator in the key,
For example, the locale file is as following,
{
"page1.hello": "Hello world"
}
In this release, if the locale json file isn't nested, it will return correct value.
intl.get('page1.hello'); // "Hello world"
Support nested JSON locale data
This release supports nested JSON locale data (#20). Here is example:
locale data:
{
"page1": {
"hello": "Hello world",
},
"page2": {
"hello": "Hello react-intl-universal!",
}
}
JS:
intl.get('page1.hello'); // "Hello world"
intl.get('page2.hello'); // "Hello react-intl-universal!"
Thanks @elgalesmana for the contribution.
Fix Build Problem
This release fixes #15, #16, #17, and #19.
The build size and time is as following.
browser-example | node-js-example | |
---|---|---|
Size | 118.35 KB | 90.14 KB |
Time | 20.03s | 18.04s |
Support node.js for server-side render (SSR)
- fix window is not defined (SSR) #9