Giter Club home page Giter Club logo

react-intl-universal's Introduction

react-intl-universal

react-intl-universal is a React internationalization package developed by Alibaba Group.

npm npm npm

Features

  • Can be used not only in React component but also in Vanilla JS.
  • Simple. Only three main API and one optional helper.
  • Display numbers, currency, dates and times for different locales.
  • Pluralize labels in strings.
  • Support variables in message.
  • Support HTML in message.
  • Support for 150+ languages.
  • Runs in the browser and Node.js.
  • Message format is strictly implemented by ICU standards.
  • Locale data in nested JSON format are supported.
  • react-intl-universal-extract helps you generate a locale file easily.

Live Demo

react-intl-universal example

Usage Trend

Usage Trend of react-intl-universal

npm usage trend of react-intl-universal

Why Another Internationalization Solution for React?

In case of internationalizing React apps, react-intl is one of most popular package in industry. react-intl decorate your React.Component with wrapped component which is injected internationalized message dynamically so that the locale data is able to be loaded dynamically without reloading page. The following is the example code using react-intl.

import { injectIntl } from 'react-intl';
class MyComponent extends Component {
  render() {
    const intl = this.props;
    const title = intl.formatMessage({ id: 'title' });
    return (<div>{title}</div>);
  }
};
export default injectIntl(MyComponent);

However, this approach introduces two major issues.

Firstly, Internationalizing can be applied only in view layer such as React.Component. For Vanilla JS file, there's no way to internationalize it. For example, the following snippet is general form validator used by many React.Component in our apps. We definitely will not have such code separated in different React.Component in order to internationalize the warning message. Sadly, react-intl can't be used in Vanilla JS.

export default const rules = {
  noSpace(value) {
    if (value.includes(' ')) {
      return 'Space is not allowed.';
    }
  }
};

Secondly, since your React.Component is wrapped by another class, the behavior is not as expected in many way. For example, to get the instance of React.Component, you can't use the normal way like:

class App {
  render() {
    <MyComponent ref="my"/>
  }
  getMyInstance() {
    console.log('getMyInstance', this.refs.my);
  }
}

Instead, you need to use the method getWrappedInstance() to get that.

class MyComponent {...}
export default injectIntl(MyComponent, {withRef: true});

class App {
  render() {
    <MyComponent ref="my"/>
  }
  getMyInstance() {
    console.log('getMyInstance', this.refs.my.getWrappedInstance());
  }
}

Furthermore, your React.Component's properties are not inherited in subclass since component is injected by react-intl.

Due to the problem above, we create react-intl-universal to internationalize React app using simple but powerful API.

Get Started

App Examples

Message With Variables

If the message contains variables the {variable_name} is substituted directly into the string. In the example below, there are two variables {name} and {where}, the second argument representing the variables in get method are substituted into the string.

Locale data:

{ "HELLO": "Hello, {name}. Welcome to {where}!" }

JS code:

intl.get('HELLO', { name: 'Tony', where: 'Alibaba' }) // "Hello, Tony. Welcome to Alibaba!"

Plural Form and Number Thousands Separators

Locale data:

{ "PHOTO": "You have {num, plural, =0 {no photos.} =1 {one photo.} other {# photos.}}" }

JS code:

intl.get('PHOTO', { num: 0 }); // "You have no photos."
intl.get('PHOTO', { num: 1 }); // "You have one photo."
intl.get('PHOTO', { num: 1000000 }); // "You have 1,000,000 photos."

Plural label supports standard ICU Message syntax.

Number thousands separators also varies according to the user's locale. According to this document, United States use a period to indicate the decimal place. Many other countries use a comma instead.

Display Currency

Locale data:

{ "SALE_PRICE": "The price is {price, number, USD}" }

JS code:

intl.get('SALE_PRICE', { price: 123456.78 }); // The price is $123,456.78

As mentioned, the locale data is in ICU Message format.

The syntax is {name, type, format}. Here is description:

  • name is the variable name in the message. In this case, it's price.
  • type is the type of value such as number, date, and time.
  • format is optional, and is additional information for the displaying format of the value. In this case, it's USD.

