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

terra-i18n

Package Overview
Dependencies
Maintainers
9
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

terra-i18n - npm Package Compare versions

Comparing version 4.25.0 to 4.26.0

5

CHANGELOG.md

@@ -7,2 +7,7 @@ ChangeLog

4.26.0 - (March 31, 2020)
------------------
### Fixed
* Check if Intl.DateTimeFormat and Int.NumberFormat have the `supportedLocalesOf` property before adding as constructors for intl-locales-supported.
4.25.0 - (March 10, 2020)

@@ -9,0 +14,0 @@ ------------------

4

lib/I18nProvider.js

@@ -37,7 +37,7 @@ "use strict";

messages = _ref.messages;
return _react.default.createElement(_reactIntl.IntlProvider, {
return /*#__PURE__*/_react.default.createElement(_reactIntl.IntlProvider, {
locale: locale,
key: locale,
messages: messages
}, _react.default.createElement(_react.default.Fragment, null, children));
}, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children));
};

@@ -44,0 +44,0 @@

@@ -27,3 +27,14 @@ "use strict";

if ((typeof Intl === "undefined" ? "undefined" : _typeof(Intl)) === 'object' && typeof Intl.DateTimeFormat === 'function' && typeof Intl.NumberFormat === 'function') {
constructors = [Intl.DateTimeFormat, Intl.NumberFormat];
/**
* intl-locales-supported accesses the 'supportedLocalesOf' property of each of these constructors.
* When certain polyfills are used, the polyfill may not have the 'supportedLocalesOf' property.
* For example, when using the date-time-format-timezone Intl.DateTimeFormat becomes Intl.DateTimeFormatPolyfill which does not support this property.
*
* Reference: https://github.com/cerner/terra-core/issues/2914
*/
if (Object.prototype.hasOwnProperty.call(Intl.DateTimeFormat, 'supportedLocalesOf') && Object.prototype.hasOwnProperty.call(Intl.NumberFormat, 'supportedLocalesOf')) {
constructors = [Intl.DateTimeFormat, Intl.NumberFormat];
} else {
constructors = [];
}
}

