react-gettext

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-gettext - npm Package Compare versions

Comparing version

to
1.0.1

# Change Log
## v1.0.1 (2019-11-21)
- Fixed babel-preset-env browser targets
- Updated dependencies to the latest versions
## v1.0.0 (2019-07-15)

@@ -4,0 +9,0 @@

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

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("PropTypes"),require("React"),require("hoistNonReactStatic")):"function"==typeof define&&define.amd?define(["PropTypes","React","hoistNonReactStatic"],e):"object"==typeof exports?exports.ReactGettext=e(require("PropTypes"),require("React"),require("hoistNonReactStatic")):t.ReactGettext=e(t.PropTypes,t.React,t.hoistNonReactStatic)}(window,function(t,e,n){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(e,n){e.exports=t},function(t,n){t.exports=e},function(t,e){t.exports=n},function(t,e,n){"use strict";n.r(e);var r=n(1),o=n.n(r),i=n(2),u=n.n(i),a=n(0),c=n.n(a),f="";function p(t){return"function"==typeof t?t():t}function l(t,e){return Number.isNaN(parseInt(e,10))?0:"function"==typeof t?t(e):"string"!=typeof t||t.match(/[^n0-9 !=?:%+-\/*><&|()]/i)?0:+Function("n","return ".concat(t))(e)}function s(t,e){var n=p(t);return Object.prototype.hasOwnProperty.call(n,e)?n[e]:e}function y(t,e,n,r,o){var i=p(t),u=l(e,o),a=o>1?r:n;return Object.prototype.hasOwnProperty.call(i,n)&&Array.isArray(i[n])&&i[n].length>u&&u>=0?i[n][u]:a}function b(t,e,n){var r=p(t),o=n+f+e;return Object.prototype.hasOwnProperty.call(r,o)?r[o]:e}function d(t,e,n,r,o,i){var u=p(t),a=l(e,o),c=o>1?r:n,s=i+f+n;return Object.prototype.hasOwnProperty.call(u,s)&&Array.isArray(u[s])&&u[s].length>a&&a>=0?u[s][a]:c}function h(t){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function x(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function g(t,e){return!e||"object"!==h(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function v(t){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function O(t,e){return(O=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var m=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),g(this,v(e).apply(this,arguments))}var n,o,i;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&O(t,e)}(e,r["Component"]),n=e,(o=[{key:"getChildContext",value:function(){return{gettext:this.gettext.bind(this),xgettext:this.xgettext.bind(this),ngettext:this.ngettext.bind(this),nxgettext:this.nxgettext.bind(this)}}},{key:"gettext",value:function(t){return s(this.props.translations,t)}},{key:"ngettext",value:function(t,e,n){var r=this.props;return y(r.translations,r.plural,t,e,n)}},{key:"xgettext",value:function(t,e){return b(this.props.translations,t,e)}},{key:"nxgettext",value:function(t,e,n,r){var o=this.props;return d(o.translations,o.plural,t,e,n,r)}},{key:"render",value:function(){return this.props.children}}])&&x(n.prototype,o),i&&x(n,i),e}();m.propTypes={translations:c.a.oneOfType([c.a.func,c.a.objectOf(c.a.oneOfType([c.a.string,c.a.arrayOf(c.a.string)]))]),plural:c.a.oneOfType([c.a.func,c.a.string]),children:c.a.oneOfType([c.a.node,c.a.arrayOf(c.a.node)])},m.defaultProps={translations:{},plural:"n != 1",children:[]},m.childContextTypes={gettext:c.a.func,ngettext:c.a.func,xgettext:c.a.func,nxgettext:c.a.func};var j=m;function w(t){return(w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function P(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function S(t,e,n){return e&&_(t.prototype,e),n&&_(t,n),t}function T(t,e){return!e||"object"!==w(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function R(t){return(R=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function C(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&k(t,e)}function k(t,e){return(k=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var N=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=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 i=Object.assign({withRef:!1},n),a=function(t){function e(){return P(this,e),T(this,R(e).apply(this,arguments))}return C(e,j),S(e,[{key:"getWrappedComponent",value:function(){return this.refs.wrappedComponent}},{key:"render",value:function(){var t=Object.assign({},this.props);return i.withRef&&(t.ref="wrappedComponent"),o.a.createElement(r,t)}}]),e}();return a.defaultProps={translations:t,plural:e},a.displayName="withGettext(".concat(r.displayName||r.name||"Component",")"),u()(a,r)}};var E=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"n != 1";return{gettext:s.bind(null,t),ngettext:y.bind(null,t,e),xgettext:b.bind(null,t),nxgettext:d.bind(null,t,e)}},q=o.a.createContext(E({},"n != 1"));n.d(e,"Textdomain",function(){return j}),n.d(e,"TextdomainContext",function(){return q}),n.d(e,"buildTextdomain",function(){return E});e.default=N}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("PropTypes"),require("React"),require("hoistNonReactStatic")):"function"==typeof define&&define.amd?define(["PropTypes","React","hoistNonReactStatic"],e):"object"==typeof exports?exports.ReactGettext=e(require("PropTypes"),require("React"),require("hoistNonReactStatic")):t.ReactGettext=e(t.PropTypes,t.React,t.hoistNonReactStatic)}(window,(function(t,e,n){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(e,n){e.exports=t},function(t,n){t.exports=e},function(t,e){t.exports=n},function(t,e,n){"use strict";n.r(e);var r=n(1),o=n.n(r),i=n(2),u=n.n(i),a=n(0),c=n.n(a),f="";function p(t){return"function"==typeof t?t():t}function l(t,e){return Number.isNaN(parseInt(e,10))?0:"function"==typeof t?t(e):"string"!=typeof t||t.match(/[^n0-9 !=?:%+-/*><&|()]/i)?0:+Function("n","return ".concat(t))(e)}function s(t,e){var n=p(t);return Object.prototype.hasOwnProperty.call(n,e)?n[e]:e}function y(t,e,n,r,o){var i=p(t),u=l(e,o),a=o>1?r:n;return Object.prototype.hasOwnProperty.call(i,n)&&Array.isArray(i[n])&&i[n].length>u&&u>=0?i[n][u]:a}function b(t,e,n){var r=p(t),o=n+f+e;return Object.prototype.hasOwnProperty.call(r,o)?r[o]:e}function d(t,e,n,r,o,i){var u=p(t),a=l(e,o),c=o>1?r:n,s=i+f+n;return Object.prototype.hasOwnProperty.call(u,s)&&Array.isArray(u[s])&&u[s].length>a&&a>=0?u[s][a]:c}function h(t){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function x(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function g(t,e){return!e||"object"!==h(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function v(t){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function O(t,e){return(O=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var m=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),g(this,v(e).apply(this,arguments))}var n,r,o;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&O(t,e)}(e,t),n=e,(r=[{key:"getChildContext",value:function(){return{gettext:this.gettext.bind(this),xgettext:this.xgettext.bind(this),ngettext:this.ngettext.bind(this),nxgettext:this.nxgettext.bind(this)}}},{key:"gettext",value:function(t){return s(this.props.translations,t)}},{key:"ngettext",value:function(t,e,n){var r=this.props;return y(r.translations,r.plural,t,e,n)}},{key:"xgettext",value:function(t,e){return b(this.props.translations,t,e)}},{key:"nxgettext",value:function(t,e,n,r){var o=this.props;return d(o.translations,o.plural,t,e,n,r)}},{key:"render",value:function(){return this.props.children}}])&&x(n.prototype,r),o&&x(n,o),e}(r.Component);m.propTypes={translations:c.a.oneOfType([c.a.func,c.a.objectOf(c.a.oneOfType([c.a.string,c.a.arrayOf(c.a.string)]))]),plural:c.a.oneOfType([c.a.func,c.a.string]),children:c.a.oneOfType([c.a.node,c.a.arrayOf(c.a.node)])},m.defaultProps={translations:{},plural:"n != 1",children:[]},m.childContextTypes={gettext:c.a.func,ngettext:c.a.func,xgettext:c.a.func,nxgettext:c.a.func};var j=m;function w(t){return(w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function P(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function S(t,e,n){return e&&_(t.prototype,e),n&&_(t,n),t}function T(t,e){return!e||"object"!==w(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function R(t){return(R=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function C(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&k(t,e)}function k(t,e){return(k=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var N=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=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 i=Object.assign({withRef:!1},n),a=function(t){function e(){return P(this,e),T(this,R(e).apply(this,arguments))}return C(e,t),S(e,[{key:"getWrappedComponent",value:function(){return this.refs.wrappedComponent}},{key:"render",value:function(){var t=Object.assign({},this.props);return i.withRef&&(t.ref="wrappedComponent"),o.a.createElement(r,t)}}]),e}(j);return a.defaultProps={translations:t,plural:e},a.displayName="withGettext(".concat(r.displayName||r.name||"Component",")"),u()(a,r)}};var E=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"n != 1";return{gettext:s.bind(null,t),ngettext:y.bind(null,t,e),xgettext:b.bind(null,t),nxgettext:d.bind(null,t,e)}},q=o.a.createContext(E({},"n != 1"));n.d(e,"Textdomain",(function(){return j})),n.d(e,"TextdomainContext",(function(){return q})),n.d(e,"buildTextdomain",(function(){return E}));e.default=N}])}));

@@ -10,3 +10,5 @@ "use strict";

function buildTextdomain(translations = {}, plural = 'n != 1') {
function buildTextdomain() {
var translations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var plural = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'n != 1';
return {

@@ -13,0 +15,0 @@ gettext: _gettext.gettext.bind(null, translations),

@@ -11,3 +11,3 @@ "use strict";

exports.default = void 0;
const DELIMITER = '\u0004'; // End of Transmission (EOT)
var DELIMITER = "\x04"; // End of Transmission (EOT)

@@ -33,3 +33,3 @@ function getTranslations(catalog) {

/* eslint-disable no-new-func */
const calcPlural = Function('n', `return ${plural}`);
var calcPlural = Function('n', "return ".concat(plural));
/* eslint-enable no-new-func */

@@ -44,3 +44,3 @@

function gettext(catalog, message) {
const messages = getTranslations(catalog);
var messages = getTranslations(catalog);
return Object.prototype.hasOwnProperty.call(messages, message) ? messages[message] : message;

@@ -50,5 +50,5 @@ }

function ngettext(catalog, plurality, singular, plural, n) {
const messages = getTranslations(catalog);
const pluralIndex = getPluralForm(plurality, n);
const defaultValue = n > 1 ? plural : singular;
var messages = getTranslations(catalog);
var pluralIndex = getPluralForm(plurality, n);
var defaultValue = n > 1 ? plural : singular;
return Object.prototype.hasOwnProperty.call(messages, singular) && Array.isArray(messages[singular]) && messages[singular].length > pluralIndex && pluralIndex >= 0 ? messages[singular][pluralIndex] : defaultValue;

@@ -58,4 +58,4 @@ }

function xgettext(catalog, message, context) {
const messages = getTranslations(catalog);
const key = context + DELIMITER + message;
var messages = getTranslations(catalog);
var key = context + DELIMITER + message;
return Object.prototype.hasOwnProperty.call(messages, key) ? messages[key] : message;

@@ -65,6 +65,6 @@ }

function nxgettext(catalog, plurality, singular, plural, n, context) {
const messages = getTranslations(catalog);
const pluralIndex = getPluralForm(plurality, n);
const defaultValue = n > 1 ? plural : singular;
const key = context + DELIMITER + singular;
var messages = getTranslations(catalog);
var pluralIndex = getPluralForm(plurality, n);
var defaultValue = n > 1 ? plural : singular;
var key = context + DELIMITER + singular;
return Object.prototype.hasOwnProperty.call(messages, key) && Array.isArray(messages[key]) && messages[key].length > pluralIndex && pluralIndex >= 0 ? messages[key][pluralIndex] : defaultValue;

@@ -74,7 +74,7 @@ }

var _default = {
gettext,
ngettext,
xgettext,
nxgettext
gettext: gettext,
ngettext: ngettext,
xgettext: xgettext,
nxgettext: nxgettext
};
exports.default = _default;

@@ -12,48 +12,85 @@ "use strict";

var _gettext = require("./gettext");
var _gettext2 = require("./gettext");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class Textdomain extends _react.Component {
getChildContext() {
const self = this;
return {
gettext: self.gettext.bind(self),
xgettext: self.xgettext.bind(self),
ngettext: self.ngettext.bind(self),
nxgettext: self.nxgettext.bind(self)
};
}
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
gettext(message) {
const translations = this.props.translations;
return (0, _gettext.gettext)(translations, message);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
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 _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
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); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var Textdomain =
/*#__PURE__*/
function (_Component) {
_inherits(Textdomain, _Component);
function Textdomain() {
_classCallCheck(this, Textdomain);
return _possibleConstructorReturn(this, _getPrototypeOf(Textdomain).apply(this, arguments));
}
ngettext(singular, plural, n) {
const _this$props = this.props,
_createClass(Textdomain, [{
key: "getChildContext",
value: function getChildContext() {
var self = this;
return {
gettext: self.gettext.bind(self),
xgettext: self.xgettext.bind(self),
ngettext: self.ngettext.bind(self),
nxgettext: self.nxgettext.bind(self)
};
}
}, {
key: "gettext",
value: function gettext(message) {
var translations = this.props.translations;
return (0, _gettext2.gettext)(translations, message);
}
}, {
key: "ngettext",
value: function ngettext(singular, plural, n) {
var _this$props = this.props,
translations = _this$props.translations,
plurality = _this$props.plural;
return (0, _gettext.ngettext)(translations, plurality, singular, plural, n);
}
xgettext(message, context) {
const translations = this.props.translations;
return (0, _gettext.xgettext)(translations, message, context);
}
nxgettext(singular, plural, n, context) {
const _this$props2 = this.props,
return (0, _gettext2.ngettext)(translations, plurality, singular, plural, n);
}
}, {
key: "xgettext",
value: function xgettext(message, context) {
var translations = this.props.translations;
return (0, _gettext2.xgettext)(translations, message, context);
}
}, {
key: "nxgettext",
value: function nxgettext(singular, plural, n, context) {
var _this$props2 = this.props,
translations = _this$props2.translations,
plurality = _this$props2.plural;
return (0, _gettext.nxgettext)(translations, plurality, singular, plural, n, context);
}
return (0, _gettext2.nxgettext)(translations, plurality, singular, plural, n, context);
}
}, {
key: "render",
value: function render() {
var children = this.props.children;
return children;
}
}]);
render() {
const children = this.props.children;
return children;
}
return Textdomain;
}(_react.Component);
}
Textdomain.propTypes = {

@@ -60,0 +97,0 @@ translations: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.objectOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]))]),

@@ -14,5 +14,5 @@ "use strict";

const TextdomainContext = _react.default.createContext((0, _buildTextdomain.default)({}, 'n != 1'));
var TextdomainContext = _react.default.createContext((0, _buildTextdomain.default)({}, 'n != 1'));
var _default = TextdomainContext;
exports.default = _default;

@@ -12,34 +12,72 @@ "use strict";

var _Textdomain = _interopRequireDefault(require("./Textdomain"));
var _Textdomain2 = _interopRequireDefault(require("./Textdomain"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const withGettext = (translations = {}, pluralForm = 'n != 1', options = {}) => WrappedComponent => {
const args = Object.assign({
withRef: false
}, options);
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
class WithGettext extends _Textdomain.default {
getWrappedComponent() {
return this.refs.wrappedComponent;
}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
render() {
const newprops = Object.assign({}, this.props);
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); } }
if (args.withRef) {
newprops.ref = 'wrappedComponent';
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
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 _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
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); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
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);
var WithGettext =
/*#__PURE__*/
function (_Textdomain) {
_inherits(WithGettext, _Textdomain);
function WithGettext() {
_classCallCheck(this, WithGettext);
return _possibleConstructorReturn(this, _getPrototypeOf(WithGettext).apply(this, arguments));
}
return _react.default.createElement(WrappedComponent, newprops);
}
_createClass(WithGettext, [{
key: "getWrappedComponent",
value: function getWrappedComponent() {
return this.refs.wrappedComponent;
}
}, {
key: "render",
value: function render() {
var newprops = Object.assign({}, this.props);
}
if (args.withRef) {
newprops.ref = 'wrappedComponent';
}
WithGettext.defaultProps = {
translations,
plural: pluralForm
return _react.default.createElement(WrappedComponent, newprops);
}
}]);
return WithGettext;
}(_Textdomain2.default);
WithGettext.defaultProps = {
translations: translations,
plural: pluralForm
};
WithGettext.displayName = "withGettext(".concat(WrappedComponent.displayName || WrappedComponent.name || 'Component', ")");
return (0, _hoistNonReactStatics.default)(WithGettext, WrappedComponent);
};
WithGettext.displayName = `withGettext(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;
return (0, _hoistNonReactStatics.default)(WithGettext, WrappedComponent);
};

@@ -46,0 +84,0 @@

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

},
"version": "1.0.0",
"version": "1.0.1",
"main": "lib/index.js",

@@ -34,29 +34,29 @@ "files": [

"build:umd:min": "NODE_ENV=production webpack --output-filename=react-gettext.min.js",
"test": "jest",
"test": "BABEL_ENV=test jest",
"prepublish": "npm run build"
},
"devDependencies": {
"@babel/cli": "^7.5.0",
"@babel/core": "^7.5.4",
"@babel/preset-env": "^7.5.4",
"@babel/preset-react": "^7.0.0",
"babel-jest": "^24.8.0",
"@babel/cli": "^7.7.0",
"@babel/core": "^7.7.2",
"@babel/preset-env": "^7.7.1",
"@babel/preset-react": "^7.7.0",
"babel-jest": "^24.9.0",
"babel-loader": "^8.0.6",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"eslint": "^6.0.1",
"eslint-config-airbnb": "^17.1.1",
"eslint-loader": "^2.2.1",
"eslint-plugin-import": "^2.7.0",
"enzyme-adapter-react-16": "^1.15.1",
"eslint": "^6.6.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-loader": "^3.0.2",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.14.2",
"eslint-plugin-react": "^7.16.0",
"faker": "^4.1.0",
"jest": "^24.8.0",
"jest-enzyme": "^7.0.2",
"jest": "^24.9.0",
"jest-enzyme": "^7.1.2",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-test-renderer": "^16.8.6",
"webpack": "^4.35.3",
"webpack-cli": "^3.3.6"
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-test-renderer": "^16.12.0",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10"
},

@@ -75,2 +75,3 @@ "peerDependencies": {

"class-methods-use-this": 0,
"prefer-object-spread": 0,
"indent": [

@@ -99,4 +100,4 @@ 2,

"dependencies": {
"hoist-non-react-statics": "^3.3.0"
"hoist-non-react-statics": "^3.3.1"
}
}

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

# react-gettext 1.0.0
# react-gettext 1.0.1

@@ -371,3 +371,3 @@ [![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)

What to help or have a suggestion? Open a [new ticket](https://github.com/eugene-manuilov/react-gettext/issues/new) and we can discuss it or submit pull request. Please, make sure you run `npm test` before submitting a pull request.
Want to help or have a suggestion? Open a [new ticket](https://github.com/eugene-manuilov/react-gettext/issues/new) and we can discuss it or submit pull request. Please, make sure you run `npm test` before submitting a pull request.

@@ -374,0 +374,0 @@ ## License