Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-intl-universal

Package Overview
Dependencies
Maintainers
1
Versions
138
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-intl-universal - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

43

lib/index.js

@@ -67,5 +67,11 @@ /*

var isPolyfill = false;
if (typeof window.Intl === "undefined") {
window.Intl = IntlPolyfill;
isPolyfill = true;
var isBrowser = typeof window !== "undefined";
if (isBrowser) {
if (typeof window.Intl === "undefined") {
window.Intl = IntlPolyfill;
isPolyfill = true;
}
} else {
global.Intl = IntlPolyfill;
}

@@ -118,8 +124,8 @@

// HTML message with variables. Escape it to avoid XSS attack.
for (key in variables) {
var value = variables[key];
for (var i in variables) {
var value = variables[i];
if (typeof value === "string" && value.indexOf("<") >= 0 && value.indexOf(">") >= 0) {
value = escapeHtml(value);
}
variables[key] = value;
variables[i] = value;
}

@@ -133,3 +139,3 @@ }

} catch (err) {
console.error("format message failure for key='" + key + "'", err);
console.warn("react-intl-universal format message failed for key='" + key + "'", err);
return "";

@@ -240,12 +246,17 @@ }

return new Promise(function (resolve, reject) {
if (isPolyfill) {
var lang = _this.options.currentLocale.split("-")[0];
load(SYS_LOCALE_DATA_URL + "/" + lang + ".js", function (err, script) {
if (err) {
reject(err);
} else {
resolve();
}
});
var lang = _this.options.currentLocale.split("-")[0];
if (isBrowser) {
if (isPolyfill) {
load(SYS_LOCALE_DATA_URL + "/" + lang + ".js", function (err, script) {
if (err) {
reject(err);
} else {
resolve();
}
});
} else {
resolve();
}
} else {
require("intl/locale-data/jsonp/" + lang + ".js");
resolve();

@@ -252,0 +263,0 @@ }

{
"name": "react-intl-universal",
"version": "1.1.1",
"version": "1.2.0",
"description": "Internationalize React apps. Not only for React.Component but also for Vanilla JS.",

@@ -30,3 +30,3 @@ "keywords": [

"dependencies": {
"console-polyfill": "^0.2.3",
"console-polyfill": "^0.3.0",
"cookie": "^0.3.1",

@@ -46,2 +46,3 @@ "escape-html": "^1.0.3",

"babel-jest": "^19.0.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.24.1",
"babel-preset-es2015": "^6.1.18",

@@ -48,0 +49,0 @@ "babel-preset-es2015-rollup": "^3.0.0",

# react-intl-universal
[react-intl-universal](https://github.com/alibaba/react-intl-universal) is a React internationalization package developed by [Alibaba Group](http://www.alibabagroup.com).

@@ -88,3 +89,3 @@ [![npm](https://img.shields.io/npm/dt/react-intl-universal.svg)](https://www.npmjs.com/package/react-intl-universal) [![npm](https://img.shields.io/npm/v/react-intl-universal.svg)](https://www.npmjs.com/package/react-intl-universal) [![npm](https://img.shields.io/npm/l/react-intl-universal.svg)](https://github.com/alibaba/react-intl-universal/blob/master/LICENSE.md)

Note that you are not necessary to load all locale data, just load the current locale data on demand. Please refer the [example](https://github.com/alibaba/react-intl-universal/blob/master/examples/src/App.js#L72-L88) for more detail.
Note that you are not necessary to load all locale data, just load the current locale data on demand. Please refer the [example](https://github.com/alibaba/react-intl-universal/blob/master/examples/browser-example/src/App.js#L72-L88) for more detail.

@@ -110,2 +111,3 @@ ```js

// init method will load CLDR locale data according to currentLocale
// react-intl-universal is singleton, so you should init it only once in your app
intl.init({

@@ -112,0 +114,0 @@ currentLocale: 'en-US', // TODO: determine locale here

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc