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.3.0

CHANGELOG.md

352

dist/react-gettext.js

@@ -10,3 +10,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

root["ReactGettext"] = factory(root["React"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_7__) {
})(this, function(__WEBPACK_EXTERNAL_MODULE_3__) {
return /******/ (function(modules) { // webpackBootstrap

@@ -374,2 +374,8 @@ /******/ // The module cache

/* 3 */
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_3__;
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {

@@ -447,3 +453,3 @@

/***/ }),
/* 4 */
/* 5 */
/***/ (function(module, exports, __webpack_require__) {

@@ -469,6 +475,162 @@

/***/ }),
/* 5 */
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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 _react = __webpack_require__(3);
var _propTypes = __webpack_require__(12);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Textdomain = function (_Component) {
_inherits(Textdomain, _Component);
function Textdomain() {
_classCallCheck(this, Textdomain);
return _possibleConstructorReturn(this, (Textdomain.__proto__ || Object.getPrototypeOf(Textdomain)).apply(this, arguments));
}
_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: 'getTranslations',
value: function getTranslations() {
var translations = this.props.translations;
return typeof translations === 'function' ? translations() : translations;
}
}, {
key: 'getPluralForm',
value: function getPluralForm(n) {
var plural = this.props.plural;
// return 0 if n is not integer
if (isNaN(parseInt(n, 10))) {
return 0;
}
// if pluralForm is function, use it to get plural form index
if (typeof plural === 'function') {
return plural(n);
}
// if pluralForm is string and contains only "n", "0-9", " ", "!=?:%+-/*><&|()"
// characters, then we can "eval" it to calculate plural form
if (typeof plural === 'string' && !plural.match(/[^n0-9 !=?:%+-/*><&|()]/i)) {
/* eslint-disable no-new-func */
var calcPlural = Function('n', 'return ' + plural);
/* eslint-enable no-new-func */
return +calcPlural(n);
}
return 0;
}
}, {
key: 'getDelimiter',
value: function getDelimiter() {
return '\x04'; // End of Transmission (EOT)
}
}, {
key: 'gettext',
value: function gettext(message) {
var messages = this.getTranslations();
return Object.prototype.hasOwnProperty.call(messages, message) ? messages[message] : message;
}
}, {
key: 'ngettext',
value: function ngettext(singular, plural, n) {
var self = this;
var messages = self.getTranslations();
var pluralIndex = self.getPluralForm(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;
}
}, {
key: 'xgettext',
value: function xgettext(message, context) {
var self = this;
var EOT = self.getDelimiter();
var messages = self.getTranslations();
var key = context + EOT + message;
return Object.prototype.hasOwnProperty.call(messages, key) ? messages[key] : message;
}
}, {
key: 'nxgettext',
value: function nxgettext(singular, plural, n, context) {
var self = this;
var messages = self.getTranslations();
var pluralIndex = self.getPluralForm(n);
var defaultValue = n > 1 ? plural : singular;
var EOT = self.getDelimiter();
var key = context + EOT + singular;
return Object.prototype.hasOwnProperty.call(messages, key) && Array.isArray(messages[key]) && messages[key].length > pluralIndex && pluralIndex >= 0 ? messages[key][pluralIndex] : defaultValue;
}
}, {
key: 'render',
value: function render() {
return this.props.children;
}
}]);
return Textdomain;
}(_react.Component);
Textdomain.propTypes = {
translations: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.objectOf(_propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.arrayOf(_propTypes2.default.string)]))]),
plural: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.string]),
children: _propTypes2.default.arrayOf(_propTypes2.default.node)
};
Textdomain.defaultProps = {
translations: {},
plural: 'n != 1',
children: []
};
Textdomain.childContextTypes = {
gettext: _propTypes2.default.func,
ngettext: _propTypes2.default.func,
xgettext: _propTypes2.default.func,
nxgettext: _propTypes2.default.func
};
exports.default = Textdomain;
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**

@@ -527,45 +689,2 @@ * Copyright 2015, Yahoo! Inc.