if type is number and format is omitted, the result is formatted number with thousands separators. If format is one of currency code, it will show in corresponding currency format.

Display Dates

Locale data:

{
  "SALE_START": "Sale begins {start, date}",
  "SALE_END": "Sale ends {end, date, long}"
}

JS code:

intl.get('SALE_START', {start:new Date()}); // Sale begins 4/19/2017
intl.get('SALE_END', {end:new Date()}); // Sale ends April 19, 2017

If type is date, format has the following values:

  • short shows date as shortest as possible
  • medium shows short textual representation of the month
  • long shows long textual representation of the month
  • full shows dates with the most detail

Display Times

Locale data:

{
  "COUPON": "Coupon expires at {expires, time, medium}"
}

JS code:

intl.get('COUPON', {expires:new Date()}); // Coupon expires at 6:45:44 PM

if type is time, format has the following values:

  • short shows times with hours and minutes
  • medium shows times with hours, minutes, and seconds
  • long shows times with hours, minutes, seconds, and timezone

Default Message

When the specific key does't exist in current locale, you may want to make it return a default message. Use defaultMessage method after get method. For example,

Locale data:

{ "HELLO": "Hello, {name}" }

JS code:

const name = 'Tony';
intl.get('HELLO', { name }).defaultMessage(`Hello, ${name}`); // "Hello, Tony"

Or using d for short:

const name = 'Tony';
intl.get('HELLO', { name }).d(`Hello, ${name}`); // "Hello, Tony"

And getHTML also supports default message.

const name = 'Tony';
intl.getHTML('HELLO').d(<div>Hello, {name}</div>) // React.Element with "<div>Hello, Tony</div>"

HTML Message

The get method returns string message. For HTML message, use getHTML instead. For example,

Locale data:

{ "TIP": "This is <span style='color:red'>HTML</span>" }

JS code:

intl.getHTML('TIP'); // {React.Element}

Helper

react-intl-universal provides a utility helping developer determine the user's currentLocale. As the running examples, when user select a new locale, it redirect user new location like http://localhost:3000?lang=en-US. Then, we can use intl.determineLocale to get the locale from URL. It can also support determine user's locale via cookie, localStorage, and browser default language. Refer to the APIs section for more detail.

Debugger mode

When developing a website with multiple languages (i18n), translators are usually responsible for translating the content instead of the web developer. However, translators often struggle to find the specific message they need to edit on the webpage because they don't know its key. This leads to them having to ask the developer for the key, resulting in a lot of time wasted on communication.

To solve this issue, a solution is proposed: When the debugger mode in react-intl-universal is enabled, each message on the webpage will be wrapped in a special span element with the key "data-i18n-key". This way, translators can easily see the key of the message and make the necessary edits themselves using some message management system, without needing to ask the developer.

Enabling debugger mode:

intl.init({
  // ...
  debug: true
})

Message will be wrapped in a span element with the key "data-i18n-key":

debugger mode

Component Internationalization

When internationalizing a React component, you don't need to intl.init again. You could make it as peerDependency, then just load the locale data in the compoent.

