react-localize
Advanced tools
Comparing version 5.0.0 to 5.0.1
@@ -10,2 +10,6 @@ # Change Log | ||
## 2019-07-15 5.0.1 | ||
### Changed | ||
- Provide ability to use empty string as translation | ||
## 2019-05-01 5.0.0 | ||
@@ -12,0 +16,0 @@ ### Added |
@@ -521,3 +521,3 @@ (function (global, factory) { | ||
var lookup = messages[key]; | ||
if (!lookup) { | ||
if (!lookup && typeof lookup !== 'string') { | ||
if (debug) console.warn('Unable to localize missing messages or key in arguments for ' + key); | ||
@@ -524,0 +524,0 @@ return key; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],t):t(e.ReactLocalize={},e.React,e.PropTypes)}(this,function(e,t,o){"use strict";var b="default"in t?t.default:t;o=o&&o.hasOwnProperty("default")?o.default:o;var n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function i(e,t){return e(t={exports:{}},t.exports),t.exports}function a(){return n[u]=(n[u]||0)+1}var u="__global_unique_id__";function l(e){return function(){return e}}function c(){}c.thatReturns=l,c.thatReturnsFalse=l(!1),c.thatReturnsTrue=l(!0),c.thatReturnsNull=l(null),c.thatReturnsThis=function(){return this},c.thatReturnsArgument=function(e){return e};var s=c,f=i(function(e,t){t.__esModule=!0;n(b);var f=n(o),p=n(a);n(s);function n(e){return e&&e.__esModule?e:{default:e}}function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function y(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var v=1073741823;t.default=function(e,r){var t,n,i,o="__create-react-context-"+(0,p.default)()+"__",a=(y(u,i=b.Component),u.prototype.getChildContext=function(){var e;return(e={})[o]=this.emitter,e},u.prototype.componentWillReceiveProps=function(e){if(this.props.value!==e.value){var t=this.props.value,n=e.value,o=void 0;!function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(t,n)?(o="function"==typeof r?r(t,n):v,0!=(o|=0)&&this.emitter.set(e.value,o)):o=0}},u.prototype.render=function(){return this.props.children},u);function u(){var e,t;d(this,u);for(var n=arguments.length,o=Array(n),r=0;r<n;r++)o[r]=arguments[r];return(e=t=h(this,i.call.apply(i,[this].concat(o)))).emitter=function(n){var o=[];return{on:function(e){o.push(e)},off:function(t){o=o.filter(function(e){return e!==t})},get:function(){return n},set:function(e,t){n=e,o.forEach(function(e){return e(n,t)})}}}(t.props.value),h(t,e)}a.childContextTypes=((t={})[o]=f.default.object.isRequired,t);var l,c=(y(s,l=b.Component),s.prototype.componentWillReceiveProps=function(e){var t=e.observedBits;this.observedBits=null==t?v:t},s.prototype.componentDidMount=function(){this.context[o]&&this.context[o].on(this.onUpdate);var e=this.props.observedBits;this.observedBits=null==e?v:e},s.prototype.componentWillUnmount=function(){this.context[o]&&this.context[o].off(this.onUpdate)},s.prototype.getValue=function(){return this.context[o]?this.context[o].get():e},s.prototype.render=function(){return function(e){return Array.isArray(e)?e[0]:e}(this.props.children)(this.state.value)},s);function s(){var e,n;d(this,s);for(var t=arguments.length,o=Array(t),r=0;r<t;r++)o[r]=arguments[r];return(e=n=h(this,l.call.apply(l,[this].concat(o)))).state={value:n.getValue()},n.onUpdate=function(e,t){0!=((0|n.observedBits)&t)&&n.setState({value:n.getValue()})},h(n,e)}return c.contextTypes=((n={})[o]=f.default.object,n),{Provider:a,Consumer:c}},e.exports=t.default});r(f);var p=r(i(function(e,t){t.__esModule=!0;var n=r(b),o=r(f);function r(e){return e&&e.__esModule?e:{default:e}}t.default=n.default.createContext||o.default,e.exports=t.default}));function d(e){e+="";var i=Array.prototype.slice.call(arguments,1);return i.length&&(e=e.replace(/(%?)(%([jds]))/g,function(e,t,n,o){var r=i.shift();switch(o){case"s":r=""+r;break;case"d":r=+r;break;case"j":r=JSON.stringify(r)}return t?(i.unshift(r),e):r})),i.length&&(e+=" "+i.join(" ")),""+(e=e.replace(/%{2,2}/g,"%"))}var h=function(e,t,n){return t&&y(e.prototype,t),n&&y(e,n),e};function y(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function v(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var g=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},_=p({localize:function(e){return e},debug:!0,xLocale:!1}),m=(function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(w,b.Component),h(w,[{key:"render",value:function(){var e=this.props;return b.createElement(_.Provider,{value:{localize:this._localize,xLocale:e.xLocale,debug:e.debug}},this.props.children)}}]),w);function w(){var e,t,l;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,w);for(var n=arguments.length,o=Array(n),r=0;r<n;r++)o[r]=arguments[r];return(t=l=v(this,(e=w.__proto__||Object.getPrototypeOf(w)).call.apply(e,[this].concat(o))))._localize=function(e,t){var n=l.props,o=n.localize,r=n.xLocale,i=n.messages,a=n.debug,u=o;return"function"!=typeof o&&(u=function(e,t){return a&&console.warn("Unable to localize "+t+", not connected to react-localize"),t}),o!==w.defaultProps.localize?u(i,e,t,r,a):i&&e?i[e]?r?"XXXXXX":u(i,e,t):(a&&console.warn("Unable to localize missing messages or key in arguments for "+e),e):(a&&console.warn("Unable to localize missing messages or key in arguments."),null)},v(l,t)}m.defaultProps={debug:!1,localize:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;return n?d(e[t],n):d(e[t])},xLocale:!1};var x=_.Consumer;e.useLocalize=function(){return t.useContext?t.useContext(_):(console.warn("This feature is only available in React >= 16.8"),{})},e.LocalizationProvider=m,e.LocalizationConsumer=x,e.withLocalization=function(n){function e(t){return b.createElement(x,null,function(e){return b.createElement(n,g({},t,{localize:e.localize}))})}return e.displayName="withLocalization("+n.name+")",e},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["exports","react","prop-types"],t):t(e.ReactLocalize={},e.React,e.PropTypes)}(this,function(e,t,o){"use strict";var b="default"in t?t.default:t;o=o&&o.hasOwnProperty("default")?o.default:o;var n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function i(e,t){return e(t={exports:{}},t.exports),t.exports}function a(){return n[u]=(n[u]||0)+1}var u="__global_unique_id__";function l(e){return function(){return e}}function c(){}c.thatReturns=l,c.thatReturnsFalse=l(!1),c.thatReturnsTrue=l(!0),c.thatReturnsNull=l(null),c.thatReturnsThis=function(){return this},c.thatReturnsArgument=function(e){return e};var s=c,f=i(function(e,t){t.__esModule=!0;n(b);var f=n(o),p=n(a);n(s);function n(e){return e&&e.__esModule?e:{default:e}}function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function y(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var v=1073741823;t.default=function(e,r){var t,n,i,o="__create-react-context-"+(0,p.default)()+"__",a=(y(u,i=b.Component),u.prototype.getChildContext=function(){var e;return(e={})[o]=this.emitter,e},u.prototype.componentWillReceiveProps=function(e){if(this.props.value!==e.value){var t=this.props.value,n=e.value,o=void 0;!function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}(t,n)?(o="function"==typeof r?r(t,n):v,0!=(o|=0)&&this.emitter.set(e.value,o)):o=0}},u.prototype.render=function(){return this.props.children},u);function u(){var e,t;d(this,u);for(var n=arguments.length,o=Array(n),r=0;r<n;r++)o[r]=arguments[r];return(e=t=h(this,i.call.apply(i,[this].concat(o)))).emitter=function(n){var o=[];return{on:function(e){o.push(e)},off:function(t){o=o.filter(function(e){return e!==t})},get:function(){return n},set:function(e,t){n=e,o.forEach(function(e){return e(n,t)})}}}(t.props.value),h(t,e)}a.childContextTypes=((t={})[o]=f.default.object.isRequired,t);var l,c=(y(s,l=b.Component),s.prototype.componentWillReceiveProps=function(e){var t=e.observedBits;this.observedBits=null==t?v:t},s.prototype.componentDidMount=function(){this.context[o]&&this.context[o].on(this.onUpdate);var e=this.props.observedBits;this.observedBits=null==e?v:e},s.prototype.componentWillUnmount=function(){this.context[o]&&this.context[o].off(this.onUpdate)},s.prototype.getValue=function(){return this.context[o]?this.context[o].get():e},s.prototype.render=function(){return function(e){return Array.isArray(e)?e[0]:e}(this.props.children)(this.state.value)},s);function s(){var e,n;d(this,s);for(var t=arguments.length,o=Array(t),r=0;r<t;r++)o[r]=arguments[r];return(e=n=h(this,l.call.apply(l,[this].concat(o)))).state={value:n.getValue()},n.onUpdate=function(e,t){0!=((0|n.observedBits)&t)&&n.setState({value:n.getValue()})},h(n,e)}return c.contextTypes=((n={})[o]=f.default.object,n),{Provider:a,Consumer:c}},e.exports=t.default});r(f);var p=r(i(function(e,t){t.__esModule=!0;var n=r(b),o=r(f);function r(e){return e&&e.__esModule?e:{default:e}}t.default=n.default.createContext||o.default,e.exports=t.default}));function d(e){e+="";var i=Array.prototype.slice.call(arguments,1);return i.length&&(e=e.replace(/(%?)(%([jds]))/g,function(e,t,n,o){var r=i.shift();switch(o){case"s":r=""+r;break;case"d":r=+r;break;case"j":r=JSON.stringify(r)}return t?(i.unshift(r),e):r})),i.length&&(e+=" "+i.join(" ")),""+(e=e.replace(/%{2,2}/g,"%"))}var h=function(e,t,n){return t&&y(e.prototype,t),n&&y(e,n),e};function y(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function v(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var g=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},_=p({localize:function(e){return e},debug:!0,xLocale:!1}),m=(function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(w,b.Component),h(w,[{key:"render",value:function(){var e=this.props;return b.createElement(_.Provider,{value:{localize:this._localize,xLocale:e.xLocale,debug:e.debug}},this.props.children)}}]),w);function w(){var e,t,c;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,w);for(var n=arguments.length,o=Array(n),r=0;r<n;r++)o[r]=arguments[r];return(t=c=v(this,(e=w.__proto__||Object.getPrototypeOf(w)).call.apply(e,[this].concat(o))))._localize=function(e,t){var n=c.props,o=n.localize,r=n.xLocale,i=n.messages,a=n.debug,u=o;if("function"!=typeof o&&(u=function(e,t){return a&&console.warn("Unable to localize "+t+", not connected to react-localize"),t}),o!==w.defaultProps.localize)return u(i,e,t,r,a);if(!i||!e)return a&&console.warn("Unable to localize missing messages or key in arguments."),null;var l=i[e];return l||"string"==typeof l?r?"XXXXXX":u(i,e,t):(a&&console.warn("Unable to localize missing messages or key in arguments for "+e),e)},v(c,t)}m.defaultProps={debug:!1,localize:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;return n?d(e[t],n):d(e[t])},xLocale:!1};var x=_.Consumer;e.useLocalize=function(){return t.useContext?t.useContext(_):(console.warn("This feature is only available in React >= 16.8"),{})},e.LocalizationProvider=m,e.LocalizationConsumer=x,e.withLocalization=function(n){function e(t){return b.createElement(x,null,function(e){return b.createElement(n,g({},t,{localize:e.localize}))})}return e.displayName="withLocalization("+n.name+")",e},Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -77,3 +77,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var lookup = messages[key]; | ||
if (!lookup) { | ||
if (!lookup && typeof lookup !== 'string') { | ||
if (debug) console.warn('Unable to localize missing messages or key in arguments for ' + key); | ||
@@ -80,0 +80,0 @@ return key; |
@@ -70,3 +70,3 @@ 'use strict'; | ||
const lookup = messages[key]; | ||
if (!lookup) { | ||
if (!lookup && typeof lookup !== 'string') { | ||
if (debug) console.warn(`Unable to localize missing messages or key in arguments for ${key}`); | ||
@@ -73,0 +73,0 @@ return key; |
{ | ||
"name": "react-localize", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "A simple context wrapper and text localization component for localizing strings", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
46704
0