/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(process) {/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
if (process.env.NODE_ENV !== 'production') {
var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
Symbol.for &&
Symbol.for('react.element')) ||
0xeac7;
var isValidElement = function(object) {
return typeof object === 'object' &&
object !== null &&
object.$$typeof === REACT_ELEMENT_TYPE;
};
// By explicitly using `prop-types` you are opting into new development behavior.
// http://fb.me/prop-types-in-prod
var throwOnDirectAccess = true;
module.exports = __webpack_require__(11)(isValidElement, throwOnDirectAccess);
} else {
// By explicitly using `prop-types` you are opting into new production behavior.
// http://fb.me/prop-types-in-prod
module.exports = __webpack_require__(10)();
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
/***/ }),
/* 7 */
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_7__;
/***/ }),
/* 8 */

@@ -583,15 +702,15 @@ /***/ (function(module, exports, __webpack_require__) {

exports.default = textdomain;
exports.default = withGettext;
var _react = __webpack_require__(7);
var _react = __webpack_require__(3);
var _react2 = _interopRequireDefault(_react);
var _propTypes = __webpack_require__(6);
var _hoistNonReactStatics = __webpack_require__(7);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _hoistNonReactStatics2 = _interopRequireDefault(_hoistNonReactStatics);
var _hoistNonReactStatics = __webpack_require__(5);
var _Textdomain2 = __webpack_require__(6);
var _hoistNonReactStatics2 = _interopRequireDefault(_hoistNonReactStatics);
var _Textdomain3 = _interopRequireDefault(_Textdomain2);

@@ -606,37 +725,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function textdomain(translations, pluralForm) {
var EOT = '\x04'; // End of Transmission
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 getTranslations = function getTranslations() {
// if translations is function, call it to get translations object,
// otherwise just use incoming translations object
return typeof translations === 'function' ? translations() : translations;
};
var getPluralForm = function getPluralForm(n) {
// return 0 if n is not integer
if (isNaN(parseInt(n, 10))) {
return 0;
}
// if pluralForm is function, use it to get plural form index
if (typeof pluralForm === 'function') {
return pluralForm(n);
}
// if pluralForm is string and contains only "n", "0-9", " ", "=?:%+-/*><&|"
// characters, then we can eval it to calculate plural form
if (typeof pluralForm === 'string' && !pluralForm.match(/[^n0-9 =?:%+-/*><&|]/i)) {
/* eslint-disable no-eval */
return +eval(pluralForm.toLowerCase().split('n').join(n));
/* eslint-enable no-eval */
}
return 0;
};
// return HOC function
return function (WrappedComponent) {
var WithGettext = function (_Component) {
_inherits(WithGettext, _Component);
var WithGettext = function (_Textdomain) {
_inherits(WithGettext, _Textdomain);

@@ -650,11 +741,2 @@ function WithGettext() {

_createClass(WithGettext, [{
key: 'getChildContext',
value: function getChildContext() {
return {
gettext: WithGettext.gettext,
ngettext: WithGettext.ngettext,
xgettext: WithGettext.xgettext
};
}
}, {
key: 'render',

@@ -664,39 +746,14 @@ value: function render() {

}
}], [{
key: 'gettext',
value: function gettext(message) {
var messages = getTranslations();
return messages[message] ? messages[message] : message;
}
}, {
key: 'ngettext',
value: function ngettext(singular, plural, n) {
var messages = getTranslations();
var pluralIndex = getPluralForm(n);
var defaultValue = n > 1 ? plural : singular;
return Array.isArray(messages[singular]) && messages[singular][pluralIndex] ? messages[singular][pluralIndex] : defaultValue;
}
}, {
key: 'xgettext',
value: function xgettext(message, context) {
var messages = getTranslations();
var key = context + EOT + message;
return messages[key] ? messages[key] : message;
}
}]);
return WithGettext;
}(_react.Component);
}(_Textdomain3.default);
WithGettext.displayName = 'WithGettext(' + (WrappedComponent.displayName || WrappedComponent.name || 'Component') + ')';
WithGettext.childContextTypes = {
gettext: _propTypes2.default.func,
ngettext: _propTypes2.default.func,
xgettext: _propTypes2.default.func
WithGettext.defaultProps = {
translations: translations,
plural: pluralForm
};
WithGettext.displayName = 'withGettext(' + (WrappedComponent.displayName || WrappedComponent.name || 'Component') + ')';
return (0, _hoistNonReactStatics2.default)(WithGettext, WrappedComponent);

@@ -724,4 +781,4 @@ };

var invariant = __webpack_require__(2);
var warning = __webpack_require__(3);
var ReactPropTypesSecret = __webpack_require__(4);
var warning = __webpack_require__(4);
var ReactPropTypesSecret = __webpack_require__(5);
var loggedTypeFailures = {};

@@ -855,5 +912,5 @@ }

var invariant = __webpack_require__(2);
var warning = __webpack_require__(3);
var warning = __webpack_require__(4);
var ReactPropTypesSecret = __webpack_require__(4);
var ReactPropTypesSecret = __webpack_require__(5);
var checkPropTypes = __webpack_require__(9);

@@ -1324,4 +1381,41 @@

/***/ }),
/* 12 */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(process) {/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
if (process.env.NODE_ENV !== 'production') {
var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
Symbol.for &&
Symbol.for('react.element')) ||
0xeac7;
var isValidElement = function(object) {
return typeof object === 'object' &&
object !== null &&
object.$$typeof === REACT_ELEMENT_TYPE;
};
// By explicitly using `prop-types` you are opting into new development behavior.
// http://fb.me/prop-types-in-prod
var throwOnDirectAccess = true;
module.exports = __webpack_require__(11)(isValidElement, throwOnDirectAccess);
} else {
// By explicitly using `prop-types` you are opting into new production behavior.
// http://fb.me/prop-types-in-prod
module.exports = __webpack_require__(10)();
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
/***/ })
/******/ ]);
});