APIs Definition

  /**
   * Initialize properties and load CLDR locale data according to currentLocale
   * @param {Object} options
   * @param {string} options.escapeHtml To escape html. Default value is true.
   * @param {string} options.currentLocale Current locale such as 'en-US'
   * @param {Object} options.locales App locale data like {"en-US":{"key1":"value1"},"zh-CN":{"key1":"值1"}}
   * @param {Object} options.warningHandler Ability to accumulate missing messages using third party services. See https://github.com/alibaba/react-intl-universal/releases/tag/1.11.1
   * @param {string} options.fallbackLocale Fallback locale such as 'zh-CN' to use if a key is not found in the current locale
   * @param {boolean} options.debug If debugger mode is on, the message will be wrapped by a span with data key
   * @param {string} options.dataKey If debugger mode is on, the message will be wrapped by a span with this data key. Default value 'data-i18n-key'
   * @returns {Promise}
   */
  init(options)


  /**
   * Load more locales after init
   * @param {Object} locales App locale data 
   */
  load(locales)


  /**
   * Get the formatted message by key
   * @param {string} key The string representing key in locale data file
   * @param {Object} variables Variables in message
   * @returns {string} message
   */
  get(key, variables)

  /**
   * Get the formatted html message by key.
   * @param {string} key The string representing key in locale data file
   * @param {Object} variables Variables in message
   * @returns {React.Element} message
  */
  getHTML(key, options)

  /**
   * Helper: determine user's locale via URL, cookie, and browser's language.
   * You may not need this API, if you have other rules to determine user's locale.
   * @param {string} options.urlLocaleKey URL's query Key to determine locale. Example: if URL=http://localhost?lang=en-US, then set it 'lang'
   * @param {string} options.cookieLocaleKey Cookie's Key to determine locale. Example: if cookie=lang:en-US, then set it 'lang'
   * @param {string} options.localStorageLocaleKey LocalStorage's Key to determine locale such as 'lang'
   * @returns {string} determined locale such as 'en-US'
   */
  determineLocale(options)

  /**
   * Get the inital options 
   * @returns {Object} options includes currentLocale and locales
   */
  getInitOptions()

Compatibility with react-intl

As mentioned in the issue Mirror react-intl API, to make people switch their existing React projects from react-intl to react-intl-universal. We provide two compatible APIs as following.

  /**
   * As same as get(...) API
   * @param {Object} options 
   * @param {string} options.id 
   * @param {string} options.defaultMessage
   * @param {Object} variables Variables in message
   * @returns {string} message
  */
  formatMessage(options, variables)
  /**
   * As same as getHTML(...) API
   * @param {Object} options 
   * @param {string} options.id 
   * @param {React.Element} options.defaultMessage
   * @param {Object} variables Variables in message
   * @returns {React.Element} message
  */
  formatHTMLMessage(options, variables)

For example, the formatMessage API

const name = 'Tony';
intl.formatMessage({ id:'hello', defaultMessage: `Hello, ${name}`}, {name});

is equivalent to get API

const name = 'Tony';
intl.get('hello', {name}).d(`Hello, ${name}`);

And the formatHTMLMessage API

const name = 'Tony';
intl.formatHTMLMessage({ id:'hello', defaultMessage: <div>Hello</div>}, {name});

is equivalent to getHTML API

const name = 'Tony';
intl.getHTML('hello', {name}).d(<div>Hello</div>);

FAQ

1. How to Internationalize Message in Constants Object

If constants are defined outside of a React component, the message in constants.fruits may get loaded before intl.init(...). This can cause a warning to be displayed, such as react-intl-universal locales data "null" not exists.

// Wrong: the message in constants.fruits is loaded before `intl.init(...)`
const constants = {
  fruits : [
    { label: intl.get('banana'), value: 'banana' },
    { label: intl.get('apple'), value: 'apple' },
  ]
}
function MyComponent() {
  return <Select dataSource={constants.fruits} />
}

To fix this, you should call intl.init before render.

Solution 1

Make the message object as a function, and call it at render function.

const constants = {
    fruits : () => [  // as arrow function
        { label: intl.get('banana'), value: 'banana' },
        { label: intl.get('apple'), value: 'apple' },
    ]
}
function MyComponent() {
    // fruits is a function which returns message when rendering
    return <Select dataSource={constants.fruits()} />
}

Solution 2

Use getter syntax to make a function call when that property is looked up

const constants = {
  fruits: [
    {
      get label() {
        return intl.get("banana");
      },
      value: "banana",
    },
    {
      get label() {
        return intl.get("apple");
      },
      value: "apple",
    },
  ],
};
function MyComponent() {
  // When "label" property is looked up, it actually make a function call 
  return <Select dataSource={constants.fruits} />;
}

2. How to Bind Event Handlers to an Internationalized Message

const MyComp = (props) => {
  const onClick = (e) => {
    if (e.target.tagName === 'A') {
      // event handler for "A" tag in the message
    }
  };
  return (
    // Wrap the message in a container and listen for the children's events.
    <span onClick={onClick}>
      {intl.getHTML('more_detail').d(<span>Please refer to the <a>document</a> for more detail.</span>)}
    </span>
  )
}