@@ -30,0 +41,0 @@ } catch (error) {

@@ -24,8 +24,12 @@ "use strict";

function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

@@ -38,2 +42,4 @@

var _super = _createSuper(Demo);
function Demo(props) {

@@ -44,3 +50,3 @@ var _this;

_this = _possibleConstructorReturn(this, _getPrototypeOf(Demo).call(this, props));
_this = _super.call(this, props);
_this.state = {

@@ -69,35 +75,35 @@ areTranslationsLoaded: false,

if (!this.state.areTranslationsLoaded) {
return _react.default.createElement("div", null);
return /*#__PURE__*/_react.default.createElement("div", null);
}
return _react.default.createElement(_terraI18n.I18nProvider, {
return /*#__PURE__*/_react.default.createElement(_terraI18n.I18nProvider, {
locale: this.state.locale,
messages: this.state.messages
}, _react.default.createElement("div", null, _react.default.createElement("span", null, " Example Message Format: "), _react.default.createElement(_reactIntl.FormattedMessage, {
}, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("span", null, " Example Message Format: "), /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
id: "Terra.ajax.error"
})), _react.default.createElement("p", null, _react.default.createElement("span", null, " Example Number Format: "), _react.default.createElement(_reactIntl.FormattedNumber, {
})), /*#__PURE__*/_react.default.createElement("p", null, /*#__PURE__*/_react.default.createElement("span", null, " Example Number Format: "), /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedNumber, {
value: parseFloat('1123432.123')
})), _react.default.createElement("p", null, _react.default.createElement("span", null, "Example Date Format: "), _react.default.createElement(_reactIntl.FormattedDate, {
})), /*#__PURE__*/_react.default.createElement("p", null, /*#__PURE__*/_react.default.createElement("span", null, "Example Date Format: "), /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedDate, {
value: new Date(1575476163287)
})), _react.default.createElement("label", {
})), /*#__PURE__*/_react.default.createElement("label", {
htmlFor: "locale"
}, ' ', "Current locale:", this.state.locale, ' '), _react.default.createElement("select", {
}, ' ', "Current locale:", this.state.locale, ' '), /*#__PURE__*/_react.default.createElement("select", {
id: "locale",
value: this.state.locale,
onChange: this.handleLocaleChange
}, _react.default.createElement("option", {
}, /*#__PURE__*/_react.default.createElement("option", {
value: "en"
}, "en"), _react.default.createElement("option", {
}, "en"), /*#__PURE__*/_react.default.createElement("option", {
value: "en-GB"
}, "en-GB"), _react.default.createElement("option", {
}, "en-GB"), /*#__PURE__*/_react.default.createElement("option", {
value: "en-US"
}, "en-US"), _react.default.createElement("option", {
}, "en-US"), /*#__PURE__*/_react.default.createElement("option", {
value: "de"
}, "de"), _react.default.createElement("option", {
}, "de"), /*#__PURE__*/_react.default.createElement("option", {
value: "es"
}, "es"), _react.default.createElement("option", {
}, "es"), /*#__PURE__*/_react.default.createElement("option", {
value: "fr"
}, "fr"), _react.default.createElement("option", {
}, "fr"), /*#__PURE__*/_react.default.createElement("option", {
value: "nl"
}, "nl"), _react.default.createElement("option", {
}, "nl"), /*#__PURE__*/_react.default.createElement("option", {
value: "pt"

@@ -112,5 +118,5 @@ }, "pt")));

var _default = function _default() {
return _react.default.createElement(Demo, null);
return /*#__PURE__*/_react.default.createElement(Demo, null);
};
exports.default = _default;

@@ -32,8 +32,12 @@ "use strict";

function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

@@ -51,2 +55,4 @@

var _super = _createSuper(Base);
function Base(props) {

@@ -57,3 +63,3 @@ var _this;

_this = _possibleConstructorReturn(this, _getPrototypeOf(Base).call(this, props));
_this = _super.call(this, props);
_this.state = {

@@ -86,11 +92,11 @@ selectedLocale: 'en',

if (!this.state.areTranslationsLoaded) {
return _react.default.createElement("div", null);
return /*#__PURE__*/_react.default.createElement("div", null);
}
return _react.default.createElement("div", null, _react.default.createElement(_I18nProvider.default, {
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_I18nProvider.default, {
locale: this.state.locale,
messages: this.state.messages
}, _react.default.createElement("label", {
}, /*#__PURE__*/_react.default.createElement("label", {
htmlFor: "change-locale"
}, " Current locale: "), _react.default.createElement("select", {
}, " Current locale: "), /*#__PURE__*/_react.default.createElement("select", {
id: "change-locale",

@@ -100,15 +106,15 @@ onChange: this.handleLocaleChange,

}, testLocales.map(function (locale) {
return _react.default.createElement("option", {
return /*#__PURE__*/_react.default.createElement("option", {
key: locale,
value: locale
}, locale);
})), _react.default.createElement("p", {
})), /*#__PURE__*/_react.default.createElement("p", {
id: "translated-message"
}, _react.default.createElement("span", {
}, /*#__PURE__*/_react.default.createElement("span", {
className: cx('weighted-text')
}, " Loaded locale message: "), _react.default.createElement(_reactIntl.FormattedMessage, {
}, " Loaded locale message: "), /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, {
id: "Terra.ajax.error"
})), this.state.selectedLocale.includes('zu') && _react.default.createElement("p", {
})), this.state.selectedLocale.includes('zu') && /*#__PURE__*/_react.default.createElement("p", {
className: cx('fallback-message')
}, "Using the en locale as fallback."), this.state.selectedLocale === 'pt-GW' && _react.default.createElement("p", {
}, "Using the en locale as fallback."), this.state.selectedLocale === 'pt-GW' && /*#__PURE__*/_react.default.createElement("p", {
className: cx('fallback-message')

@@ -130,5 +136,5 @@ }, "Using the pt locale as fallback.")));

var _default = function _default() {
return _react.default.createElement(Base, null);
return /*#__PURE__*/_react.default.createElement(Base, null);
};
exports.default = _default;
{
"name": "terra-i18n",
"main": "lib/I18n.js",
"version": "4.25.0",
"version": "4.26.0",
"description": "The terra-i18n package provides on-demand internationalization of React components.",

@@ -45,3 +45,3 @@ "repository": {

},
"gitHead": "28a1067266d1014f6ddab6f7ee74c82b66de024b"
"gitHead": "53b691e18d215fd8fd10da8cf03a22a0c3876f4e"
}

@@ -15,6 +15,17 @@ /* eslint-disable import/no-unresolved, compat/compat, no-console */

if (typeof (Intl) === 'object' && typeof (Intl.DateTimeFormat) === 'function' && typeof (Intl.NumberFormat) === 'function') {
constructors = [
Intl.DateTimeFormat,
Intl.NumberFormat,
];
/**
* intl-locales-supported accesses the 'supportedLocalesOf' property of each of these constructors.
* When certain polyfills are used, the polyfill may not have the 'supportedLocalesOf' property.
* For example, when using the date-time-format-timezone Intl.DateTimeFormat becomes Intl.DateTimeFormatPolyfill which does not support this property.
*
* Reference: https://github.com/cerner/terra-core/issues/2914
*/
if (Object.prototype.hasOwnProperty.call(Intl.DateTimeFormat, 'supportedLocalesOf') && Object.prototype.hasOwnProperty.call(Intl.NumberFormat, 'supportedLocalesOf')) {
constructors = [
Intl.DateTimeFormat,
Intl.NumberFormat,
];
} else {
constructors = [];
}
}

@@ -21,0 +32,0 @@ } catch (error) {

@@ -169,3 +169,10 @@ /* eslint-disable import/no-extraneous-dependencies, import/no-unresolved,no-console, compat/compat */

});
it('does not add supported Intl constructors if supportedLocalesOf property does not exist', () => {
delete Intl.DateTimeFormat.supportedLocalesOf;
delete Intl.NumberFormat.supportedLocalesOf;
defaultLoadIntl('en');
expect(hasIntlData).toHaveBeenNthCalledWith(1, ['en'], []);
});
});
});
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