@@ -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(__WEBPACK_EXTERNAL_MODULE_7__){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(f===setTimeout)return setTimeout(e,0);if((f===n||!f)&&setTimeout)return f=setTimeout,setTimeout(e,0);try{return f(e,0)}catch(t){try{return f.call(null,e,0)}catch(t){return f.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 a(){h&&y&&(h=!1,y.length?d=y.concat(d):v=-1,d.length&&u())}function u(){if(!h){var e=o(a);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 s(){}var f,l,p=e.exports={};!function(){try{f="function"==typeof setTimeout?setTimeout:n}catch(e){f=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(u)},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=s,p.addListener=s,p.once=s,p.off=s,p.removeListener=s,p.removeAllListeners=s,p.emit=s,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,a,u,c){if(r(t),!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var f=[n,o,i,a,u,c],l=0;s=new Error(t.replace(/%s/g,function(){return f[l++]})),s.name="Invariant Violation"}throw s.framesToPop=1,s}}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";(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";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},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 a=Object.getOwnPropertyNames(t);i&&(a=a.concat(Object.getOwnPropertySymbols(t)));for(var u=0;u<a.length;++u)if(!(r[a[u]]||o[a[u]]||n&&n[a[u]]))try{e[a[u]]=t[a[u]]}catch(e){}}return e}},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){e.exports=__WEBPACK_EXTERNAL_MODULE_7__},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(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 _inherits(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 textdomain(translations,pluralForm){var EOT="",getTranslations=function(){return"function"==typeof translations?translations():translations},getPluralForm=function getPluralForm(n){return isNaN(parseInt(n,10))?0:"function"==typeof pluralForm?pluralForm(n):"string"!=typeof pluralForm||pluralForm.match(/[^n0-9 =?:%+-\/*><&|]/i)?0:+eval(pluralForm.toLowerCase().split("n").join(n))};return function(e){var t=function(t){function n(){return _classCallCheck(this,n),_possibleConstructorReturn(this,(n.__proto__||Object.getPrototypeOf(n)).apply(this,arguments))}return _inherits(n,t),_createClass(n,[{key:"getChildContext",value:function(){return{gettext:n.gettext,ngettext:n.ngettext,xgettext:n.xgettext}}},{key:"render",value:function(){return _react2.default.createElement(e,this.props)}}],[{key:"gettext",value:function(e){var t=getTranslations();return t[e]?t[e]:e}},{key:"ngettext",value:function(e,t,n){var r=getTranslations(),o=getPluralForm(n),i=n>1?t:e;return Array.isArray(r[e])&&r[e][o]?r[e][o]:i}},{key:"xgettext",value:function(e,t){var n=getTranslations(),r=t+""+e;return n[r]?n[r]:e}}]),n}(_react.Component);return t.displayName="WithGettext("+(e.displayName||e.name||"Component")+")",t.childContextTypes={gettext:_propTypes2.default.func,ngettext:_propTypes2.default.func,xgettext:_propTypes2.default.func},(0,_hoistNonReactStatics2.default)(t,e)}}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=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}}();exports.default=textdomain;var _react=__webpack_require__(7),_react2=_interopRequireDefault(_react),_propTypes=__webpack_require__(6),_propTypes2=_interopRequireDefault(_propTypes),_hoistNonReactStatics=__webpack_require__(5),_hoistNonReactStatics2=_interopRequireDefault(_hoistNonReactStatics)},function(e,t,n){"use strict";(function(t){function r(e,n,r,c,s){if("production"!==t.env.NODE_ENV)for(var f in e)if(e.hasOwnProperty(f)){var l;try{o("function"==typeof e[f],"%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",c||"React class",r,f),l=e[f](n,f,c,r,null,a)}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,f,typeof l),l instanceof Error&&!(l.message in u)){u[l.message]=!0;var p=s?s():"";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(3),a=n(4),u={};e.exports=r}).call(t,n(0))},function(e,t,n){"use strict";var r=n(1),o=n(2);e.exports=function(){function e(){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(3),a=n(4),u=n(9);e.exports=function(e,n){function c(e){var t=e&&(O&&e[O]||e[E]);if("function"==typeof t)return t}function s(e,t){return e===t?0!==e||1/e==1/t:e!==e&&t!==t}function f(e){this.message=e,this.stack=""}function l(e){function r(r,s,l,p,y,d,h){if(p=p||R,d=d||l,h!==a)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;!u[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),u[v]=!0,c++)}return null==s[l]?r?new f(null===s[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(s,l,p,y,d)}if("production"!==t.env.NODE_ENV)var u={},c=0;var s=r.bind(null,!1);return s.isRequired=r.bind(null,!0),s}function p(e){function t(t,n,r,o,i,a){var u=t[n];if(x(u)!==e)return new f("Invalid "+o+" `"+i+"` of type `"+T(u)+"` 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 f("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var u=t[n];if(!Array.isArray(u)){return new f("Invalid "+o+" `"+i+"` of type `"+x(u)+"` supplied to `"+r+"`, expected an array.")}for(var c=0;c<u.length;c++){var s=e(u,c,r,o,i+"["+c+"]",a);if(s instanceof Error)return s}return null}return l(t)}function d(e){function t(t,n,r,o,i){if(!(t[n]instanceof e)){var a=e.name||R;return new f("Invalid "+o+" `"+i+"` of type `"+w(t[n])+"` supplied to `"+r+"`, expected instance of `"+a+"`.")}return null}return l(t)}function h(e){function n(t,n,r,o,i){for(var a=t[n],u=0;u<e.length;u++)if(s(a,e[u]))return null;return new f("Invalid "+o+" `"+i+"` of value `"+a+"` 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 f("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var u=t[n],c=x(u);if("object"!==c)return new f("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+r+"`, expected an object.");for(var s in u)if(u.hasOwnProperty(s)){var l=e(u,s,r,o,i+"."+s,a);if(l instanceof Error)return l}return null}return l(t)}function m(e){function n(t,n,r,o,i){for(var u=0;u<e.length;u++){if(null==(0,e[u])(t,n,r,o,i,a))return null}return new f("Invalid "+o+" `"+i+"` supplied to `"+r+"`.")}return Array.isArray(e)?l(n):("production"!==t.env.NODE_ENV&&i(!1,"Invalid argument supplied to oneOfType, expected an instance of array."),r.thatReturnsNull)}function g(e){function t(t,n,r,o,i){var u=t[n],c=x(u);if("object"!==c)return new f("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+r+"`, expected `object`.");for(var s in e){var l=e[s];if(l){var p=l(u,s,r,o,i+"."+s,a);if(p)return p}}return null}return l(t)}function _(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(_);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(!_(r.value))return!1}else for(;!(r=o.next()).done;){var i=r.value;if(i&&!_(i[1]))return!1}return!0;default:return!1}}function b(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":b(t,e)?"symbol":t}function T(e){var t=x(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function w(e){return e.constructor&&e.constructor.name?e.constructor.name:R}var O="function"==typeof Symbol&&Symbol.iterator,E="@@iterator",R="<<anonymous>>",P={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 a=t[n];if(!e(a)){return new f("Invalid "+o+" `"+i+"` of type `"+x(a)+"` supplied to `"+r+"`, expected a single ReactElement.")}return null}return l(t)}(),instanceOf:d,node:function(){function e(e,t,n,r,o){return _(e[t])?null:new f("Invalid "+r+" `"+o+"` supplied to `"+n+"`, expected a ReactNode.")}return l(e)}(),objectOf:v,oneOf:h,oneOfType:m,shape:g};return f.prototype=Error.prototype,P.checkPropTypes=u,P.PropTypes=P,P}}).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(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(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";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},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(3),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.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});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(3),l=r(f),s=n(7),p=r(s),y=n(6),d=r(y)},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(4),u=n(5),a={};e.exports=r}).call(t,n(0))},function(e,t,n){"use strict";var r=n(1),o=n(2);e.exports=function(){function e(){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(4),u=n(5),a=n(9);e.exports=function(e,n){function c(e){var t=e&&(E&&e[E]||e[P]);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||_,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||_;return new l("Invalid "+o+" `"+i+"` of type `"+T(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+"`.")}return Array.isArray(e)?s(n):("production"!==t.env.NODE_ENV&&i(!1,"Invalid argument supplied to oneOfType, expected an instance of array."),r.thatReturnsNull)}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){var t=x(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function T(e){return e.constructor&&e.constructor.name?e.constructor.name:_}var E="function"==typeof Symbol&&Symbol.iterator,P="@@iterator",_="<<anonymous>>",j={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,j.checkPropTypes=a,j.PropTypes=j,j}}).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))}])});

@@ -9,3 +9,3 @@ 'use strict';

exports.default = textdomain;
exports.default = withGettext;

@@ -16,6 +16,2 @@ var _react = require('react');

var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _hoistNonReactStatics = require('hoist-non-react-statics');

@@ -25,2 +21,6 @@

var _Textdomain2 = require('./Textdomain');
var _Textdomain3 = _interopRequireDefault(_Textdomain2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -34,37 +34,9 @@

function textdomain(translations, pluralForm) {
var EOT = '\x04'; // End of Transmission
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 getTranslations = function getTranslations() {
// if translations is function, call it to get translations object,
// otherwise just use incoming translations object
return typeof translations === 'function' ? translations() : translations;
};
var getPluralForm = function getPluralForm(n) {
// return 0 if n is not integer
if (isNaN(parseInt(n, 10))) {
return 0;
}
// if pluralForm is function, use it to get plural form index
if (typeof pluralForm === 'function') {
return pluralForm(n);
}
// if pluralForm is string and contains only "n", "0-9", " ", "=?:%+-/*><&|"
// characters, then we can eval it to calculate plural form
if (typeof pluralForm === 'string' && !pluralForm.match(/[^n0-9 =?:%+-/*><&|]/i)) {
/* eslint-disable no-eval */
return +eval(pluralForm.toLowerCase().split('n').join(n));
/* eslint-enable no-eval */
}
return 0;
};
// return HOC function
return function (WrappedComponent) {
var WithGettext = function (_Component) {
_inherits(WithGettext, _Component);
var WithGettext = function (_Textdomain) {
_inherits(WithGettext, _Textdomain);

@@ -78,11 +50,2 @@ function WithGettext() {

_createClass(WithGettext, [{
key: 'getChildContext',
value: function getChildContext() {
return {
gettext: WithGettext.gettext,
ngettext: WithGettext.ngettext,
xgettext: WithGettext.xgettext
};
}
}, {
key: 'render',

@@ -92,41 +55,16 @@ value: function render() {

}
}], [{
key: 'gettext',
value: function gettext(message) {
var messages = getTranslations();
return messages[message] ? messages[message] : message;
}
}, {
key: 'ngettext',
value: function ngettext(singular, plural, n) {
var messages = getTranslations();
var pluralIndex = getPluralForm(n);
var defaultValue = n > 1 ? plural : singular;
return Array.isArray(messages[singular]) && messages[singular][pluralIndex] ? messages[singular][pluralIndex] : defaultValue;
}
}, {
key: 'xgettext',
value: function xgettext(message, context) {
var messages = getTranslations();
var key = context + EOT + message;
return messages[key] ? messages[key] : message;
}
}]);
return WithGettext;
}(_react.Component);
}(_Textdomain3.default);
WithGettext.displayName = 'WithGettext(' + (WrappedComponent.displayName || WrappedComponent.name || 'Component') + ')';
WithGettext.childContextTypes = {
gettext: _propTypes2.default.func,
ngettext: _propTypes2.default.func,
xgettext: _propTypes2.default.func
WithGettext.defaultProps = {
translations: translations,
plural: pluralForm
};
WithGettext.displayName = 'withGettext(' + (WrappedComponent.displayName || WrappedComponent.name || 'Component') + ')';
return (0, _hoistNonReactStatics2.default)(WithGettext, WrappedComponent);
};
}

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

},
"version": "0.2.0",
"version": "0.3.0",
"main": "lib/index",

@@ -46,2 +46,3 @@ "files": [

"babel-preset-react": "^6.24.1",
"enzyme": "^2.9.1",
"eslint": "^3.19.0",

@@ -54,3 +55,5 @@ "eslint-config-airbnb": "^14.1.0",

"faker": "^4.1.0",
"hoist-non-react-statics": "^1.2.0",
"jest": "^19.0.2",
"jest-enzyme": "^3.3.0",
"prop-types": "^15.5.8",

@@ -63,8 +66,6 @@ "react": "^15.5.4",

"peerDependencies": {
"hoist-non-react-statics": "^1.2.0",
"prop-types": "^15.0.0-0 || ^16.0.0-0",
"react": "^15.0.0-0 || ^16.0.0-0"
},
"dependencies": {
"hoist-non-react-statics": "^1.2.0"
}
}

@@ -1,3 +0,5 @@

# react-gettext
# react-gettext 0.3.0
[![Build Status](https://travis-ci.org/eugene-manuilov/react-gettext.svg?branch=master)](https://travis-ci.org/eugene-manuilov/react-gettext)
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.

@@ -7,3 +9,3 @@

React Gettext requires **React 15.0 or later**.
React Gettext requires **React 15.0 or later**. You can add this package using following commands:

@@ -14,2 +16,6 @@ ```

```
yarn add react-gettext
```
## Usage

@@ -60,3 +66,3 @@

import React, { Component } from 'react';
+ import Textdomain from 'react-gettext';
+ import withGettext from 'react-gettext';
import Header from './Header';

@@ -70,6 +76,6 @@ import Footer from './Footer';

+ export default Textdomain({...}, 'n != 1')(App);
+ export default withGettext({...}, 'n != 1')(App);
```
After doing it you can start using `gettext`, `ngettext` and `xgettext` functions in your descending components:
After doing it you can start using `gettext`, `ngettext`, `xgettext` and `nxgettext` functions in your descending components:

@@ -79,3 +85,4 @@ ```diff

- import React, { Component } from 'react';
+ import React, { Component, PropTypes } from 'react';
+ import React, { Component } from 'react';
+ import PropTypes from 'prop-types';

@@ -96,3 +103,4 @@ export default class Header extends Component {

+ ngettext: PropTypes.func.isRequired,
+ xgettext: PropTypes.func.isRequired
+ xgettext: PropTypes.func.isRequired,
+ nxgettext: PropTypes.func.isRequired,
+ };

@@ -103,3 +111,3 @@ ```

### Textdomain(translations, pluralForms)
### withGettext(translations, pluralForms)

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

const HOC = Textdomain(translations, pluralForms)(App);
const HOC = withGettext(translations, pluralForms)(App);
```

@@ -137,5 +145,27 @@

const HOC = Textdomain(getTranslations, getPluralForms)(App);
const HOC = withGettext(getTranslations, getPluralForms)(App);
```
As an alternative you can pass translations and plural form as properties to higher-order-component, like this:
```javascript
function getTranslations() {
return {
'Some text': 'Some translated text',
...
};
}
function getPluralForms(n) {
return n > 1 ? 1 : 0;
}
const HOC = withGettext()(App);
...
ReactDOM.render(<HOC translations={getTranslations} plural={getPluralForms}>...</HOC>, ...);
```
### gettext(message)

@@ -183,12 +213,47 @@

### nxgettext(singular, plural, n, context)
The function to translate plural string based on a specific context. Accepts singular and plural messages along with a number to calculate plural form against and context string. Returns translated message based on plural form if it exists, otherwise original message based on **n** value.
- **singular**: a string to be translated when count is not plural
- **plural**: a string to be translated when count is plural
- **n**: a number to count plural form
- **context**: A context to search translation in.
Example:
```javascript
// somewhere in your jsx component
this.context.nxgettext('day ago', 'days ago', numberOfDays, 'Article publish date');
```
## Poedit
If you use Poedit app to translate your messages, then you can use `gettext;ngettext:1,2;xgettext:1,2c` as keywords list to properly parse and extract strings from your javascript files.
If you use Poedit app to translate your messages, then you can use `gettext;ngettext:1,2;xgettext:1,2c;nxgettext:1,2,4c` as keywords list to properly parse and extract strings from your javascript files.
Here is an example of a **POT** file which you can start with:
```
msgid ""
msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Project-Id-Version: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=iso-8859-1\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-Basepath: ./src\n"
"X-Poedit-KeywordsList: gettext;ngettext:1,2;xgettext:1,2c;nxgettext:1,2,4c\n"
"X-Poedit-SourceCharset: UTF-8\n"
```
## Contribute
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 run test` before submitting a pull request.
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.
## License
MIT
MIT

@@ -1,85 +0,24 @@

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import React from 'react';
import hoistNonReactStatic from 'hoist-non-react-statics';
import Textdomain from './Textdomain';
export default function textdomain(translations, pluralForm) {
const EOT = '\u0004'; // End of Transmission
const getTranslations = function () {
// if translations is function, call it to get translations object,
// otherwise just use incoming translations object
return typeof translations === 'function' ? translations() : translations;
};
const getPluralForm = (n) => {
// return 0 if n is not integer
if (isNaN(parseInt(n, 10))) {
return 0;
}
// if pluralForm is function, use it to get plural form index
if (typeof pluralForm === 'function') {
return pluralForm(n);
}
// if pluralForm is string and contains only "n", "0-9", " ", "=?:%+-/*><&|"
// characters, then we can eval it to calculate plural form
if (typeof pluralForm === 'string' && !pluralForm.match(/[^n0-9 =?:%+-/*><&|]/i)) {
/* eslint-disable no-eval */
return +eval(pluralForm.toLowerCase().split('n').join(n));
/* eslint-enable no-eval */
}
return 0;
};
// return HOC function
export default function withGettext(translations = {}, pluralForm = 'n != 1') {
return (WrappedComponent) => {
class WithGettext extends Component {
static gettext(message) {
const messages = getTranslations();
class WithGettext extends Textdomain {
return messages[message] ? messages[message] : message;
}
static ngettext(singular, plural, n) {
const messages = getTranslations();
const pluralIndex = getPluralForm(n);
const defaultValue = n > 1 ? plural : singular;
return Array.isArray(messages[singular]) && messages[singular][pluralIndex]
? messages[singular][pluralIndex]
: defaultValue;
}
static xgettext(message, context) {
const messages = getTranslations();
const key = context + EOT + message;
return messages[key] ? messages[key] : message;
}
getChildContext() {
return {
gettext: WithGettext.gettext,
ngettext: WithGettext.ngettext,
xgettext: WithGettext.xgettext,
};
}
render() {
return React.createElement(WrappedComponent, this.props);
}
}
WithGettext.displayName = `WithGettext(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;
WithGettext.childContextTypes = {
gettext: PropTypes.func,
ngettext: PropTypes.func,
xgettext: PropTypes.func,
WithGettext.defaultProps = {
translations,
plural: pluralForm,
};
WithGettext.displayName = `withGettext(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;
return hoistNonReactStatic(WithGettext, WrappedComponent);
};
}