Other Frontend Tools

License

This software is free to use under the BSD license.

react-intl-universal's People

Contributors

1999 avatar alexeymohnatkin avatar ankon avatar bowling00 avatar chevindu avatar chuckwu1989 avatar cwtuan avatar dependabot[bot] avatar dreamwb avatar elgalesmana avatar fofir avatar h4mit avatar hardfist avatar jamespearson avatar jbach avatar jhaenchen avatar lex111 avatar lsiric avatar qhxin avatar ryuta1346 avatar sharp-young avatar thierryc avatar tomtomsen avatar wylkon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-intl-universal's Issues

Make loading of common locale optional

It shouldn't be required that the package go out to a third-party CDN. It'd be nice to be able to specify the COMMON_LOCALE_DATA_URLS or be able to bundle an entire locale package in with the initialization. Something like:

intl.init({
  currentLocale: 'en-US',
  locales: {
    'en-US': { ... }
  },
  localeUrls: {
    'en-US': 'https://nonexistentUrl.cdn.com/localedata/en-us.json'
  },
  localeData: {
    'en-US': { ... }
  }
})

Is there a way to turn off warnings for non-defined keys?

I am wondering if it's possible to turn off the browser console warnings for missing keys in a locale file?

eg in chrome console:

react-intl-universal key "ZIP_CODE" not defined in en-US
tracker.js:13 react-intl-universal key "REDEEM_PROMO_CODE" not defined in en-US
etc.

This is causing a lot of log pollution.

Thanks.

Typescript declaration file

Could you please provide a type definition file for this package. I am using typescript in my project and want to use this with the typescript.

version 1.2.0 - npm run build - slowly!!!

从1.1.1版本升级至1.2.0版本后

运行官方browser-example的代码,执行npm start是很快的,但是在执行npm run build的时候,大概要构建2-3分钟。

在我自己的项目中(使用v1.1.1版本,构建时间大概是45s),但是升级了v1.2.0后等待超过10分钟依然不能构建成功!!!但是换回 v1.1.1 版本后,却能正常构建

请尽快解决这个问题~~辛苦啦

Who's using react-intl-universal?

Hi folks,
I'm the author of react-intl-universal, I would like to collect a list of company using this library.
Please reply as the following format:

- Company: xxx
- Products using this lib:
  - http://a.test
  - http://b.test

Thanks!

How to get Locale-data without using cdn

我们的项目不能不能使用外网,有没有什么办法把我想要的几种语言的locale-data放在本地进行访问。
SYS_LOCALE_DATA_URL是不是加个容错比较好,如果无法访问那个网站则采用另一种方式

How to use the react-intl-universal lib in electron without network?

  1. In my project, I use electron, react, antd and react-intl-universal.
  2. In electron, the typeof window !== "undefined", so the isBrowser is true.
  3. If the the isBrowser is true, will add CDN locale data, but my app may be used without network.
    so , is there a way to solve this problem?

Support for nested JSON data?

I am working on a big project, and there are a lot of pages.
I think it would be good to organize the locale data in json by nesting data.

"page1": {
  "first_sentence": "this is first sentence",
  "second_sentence": "this is second sentence" 
},
"page2": ...

how to load multiple JSON files instead of single JSON file of a single language

Hi there,

Thanks for providing the react-intl-universal library. I have used it easily without any issue.

but currently language local data is not in a single file but on multiple JSON files in the local folder. so I have to load all the JSON files from the local folder and then display the data. I am considering only one language currently.

Thanks in advance.

COMMON_LOCALE_DATA_URLS - why not included in the package?

Hi All,

First of all, thanks for the very good lib.
Could you tell me why that data is hosted on CDN, not included in the lib itself?
My app wastes about 1sec to get it from CDN, I would appreciate an option to host it by myself.

What do you think about that? What's the reason of keeping these on external servers?

Regards,
Artur

urlLocaleKey - problem

