Skip to content

Releases: alibaba/react-intl-universal

2.3.1

18 Jul 07:33
Compare
Choose a tag to compare

Update intl-messageformat@8 for Number Skeletons.

Multiple Instance

14 Oct 01:55
Compare
Choose a tag to compare

react-intl-universal is singleton by default. However, if you would like to have multiple react-intl-universal instance, you could instantiate it on demand.

import intl from 'react-intl-universal'; // singleton instance

It's equalivent to:

import { ReactIntlUniversal } from 'react-intl-universal';
const intl = new ReactIntlUniversal();

localStorage's key to determine current key

29 Jun 05:40
Compare
Choose a tag to compare

If there's a item lang=en-US in localStorage, you could determine currentLocale as the following code.

intl.determineLocale( {localStorageLocaleKey: 'lang'} );

Remove Network Dependency for Downloading Common Locale Data

23 May 09:10
e7b5cc4
Compare
Choose a tag to compare

In this release, common locale data will not be loaded from CDN anymore. #84
Please require the locale data like this:

require('intl/locale-data/jsonp/en.js');
require('intl/locale-data/jsonp/zh.js');

See the example.

Support fallbackLocale option

30 Oct 15:40
a5d97fd
Compare
Choose a tag to compare

Support fallbackLocale option to use if a key is not found in the currentLocale. #91

Add escapeHtml option to disable escaping html

23 Oct 12:57
Compare
Choose a tag to compare

To prevent XSS attack, escaping Html is enabled by default.
However, if you would like to disable escaping Html in some cases, use escapeHtml option.
See the test case for example.

Support Message with Brace

12 Sep 16:47
Compare
Choose a tag to compare

In ICU standard, brace in message is treated as variable. An object is supposed to be passed as second parameter in the intl.get("key", object) function. Otherwise, react-intl-universal could not format the message, resulting in returning empty string.

// en-US.js
module.exports = ({
  "BRACE": "The format is {var}",
});

intl.get("BRACE"); // Before this release, it return empty string ""

However, in some case, brace is just a part of the sentence. It's better to be return the original message instead of empty string. This release fixes this issue. Here is the result:

intl.get("BRACE"); // "The format is {var}"
intl.get("BRACE", {var: "x.y.z"}); // "The format is x.y.z"

Custom Common Locale Data URL

05 Aug 07:05
Compare
Choose a tag to compare

The Common Locale Data is now hosted in //g.alicdn.com, however some users in private network may not able to access the internet. This release make the common locale data URL optional. #76, #68, #63, #71

intl.init({
  // ...
  commonLocaleDataUrls: {
     en: "https://g.alicdn.com/react-intl-universal/locale-data/1.0.0/en.js",
     zh: "https://g.alicdn.com/react-intl-universal/locale-data/1.0.0/zh.js",
  }
});

Moreover, if you encounter the following error, this options make supporting more languages possible. #51

Language "${lang}" is not supported.

Custom Warning Handler

13 May 13:28
Compare
Choose a tag to compare

Whenever a default message is missing or having error for formatting a message, react-intl-universal will log warning message like this react-intl-universal key "not-exist-key" not defined in en-US.

If you would like to log these messages using third party services or even turn off the message, here is a chance to add custom warning handler in init function.

const locales = {...};
const currentLocale = "en-US";
const warningHandler = (message, detail) => {...}; // Define your custom warning handler
intl.init({
    locales, 
    currentLocale,
    warningHandler
})

This release fixes #44 and #45.

Support Electron

21 Apr 04:58
Compare
Choose a tag to compare

Electron environment is treated as Node.js environment now.
In Electron, react-intl-universal will not fetch locale files via CDN. You can bundle locale files on demand.
This release fixes #56.