You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-gettext

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-gettext - npm Package Compare versions

Comparing version

to
0.4.0

6

CHANGELOG.md
# Change Log
## v0.4.0 (2017-08-17)
**Implemented enhancements:**
- Implemented ability to get wrapped component.
## v0.3.3 (2017-08-12)

@@ -4,0 +10,0 @@

26

dist/react-gettext.js

@@ -698,4 +698,2 @@ (function webpackUniversalModuleDefinition(root, factory) {

exports.default = withGettext;
var _react = __webpack_require__(4);

@@ -721,8 +719,9 @@

exports.Textdomain = _Textdomain3.default;
function withGettext() {
var withGettext = function withGettext() {
var translations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var pluralForm = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'n != 1';
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
return function (WrappedComponent) {
var args = Object.assign({ withRef: false }, options);
return function (WrappedComponent) {
var WithGettext = function (_Textdomain) {

@@ -738,5 +737,15 @@ _inherits(WithGettext, _Textdomain);

_createClass(WithGettext, [{
key: 'getWrappedComponent',
value: function getWrappedComponent() {
return this.refs.wrappedComponent;
}
}, {
key: 'render',
value: function render() {
return _react2.default.createElement(WrappedComponent, this.props);
var newprops = Object.assign({}, this.props);
if (args.withRef) {
newprops.ref = 'wrappedComponent';
}
return _react2.default.createElement(WrappedComponent, newprops);
}

@@ -757,4 +766,7 @@ }]);

};
}
};
exports.Textdomain = _Textdomain3.default;
exports.default = withGettext;
/***/ }),

@@ -761,0 +773,0 @@ /* 9 */

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactGettext=t(require("react")):e.ReactGettext=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=8)}([function(e,t){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(e){if(l===setTimeout)return setTimeout(e,0);if((l===n||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}function i(e){if(s===clearTimeout)return clearTimeout(e);if((s===r||!s)&&clearTimeout)return s=clearTimeout,clearTimeout(e);try{return s(e)}catch(t){try{return s.call(null,e)}catch(t){return s.call(this,e)}}}function u(){h&&y&&(h=!1,y.length?d=y.concat(d):v=-1,d.length&&a())}function a(){if(!h){var e=o(u);h=!0;for(var t=d.length;t;){for(y=d,d=[];++v<t;)y&&y[v].run();v=-1,t=d.length}y=null,h=!1,i(e)}}function c(e,t){this.fun=e,this.array=t}function f(){}var l,s,p=e.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:n}catch(e){l=n}try{s="function"==typeof clearTimeout?clearTimeout:r}catch(e){s=r}}();var y,d=[],h=!1,v=-1;p.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];d.push(new c(e,t)),1!==d.length||h||o(a)},c.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=f,p.addListener=f,p.once=f,p.off=f,p.removeListener=f,p.removeAllListeners=f,p.emit=f,p.binding=function(e){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(e){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},function(e,t,n){"use strict";function r(e){return function(){return e}}var o=function(){};o.thatReturns=r,o.thatReturnsFalse=r(!1),o.thatReturnsTrue=r(!0),o.thatReturnsNull=r(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},e.exports=o},function(e,t,n){"use strict";(function(t){function n(e,t,n,o,i,u,a,c){if(r(t),!e){var f;if(void 0===t)f=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[n,o,i,u,a,c],s=0;f=new Error(t.replace(/%s/g,function(){return l[s++]})),f.name="Invariant Violation"}throw f.framesToPop=1,f}}var r=function(e){};"production"!==t.env.NODE_ENV&&(r=function(e){if(void 0===e)throw new Error("invariant requires an error message argument")}),e.exports=n}).call(t,n(0))},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(t,n){t.exports=e},function(e,t,n){"use strict";(function(t){var r=n(1),o=r;"production"!==t.env.NODE_ENV&&function(){var e=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var o=0,i="Warning: "+e.replace(/%s/g,function(){return n[o++]});"undefined"!=typeof console&&console.error(i);try{throw new Error(i)}catch(e){}};o=function(t,n){if(void 0===n)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(0!==n.indexOf("Failed Composite propType: ")&&!t){for(var r=arguments.length,o=Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];e.apply(void 0,[n].concat(o))}}}(),e.exports=o}).call(t,n(0))},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 i(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)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(4),c=n(12),f=function(e){return e&&e.__esModule?e:{default:e}}(c),l=function(e){function t(){return r(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),u(t,[{key:"getChildContext",value:function(){var e=this;return{gettext:e.gettext.bind(e),xgettext:e.xgettext.bind(e),ngettext:e.ngettext.bind(e),nxgettext:e.nxgettext.bind(e)}}},{key:"getTranslations",value:function(){var e=this.props.translations;return"function"==typeof e?e():e}},{key:"getPluralForm",value:function(e){var t=this.props.plural;if(isNaN(parseInt(e,10)))return 0;if("function"==typeof t)return t(e);if("string"==typeof t&&!t.match(/[^n0-9 !=?:%+-\/*><&|()]/i)){return+Function("n","return "+t)(e)}return 0}},{key:"getDelimiter",value:function(){return""}},{key:"gettext",value:function(e){var t=this.getTranslations();return Object.prototype.hasOwnProperty.call(t,e)?t[e]:e}},{key:"ngettext",value:function(e,t,n){var r=this,o=r.getTranslations(),i=r.getPluralForm(n),u=n>1?t:e;return Object.prototype.hasOwnProperty.call(o,e)&&Array.isArray(o[e])&&o[e].length>i&&i>=0?o[e][i]:u}},{key:"xgettext",value:function(e,t){var n=this,r=n.getDelimiter(),o=n.getTranslations(),i=t+r+e;return Object.prototype.hasOwnProperty.call(o,i)?o[i]:e}},{key:"nxgettext",value:function(e,t,n,r){var o=this,i=o.getTranslations(),u=o.getPluralForm(n),a=n>1?t:e,c=o.getDelimiter(),f=r+c+e;return Object.prototype.hasOwnProperty.call(i,f)&&Array.isArray(i[f])&&i[f].length>u&&u>=0?i[f][u]:a}},{key:"render",value:function(){return this.props.children}}]),t}(a.Component);l.propTypes={translations:f.default.oneOfType([f.default.func,f.default.objectOf(f.default.oneOfType([f.default.string,f.default.arrayOf(f.default.string)]))]),plural:f.default.oneOfType([f.default.func,f.default.string]),children:f.default.oneOfType([f.default.node,f.default.arrayOf(f.default.node)])},l.defaultProps={translations:{},plural:"n != 1",children:[]},l.childContextTypes={gettext:f.default.func,ngettext:f.default.func,xgettext:f.default.func,nxgettext:f.default.func},t.default=l},function(e,t,n){"use strict";var r={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},i="function"==typeof Object.getOwnPropertySymbols;e.exports=function(e,t,n){if("string"!=typeof t){var u=Object.getOwnPropertyNames(t);i&&(u=u.concat(Object.getOwnPropertySymbols(t)));for(var a=0;a<u.length;++a)if(!(r[u[a]]||o[u[a]]||n&&n[u[a]]))try{e[u[a]]=t[u[a]]}catch(e){}}return e}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(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 u(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)}function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"n != 1";return function(n){var r=function(e){function t(){return o(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,e),c(t,[{key:"render",value:function(){return l.default.createElement(n,this.props)}}]),t}(d.default);return r.defaultProps={translations:e,plural:t},r.displayName="withGettext("+(n.displayName||n.name||"Component")+")",(0,p.default)(r,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.Textdomain=void 0;var c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.default=a;var f=n(4),l=r(f),s=n(7),p=r(s),y=n(6),d=r(y);t.Textdomain=d.default},function(e,t,n){"use strict";(function(t){function r(e,n,r,c,f){if("production"!==t.env.NODE_ENV)for(var l in e)if(e.hasOwnProperty(l)){var s;try{o("function"==typeof e[l],"%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",c||"React class",r,l),s=e[l](n,l,c,r,null,u)}catch(e){s=e}if(i(!s||s instanceof Error,"%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",c||"React class",r,l,typeof s),s instanceof Error&&!(s.message in a)){a[s.message]=!0;var p=f?f():"";i(!1,"Failed %s type: %s%s",r,s.message,null!=p?p:"")}}}if("production"!==t.env.NODE_ENV)var o=n(2),i=n(5),u=n(3),a={};e.exports=r}).call(t,n(0))},function(e,t,n){"use strict";var r=n(1),o=n(2),i=n(3);e.exports=function(){function e(e,t,n,r,u,a){a!==i&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t};return n.checkPropTypes=r,n.PropTypes=n,n}},function(e,t,n){"use strict";(function(t){var r=n(1),o=n(2),i=n(5),u=n(3),a=n(9);e.exports=function(e,n){function c(e){var t=e&&(P&&e[P]||e[_]);if("function"==typeof t)return t}function f(e,t){return e===t?0!==e||1/e==1/t:e!==e&&t!==t}function l(e){this.message=e,this.stack=""}function s(e){function r(r,f,s,p,y,d,h){if(p=p||j,d=d||s,h!==u)if(n)o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");else if("production"!==t.env.NODE_ENV&&"undefined"!=typeof console){var v=p+":"+s;!a[v]&&c<3&&(i(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",d,p),a[v]=!0,c++)}return null==f[s]?r?new l(null===f[s]?"The "+y+" `"+d+"` is marked as required in `"+p+"`, but its value is `null`.":"The "+y+" `"+d+"` is marked as required in `"+p+"`, but its value is `undefined`."):null:e(f,s,p,y,d)}if("production"!==t.env.NODE_ENV)var a={},c=0;var f=r.bind(null,!1);return f.isRequired=r.bind(null,!0),f}function p(e){function t(t,n,r,o,i,u){var a=t[n];if(x(a)!==e)return new l("Invalid "+o+" `"+i+"` of type `"+w(a)+"` supplied to `"+r+"`, expected `"+e+"`.");return null}return s(t)}function y(e){function t(t,n,r,o,i){if("function"!=typeof e)return new l("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var a=t[n];if(!Array.isArray(a)){return new l("Invalid "+o+" `"+i+"` of type `"+x(a)+"` supplied to `"+r+"`, expected an array.")}for(var c=0;c<a.length;c++){var f=e(a,c,r,o,i+"["+c+"]",u);if(f instanceof Error)return f}return null}return s(t)}function d(e){function t(t,n,r,o,i){if(!(t[n]instanceof e)){var u=e.name||j;return new l("Invalid "+o+" `"+i+"` of type `"+E(t[n])+"` supplied to `"+r+"`, expected instance of `"+u+"`.")}return null}return s(t)}function h(e){function n(t,n,r,o,i){for(var u=t[n],a=0;a<e.length;a++)if(f(u,e[a]))return null;return new l("Invalid "+o+" `"+i+"` of value `"+u+"` supplied to `"+r+"`, expected one of "+JSON.stringify(e)+".")}return Array.isArray(e)?s(n):("production"!==t.env.NODE_ENV&&i(!1,"Invalid argument supplied to oneOf, expected an instance of array."),r.thatReturnsNull)}function v(e){function t(t,n,r,o,i){if("function"!=typeof e)return new l("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var a=t[n],c=x(a);if("object"!==c)return new l("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+r+"`, expected an object.");for(var f in a)if(a.hasOwnProperty(f)){var s=e(a,f,r,o,i+"."+f,u);if(s instanceof Error)return s}return null}return s(t)}function m(e){function n(t,n,r,o,i){for(var a=0;a<e.length;a++){if(null==(0,e[a])(t,n,r,o,i,u))return null}return new l("Invalid "+o+" `"+i+"` supplied to `"+r+"`.")}if(!Array.isArray(e))return"production"!==t.env.NODE_ENV&&i(!1,"Invalid argument supplied to oneOfType, expected an instance of array."),r.thatReturnsNull;for(var o=0;o<e.length;o++){var a=e[o];if("function"!=typeof a)return i(!1,"Invalid argument supplid to oneOfType. Expected an array of check functions, but received %s at index %s.",T(a),o),r.thatReturnsNull}return s(n)}function g(e){function t(t,n,r,o,i){var a=t[n],c=x(a);if("object"!==c)return new l("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+r+"`, expected `object`.");for(var f in e){var s=e[f];if(s){var p=s(a,f,r,o,i+"."+f,u);if(p)return p}}return null}return s(t)}function b(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(b);if(null===t||e(t))return!0;var n=c(t);if(!n)return!1;var r,o=n.call(t);if(n!==t.entries){for(;!(r=o.next()).done;)if(!b(r.value))return!1}else for(;!(r=o.next()).done;){var i=r.value;if(i&&!b(i[1]))return!1}return!0;default:return!1}}function O(e,t){return"symbol"===e||("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}function x(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":O(t,e)?"symbol":t}function w(e){if(void 0===e||null===e)return""+e;var t=x(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function T(e){var t=w(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}function E(e){return e.constructor&&e.constructor.name?e.constructor.name:j}var P="function"==typeof Symbol&&Symbol.iterator,_="@@iterator",j="<<anonymous>>",N={array:p("array"),bool:p("boolean"),func:p("function"),number:p("number"),object:p("object"),string:p("string"),symbol:p("symbol"),any:function(){return s(r.thatReturnsNull)}(),arrayOf:y,element:function(){function t(t,n,r,o,i){var u=t[n];if(!e(u)){return new l("Invalid "+o+" `"+i+"` of type `"+x(u)+"` supplied to `"+r+"`, expected a single ReactElement.")}return null}return s(t)}(),instanceOf:d,node:function(){function e(e,t,n,r,o){return b(e[t])?null:new l("Invalid "+r+" `"+o+"` supplied to `"+n+"`, expected a ReactNode.")}return s(e)}(),objectOf:v,oneOf:h,oneOfType:m,shape:g};return l.prototype=Error.prototype,N.checkPropTypes=a,N.PropTypes=N,N}}).call(t,n(0))},function(e,t,n){(function(t){if("production"!==t.env.NODE_ENV){var r="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,o=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r};e.exports=n(11)(o,!0)}else e.exports=n(10)()}).call(t,n(0))}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactGettext=t(require("react")):e.ReactGettext=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=8)}([function(e,t){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(e){if(s===setTimeout)return setTimeout(e,0);if((s===n||!s)&&setTimeout)return s=setTimeout,setTimeout(e,0);try{return s(e,0)}catch(t){try{return s.call(null,e,0)}catch(t){return s.call(this,e,0)}}}function i(e){if(l===clearTimeout)return clearTimeout(e);if((l===r||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(e);try{return l(e)}catch(t){try{return l.call(null,e)}catch(t){return l.call(this,e)}}}function u(){h&&y&&(h=!1,y.length?d=y.concat(d):v=-1,d.length&&a())}function a(){if(!h){var e=o(u);h=!0;for(var t=d.length;t;){for(y=d,d=[];++v<t;)y&&y[v].run();v=-1,t=d.length}y=null,h=!1,i(e)}}function c(e,t){this.fun=e,this.array=t}function f(){}var s,l,p=e.exports={};!function(){try{s="function"==typeof setTimeout?setTimeout:n}catch(e){s=n}try{l="function"==typeof clearTimeout?clearTimeout:r}catch(e){l=r}}();var y,d=[],h=!1,v=-1;p.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];d.push(new c(e,t)),1!==d.length||h||o(a)},c.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=f,p.addListener=f,p.once=f,p.off=f,p.removeListener=f,p.removeAllListeners=f,p.emit=f,p.binding=function(e){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(e){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},function(e,t,n){"use strict";function r(e){return function(){return e}}var o=function(){};o.thatReturns=r,o.thatReturnsFalse=r(!1),o.thatReturnsTrue=r(!0),o.thatReturnsNull=r(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},e.exports=o},function(e,t,n){"use strict";(function(t){function n(e,t,n,o,i,u,a,c){if(r(t),!e){var f;if(void 0===t)f=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=[n,o,i,u,a,c],l=0;f=new Error(t.replace(/%s/g,function(){return s[l++]})),f.name="Invariant Violation"}throw f.framesToPop=1,f}}var r=function(e){};"production"!==t.env.NODE_ENV&&(r=function(e){if(void 0===e)throw new Error("invariant requires an error message argument")}),e.exports=n}).call(t,n(0))},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(t,n){t.exports=e},function(e,t,n){"use strict";(function(t){var r=n(1),o=r;"production"!==t.env.NODE_ENV&&function(){var e=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var o=0,i="Warning: "+e.replace(/%s/g,function(){return n[o++]});"undefined"!=typeof console&&console.error(i);try{throw new Error(i)}catch(e){}};o=function(t,n){if(void 0===n)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(0!==n.indexOf("Failed Composite propType: ")&&!t){for(var r=arguments.length,o=Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];e.apply(void 0,[n].concat(o))}}}(),e.exports=o}).call(t,n(0))},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 i(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)}Object.defineProperty(t,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(4),c=n(12),f=function(e){return e&&e.__esModule?e:{default:e}}(c),s=function(e){function t(){return r(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),u(t,[{key:"getChildContext",value:function(){var e=this;return{gettext:e.gettext.bind(e),xgettext:e.xgettext.bind(e),ngettext:e.ngettext.bind(e),nxgettext:e.nxgettext.bind(e)}}},{key:"getTranslations",value:function(){var e=this.props.translations;return"function"==typeof e?e():e}},{key:"getPluralForm",value:function(e){var t=this.props.plural;if(isNaN(parseInt(e,10)))return 0;if("function"==typeof t)return t(e);if("string"==typeof t&&!t.match(/[^n0-9 !=?:%+-\/*><&|()]/i)){return+Function("n","return "+t)(e)}return 0}},{key:"getDelimiter",value:function(){return""}},{key:"gettext",value:function(e){var t=this.getTranslations();return Object.prototype.hasOwnProperty.call(t,e)?t[e]:e}},{key:"ngettext",value:function(e,t,n){var r=this,o=r.getTranslations(),i=r.getPluralForm(n),u=n>1?t:e;return Object.prototype.hasOwnProperty.call(o,e)&&Array.isArray(o[e])&&o[e].length>i&&i>=0?o[e][i]:u}},{key:"xgettext",value:function(e,t){var n=this,r=n.getDelimiter(),o=n.getTranslations(),i=t+r+e;return Object.prototype.hasOwnProperty.call(o,i)?o[i]:e}},{key:"nxgettext",value:function(e,t,n,r){var o=this,i=o.getTranslations(),u=o.getPluralForm(n),a=n>1?t:e,c=o.getDelimiter(),f=r+c+e;return Object.prototype.hasOwnProperty.call(i,f)&&Array.isArray(i[f])&&i[f].length>u&&u>=0?i[f][u]:a}},{key:"render",value:function(){return this.props.children}}]),t}(a.Component);s.propTypes={translations:f.default.oneOfType([f.default.func,f.default.objectOf(f.default.oneOfType([f.default.string,f.default.arrayOf(f.default.string)]))]),plural:f.default.oneOfType([f.default.func,f.default.string]),children:f.default.oneOfType([f.default.node,f.default.arrayOf(f.default.node)])},s.defaultProps={translations:{},plural:"n != 1",children:[]},s.childContextTypes={gettext:f.default.func,ngettext:f.default.func,xgettext:f.default.func,nxgettext:f.default.func},t.default=s},function(e,t,n){"use strict";var r={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},i="function"==typeof Object.getOwnPropertySymbols;e.exports=function(e,t,n){if("string"!=typeof t){var u=Object.getOwnPropertyNames(t);i&&(u=u.concat(Object.getOwnPropertySymbols(t)));for(var a=0;a<u.length;++a)if(!(r[u[a]]||o[u[a]]||n&&n[u[a]]))try{e[u[a]]=t[u[a]]}catch(e){}}return e}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(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 u(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)}Object.defineProperty(t,"__esModule",{value:!0}),t.Textdomain=void 0;var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(4),f=r(c),s=n(7),l=r(s),p=n(6),y=r(p),d=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"n != 1",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(r){var c=Object.assign({withRef:!1},n),s=function(e){function t(){return o(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,e),a(t,[{key:"getWrappedComponent",value:function(){return this.refs.wrappedComponent}},{key:"render",value:function(){var e=Object.assign({},this.props);return c.withRef&&(e.ref="wrappedComponent"),f.default.createElement(r,e)}}]),t}(y.default);return s.defaultProps={translations:e,plural:t},s.displayName="withGettext("+(r.displayName||r.name||"Component")+")",(0,l.default)(s,r)}};t.Textdomain=y.default,t.default=d},function(e,t,n){"use strict";(function(t){function r(e,n,r,c,f){if("production"!==t.env.NODE_ENV)for(var s in e)if(e.hasOwnProperty(s)){var l;try{o("function"==typeof e[s],"%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",c||"React class",r,s),l=e[s](n,s,c,r,null,u)}catch(e){l=e}if(i(!l||l instanceof Error,"%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",c||"React class",r,s,typeof l),l instanceof Error&&!(l.message in a)){a[l.message]=!0;var p=f?f():"";i(!1,"Failed %s type: %s%s",r,l.message,null!=p?p:"")}}}if("production"!==t.env.NODE_ENV)var o=n(2),i=n(5),u=n(3),a={};e.exports=r}).call(t,n(0))},function(e,t,n){"use strict";var r=n(1),o=n(2),i=n(3);e.exports=function(){function e(e,t,n,r,u,a){a!==i&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t};return n.checkPropTypes=r,n.PropTypes=n,n}},function(e,t,n){"use strict";(function(t){var r=n(1),o=n(2),i=n(5),u=n(3),a=n(9);e.exports=function(e,n){function c(e){var t=e&&(P&&e[P]||e[j]);if("function"==typeof t)return t}function f(e,t){return e===t?0!==e||1/e==1/t:e!==e&&t!==t}function s(e){this.message=e,this.stack=""}function l(e){function r(r,f,l,p,y,d,h){if(p=p||_,d=d||l,h!==u)if(n)o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");else if("production"!==t.env.NODE_ENV&&"undefined"!=typeof console){var v=p+":"+l;!a[v]&&c<3&&(i(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",d,p),a[v]=!0,c++)}return null==f[l]?r?new s(null===f[l]?"The "+y+" `"+d+"` is marked as required in `"+p+"`, but its value is `null`.":"The "+y+" `"+d+"` is marked as required in `"+p+"`, but its value is `undefined`."):null:e(f,l,p,y,d)}if("production"!==t.env.NODE_ENV)var a={},c=0;var f=r.bind(null,!1);return f.isRequired=r.bind(null,!0),f}function p(e){function t(t,n,r,o,i,u){var a=t[n];if(x(a)!==e)return new s("Invalid "+o+" `"+i+"` of type `"+w(a)+"` supplied to `"+r+"`, expected `"+e+"`.");return null}return l(t)}function y(e){function t(t,n,r,o,i){if("function"!=typeof e)return new s("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var a=t[n];if(!Array.isArray(a)){return new s("Invalid "+o+" `"+i+"` of type `"+x(a)+"` supplied to `"+r+"`, expected an array.")}for(var c=0;c<a.length;c++){var f=e(a,c,r,o,i+"["+c+"]",u);if(f instanceof Error)return f}return null}return l(t)}function d(e){function t(t,n,r,o,i){if(!(t[n]instanceof e)){var u=e.name||_;return new s("Invalid "+o+" `"+i+"` of type `"+E(t[n])+"` supplied to `"+r+"`, expected instance of `"+u+"`.")}return null}return l(t)}function h(e){function n(t,n,r,o,i){for(var u=t[n],a=0;a<e.length;a++)if(f(u,e[a]))return null;return new s("Invalid "+o+" `"+i+"` of value `"+u+"` supplied to `"+r+"`, expected one of "+JSON.stringify(e)+".")}return Array.isArray(e)?l(n):("production"!==t.env.NODE_ENV&&i(!1,"Invalid argument supplied to oneOf, expected an instance of array."),r.thatReturnsNull)}function v(e){function t(t,n,r,o,i){if("function"!=typeof e)return new s("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var a=t[n],c=x(a);if("object"!==c)return new s("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+r+"`, expected an object.");for(var f in a)if(a.hasOwnProperty(f)){var l=e(a,f,r,o,i+"."+f,u);if(l instanceof Error)return l}return null}return l(t)}function m(e){function n(t,n,r,o,i){for(var a=0;a<e.length;a++){if(null==(0,e[a])(t,n,r,o,i,u))return null}return new s("Invalid "+o+" `"+i+"` supplied to `"+r+"`.")}if(!Array.isArray(e))return"production"!==t.env.NODE_ENV&&i(!1,"Invalid argument supplied to oneOfType, expected an instance of array."),r.thatReturnsNull;for(var o=0;o<e.length;o++){var a=e[o];if("function"!=typeof a)return i(!1,"Invalid argument supplid to oneOfType. Expected an array of check functions, but received %s at index %s.",T(a),o),r.thatReturnsNull}return l(n)}function g(e){function t(t,n,r,o,i){var a=t[n],c=x(a);if("object"!==c)return new s("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+r+"`, expected `object`.");for(var f in e){var l=e[f];if(l){var p=l(a,f,r,o,i+"."+f,u);if(p)return p}}return null}return l(t)}function b(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(b);if(null===t||e(t))return!0;var n=c(t);if(!n)return!1;var r,o=n.call(t);if(n!==t.entries){for(;!(r=o.next()).done;)if(!b(r.value))return!1}else for(;!(r=o.next()).done;){var i=r.value;if(i&&!b(i[1]))return!1}return!0;default:return!1}}function O(e,t){return"symbol"===e||("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}function x(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":O(t,e)?"symbol":t}function w(e){if(void 0===e||null===e)return""+e;var t=x(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function T(e){var t=w(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}function E(e){return e.constructor&&e.constructor.name?e.constructor.name:_}var P="function"==typeof Symbol&&Symbol.iterator,j="@@iterator",_="<<anonymous>>",N={array:p("array"),bool:p("boolean"),func:p("function"),number:p("number"),object:p("object"),string:p("string"),symbol:p("symbol"),any:function(){return l(r.thatReturnsNull)}(),arrayOf:y,element:function(){function t(t,n,r,o,i){var u=t[n];if(!e(u)){return new s("Invalid "+o+" `"+i+"` of type `"+x(u)+"` supplied to `"+r+"`, expected a single ReactElement.")}return null}return l(t)}(),instanceOf:d,node:function(){function e(e,t,n,r,o){return b(e[t])?null:new s("Invalid "+r+" `"+o+"` supplied to `"+n+"`, expected a ReactNode.")}return l(e)}(),objectOf:v,oneOf:h,oneOfType:m,shape:g};return s.prototype=Error.prototype,N.checkPropTypes=a,N.PropTypes=N,N}}).call(t,n(0))},function(e,t,n){(function(t){if("production"!==t.env.NODE_ENV){var r="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,o=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r};e.exports=n(11)(o,!0)}else e.exports=n(10)()}).call(t,n(0))}])});

@@ -10,4 +10,2 @@ 'use strict';

exports.default = withGettext;
var _react = require('react');

@@ -33,8 +31,9 @@

exports.Textdomain = _Textdomain3.default;
function withGettext() {
var withGettext = function withGettext() {
var translations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var pluralForm = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'n != 1';
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
return function (WrappedComponent) {
var args = Object.assign({ withRef: false }, options);
return function (WrappedComponent) {
var WithGettext = function (_Textdomain) {

@@ -50,5 +49,15 @@ _inherits(WithGettext, _Textdomain);

_createClass(WithGettext, [{
key: 'getWrappedComponent',
value: function getWrappedComponent() {
return this.refs.wrappedComponent;
}
}, {
key: 'render',
value: function render() {
return _react2.default.createElement(WrappedComponent, this.props);
var newprops = Object.assign({}, this.props);
if (args.withRef) {
newprops.ref = 'wrappedComponent';
}
return _react2.default.createElement(WrappedComponent, newprops);
}

@@ -69,2 +78,5 @@ }]);

};
}
};
exports.Textdomain = _Textdomain3.default;
exports.default = withGettext;

@@ -10,3 +10,3 @@ {

},
"version": "0.3.3",
"version": "0.4.0",
"main": "lib/index",

@@ -13,0 +13,0 @@ "files": [

@@ -1,4 +0,4 @@

# react-gettext 0.3.3
# react-gettext 0.4.0
[![Build Status](https://travis-ci.org/eugene-manuilov/react-gettext.svg?branch=master)](https://travis-ci.org/eugene-manuilov/react-gettext)
[![npm version](https://badge.fury.io/js/react-gettext.svg)](https://badge.fury.io/js/react-gettext) [![Build Status](https://travis-ci.org/eugene-manuilov/react-gettext.svg?branch=master)](https://travis-ci.org/eugene-manuilov/react-gettext)

@@ -107,3 +107,3 @@ Tiny React library for implementing gettext localization in your application. It provides HOC function to enhance your application by exposing gettext functions in the context scope.

### withGettext(translations, pluralForms)
### withGettext(translations, pluralForms, options)

@@ -114,2 +114,4 @@ Higher-order function which is exported by default from `react-gettext` package. It accepts two arguments and returns function to create higher-order component.

- **pluralForms**: a string to calculate plural form (used by [Gettext PO](http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html?id=l10n/pluralforms)) or a function which accepts a number and calculates a plural form number. Pay attentions that plural forms are zero-based what means to get 1st plural form it should return 0, to get 2nd - 1, and so on.
- **options**: a hash object with options. Currently supports following options:
- **withRef**: an optional boolean flag that determines whether or not to set `ref` property to a wrapped component what will allow you to get wrapped component instance by calling `getWrappedComponent()` function of the HOC. By default: `FALSE`.

@@ -116,0 +118,0 @@ Example:

@@ -5,23 +5,33 @@ import React from 'react';

export { Textdomain };
const withGettext = (translations = {}, pluralForm = 'n != 1', options = {}) => (WrappedComponent) => {
const args = Object.assign({ withRef: false }, options);
export default function withGettext(translations = {}, pluralForm = 'n != 1') {
return (WrappedComponent) => {
class WithGettext extends Textdomain {
class WithGettext extends Textdomain {
render() {
return React.createElement(WrappedComponent, this.props);
getWrappedComponent() {
return this.refs.wrappedComponent;
}
render() {
const newprops = Object.assign({}, this.props);
if (args.withRef) {
newprops.ref = 'wrappedComponent';
}
return React.createElement(WrappedComponent, newprops);
}
WithGettext.defaultProps = {
translations,
plural: pluralForm,
};
}
WithGettext.displayName = `withGettext(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;
WithGettext.defaultProps = {
translations,
plural: pluralForm,
};
return hoistNonReactStatic(WithGettext, WrappedComponent);
};
}
WithGettext.displayName = `withGettext(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;
return hoistNonReactStatic(WithGettext, WrappedComponent);
};
export { Textdomain };
export default withGettext;