intl.determineLocale({
  urlLocaleKey: "lang"
});

i use react-router hashHistory
url-example-A(standard): http://www.xxx.com/index.html?lang=en#/test
url-example-B(non-standard): http://www.xxx.com/index.html#/test?lang=en

url-example-A:

window.location.search == '?lang=en'
window.location.hash == '#/test'

url-example-B:

window.location.search == ''
window.location.hash == '#/test?lang=en'

urlLocaleKey only stand by standard-URL ,can u stand by non-standard-URL like "http://www.xxx.com/index.html#/test?lang=en"

Question: Is it possible to send in format as a varible?

Hi,

I'm trying to send in the currency code dynamically to work when switching currency in the system. Is it possible to use a variable for the format, or is the only way to hard code the language code in the translation file?
If it is possible, what is the syntax to use?
I have tried a lot of different approaches without success.

Thanks!

should variables apply when defaultMessage is used?

Hi,
Not sure if it is a bug, but with my usage of extract-intl, I had a case, when the locale message was actually an empty string, so we passed this null check variables had no effect, and the defaultMessage is shown in the end with {variable} as in "locale.json".

I don't know what is a right thing to do, but it seems to me that the desired result would be to have variables inserted into defaultMessage as well.

Thanks!

The build is to big

Hi..

I am using this implementation and works perfectly. But the problem that after do the build is that the dependency intl (react-intl-universal) consume a lot of space, look the image.

intl imports all the languages (close to 20 mb) and i only need two.

How I can limit the languages to require only the ones that I need.?

screen shot 2017-11-02 at 1 01 41 pm

extract-intl / defineMessages

Hi, thanks for sharing this package!

Sorry, if I missed something, but is there, or will there be a way to extract a messages and build a translation.json files?

I mean something like what react-boilerplate do with command extract-intl ? Or what is recommendations to generate the files?

I may be wrong, but I checked the code and, it seems to me, that adding
defineMessages may make this project compatible with babel-plugin-react-intl, isn't it ?
The though is based on this lines . Can we replace the name and get the results?

Best regards,

能否让用户可以手动设置CLDR文件的CDN路径?

现在的CLDR文件的CDN下载路径是直接硬编码的。这样一来就有这么几个问题:
1、有时候g.alicdn.com会非常慢,需要5秒钟以上才能完成文件下载,严重影响用户体验;
2、我们项目希望所有的相关文件都配置在自己的CDN服务器上;
3、很多客户的公司使用proxy来访问外部网络,未必会允许访问g.alicdn.com(我们的客户主要在海外,对于他们来说g.alicdn.com是非常陌生的);
4、虽然可以手动修改src/index.js来解决上述问题,但是因为是硬编码,所以不得不将库文件直接复制到项目的repository里来修改,用自己的git来管理这个库的源代码,感觉很糟……

documentation or at least a list of API functions

Hello guys,
was experimenting with your library 'react-intl-universal' recently.
I feel totally blind in terms of documentation, there is not enough info in repo description.

@cwtuan could you please add at least a list of all functions available in API of 'react-intl-universal' ?

Or if you need any help writing one, i would like to help, in this case, @cwtuan please pm me
[email protected]

Thank you in advance!

Switch to another language

我最近按照你们提供的例子试了一下,在react组件里面定义全局变量,然后切换多语言发现不能够显示对应的语言:请问是不是不支持针对全局变量的多语言翻译。
代码简化如下:
const title=${intl.get('时间')}`;

class Demo { render () { return ( <h1>{title}</h1> ) } }

在切换多语言的时候并不能够翻译title变量。求解

调整一下 react 依赖位置及版本

目前对 react 依赖显式放在 Dependency 中,建议调整至 DevDependency 中,避免对项目中 react 版本的影响,同时升级依赖至 react@16

Object.assign problem in android 4.4.2

构建出来的lib包,并没有对 Object.assign 等进行转码,导致在android 4.4.2 版本的设备上,在执行 init 的时候报错(因为不支持Object.assign )
现在我通过添加 babel-polyfill 垫片库,然后才能正常运行 react-intl-universal的init方法
希望在后续版本可以在打包的时候就加入类似Object.assign的兼容细节。麻烦了!

Built result size is large

感谢作者的组件~
发现个问题 在build时候构建出来的js非常大 应该是一些翻译的包 怎么去掉 不然打包完包太大 18MB左右
image

Using general localization

Will it impose to any issue if I use general locale (e.g. en instead of en-US) in my list of supported locales?

Mirror react-intl API

First, thanks for creating this package! I've been looking for something similar ever since I started using react-intl.

As the documentation suggests this package as an replacement to react-intl, it would be really nice if it would provide the same API as the injected intl object.

So instead of formatting a message with

intl.get('SIMPLE')

it would use the same API as react-intl

intl.formatMessage({id: 'SIMPLE'})

This would make it a lot easier for existing users of react-intl to transition to this package.

Change the locale without reloading the app.

Is there a way to change the locale without forcing the entire app to reload? Setting the locale via the search parameter of the URL is causing the entire app to reload, which is conflicting with an update to the user's profile. It seems like this being a react solution, it should be reactive, but its current implementation imposes a bad experience on users, IMO.

react-intl-universal build failed with create-react-app

我按照例子配置了我的项目,发现build很久,大概5min以上,到最后失败了:报错如下:
`
yarn build
yarn build v0.27.5
$ node scripts/build.js
Creating an optimized production build...

<--- Last few GCs --->

[15101:0x2ae6680] 333362 ms: Mark-sweep 1401.1 (1522.6) -> 1401.1 (1521.6) MB, 884.7 / 0.0 ms (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 885 ms) last resort
[15101:0x2ae6680] 334267 ms: Mark-sweep 1401.1 (1521.6) -> 1401.1 (1521.6) MB, 904.4 / 0.0 ms last resort

<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x175f3e2266a1
2: _serializeMappings(aka SourceMapGenerator_serializeMappings) [/home/littlestone/Documents/work/duomi-cp/node_modules/source-map/lib/source-map-generator.js:~291] [pc=0x2db6aa584db4](this=0x1fa145e2b651 <a SourceMapGenerator with map 0x28d6ae1d0491>)
3: toJSON(aka SourceMapGenerator_toJSON) [/home/littlestone/Documents/work/duomi-cp/node_modules/source-map/lib/source-map-generator.js:...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [node]
2: 0x12b82ac [node]
3: v8::Utils::ReportOOMFailure(char const*, bool) [node]
4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
5: v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [node]
6: v8::internal::Runtime_AllocateInTargetSpace(int, v8::internal::Object**, v8::internal::Isolate*) [node]
7: 0x2db6a748ed46
Aborted
error Command failed with exit code 134.

`
我降了版本还是无法解决问题。请问有没有人能解决这个问题?

lang is not supported ru

I've used react-intl-universal to fetch multiple languages: de, en, fr, ja, ru, zh

When switching the lang, performing the re-init intl.init() into ru-RU
i've got a warning that RU is not supported, locale get loaded and works just fine.
I wonder why the warning.

Here is the log:

screen shot 2018-04-02 at 19 16 20

here is locales structure:

screen shot 2018-04-02 at 19 20 04

here is ru-RU.json
screen shot 2018-04-02 at 19 21 39

bundle file still have 360KB

升级到了最新版本1.3.4,压缩打包出来的文件还是有360多KB。可以看到还是加载了八九个语言包文件,每个语言包压缩之后也会平均占用二十多KB。

intl

local

Can you make the load of CLDR local data optional ?

  1. My electron app does not have network, it takes a few seconds to load the CLDR local data(timeout). Can you make the load of CLDR local data optional in the init (ReactIntlUniversalOptions.loadCLDRLocalData).

Remove network dependency for downloading polyfills

I'm building a progressive web app that sometimes is offline and refreshes. In those scenarios, react-intl-universal causes a network exception to be shown in the console as the request initiated here fails. I recommend we move these files to the repository and you can have your build/deployment process copy these files as they're updated. There's no need for this repo to reach out to the internet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.