@absolutesight/react-gettext 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react-gettext.js +74 -91
- package/dist/react-gettext.min.js +1 -1
- package/lib/TextDomain.js +16 -23
- package/lib/TextDomainContext.js +4 -11
- package/lib/buildTextDomain.js +7 -14
- package/lib/gettext.js +5 -15
- package/lib/index.js +6 -30
- package/lib/withGettext.js +23 -35
- package/package.json +1 -1
- package/src/TextDomain.js +1 -1
- package/src/TextDomainContext.js +1 -1
- package/src/buildTextDomain.js +1 -1
- package/src/index.js +4 -4
- package/src/withGettext.js +1 -1
package/dist/react-gettext.js
CHANGED
|
@@ -12,21 +12,49 @@ return /******/ (() => { // webpackBootstrap
|
|
|
12
12
|
/******/ "use strict";
|
|
13
13
|
/******/ var __webpack_modules__ = ({
|
|
14
14
|
|
|
15
|
+
/***/ "prop-types":
|
|
16
|
+
/*!****************************!*\
|
|
17
|
+
!*** external "PropTypes" ***!
|
|
18
|
+
\****************************/
|
|
19
|
+
/***/ ((module) => {
|
|
20
|
+
|
|
21
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_prop_types__;
|
|
22
|
+
|
|
23
|
+
/***/ }),
|
|
24
|
+
|
|
25
|
+
/***/ "react":
|
|
26
|
+
/*!************************!*\
|
|
27
|
+
!*** external "React" ***!
|
|
28
|
+
\************************/
|
|
29
|
+
/***/ ((module) => {
|
|
30
|
+
|
|
31
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_react__;
|
|
32
|
+
|
|
33
|
+
/***/ }),
|
|
34
|
+
|
|
35
|
+
/***/ "hoist-non-react-statics":
|
|
36
|
+
/*!**************************************!*\
|
|
37
|
+
!*** external "hoistNonReactStatic" ***!
|
|
38
|
+
\**************************************/
|
|
39
|
+
/***/ ((module) => {
|
|
40
|
+
|
|
41
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_hoist_non_react_statics__;
|
|
42
|
+
|
|
43
|
+
/***/ }),
|
|
44
|
+
|
|
15
45
|
/***/ "./TextDomain.js":
|
|
16
46
|
/*!***********************!*\
|
|
17
47
|
!*** ./TextDomain.js ***!
|
|
18
48
|
\***********************/
|
|
19
|
-
/***/ ((
|
|
49
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
20
50
|
|
|
21
51
|
__webpack_require__.r(__webpack_exports__);
|
|
22
52
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
23
53
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
24
54
|
/* harmony export */ });
|
|
25
55
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
26
|
-
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
27
56
|
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "prop-types");
|
|
28
|
-
/* harmony import */ var
|
|
29
|
-
/* harmony import */ var _gettext__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gettext */ "./gettext.js");
|
|
57
|
+
/* harmony import */ var _gettext_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gettext.js */ "./gettext.js");
|
|
30
58
|
|
|
31
59
|
|
|
32
60
|
|
|
@@ -47,22 +75,22 @@ class TextDomain extends react__WEBPACK_IMPORTED_MODULE_0__.Component {
|
|
|
47
75
|
|
|
48
76
|
gettext(message) {
|
|
49
77
|
const { translations } = this.props;
|
|
50
|
-
return (0,
|
|
78
|
+
return (0,_gettext_js__WEBPACK_IMPORTED_MODULE_2__.gettext)(translations, message);
|
|
51
79
|
}
|
|
52
80
|
|
|
53
81
|
ngettext(singular, plural, n) {
|
|
54
82
|
const { translations, plural: plurality } = this.props;
|
|
55
|
-
return (0,
|
|
83
|
+
return (0,_gettext_js__WEBPACK_IMPORTED_MODULE_2__.ngettext)(translations, plurality, singular, plural, n);
|
|
56
84
|
}
|
|
57
85
|
|
|
58
86
|
xgettext(message, context) {
|
|
59
87
|
const { translations } = this.props;
|
|
60
|
-
return (0,
|
|
88
|
+
return (0,_gettext_js__WEBPACK_IMPORTED_MODULE_2__.xgettext)(translations, message, context);
|
|
61
89
|
}
|
|
62
90
|
|
|
63
91
|
nxgettext(singular, plural, n, context) {
|
|
64
92
|
const { translations, plural: plurality } = this.props;
|
|
65
|
-
return (0,
|
|
93
|
+
return (0,_gettext_js__WEBPACK_IMPORTED_MODULE_2__.nxgettext)(translations, plurality, singular, plural, n, context);
|
|
66
94
|
}
|
|
67
95
|
|
|
68
96
|
render() {
|
|
@@ -73,20 +101,20 @@ class TextDomain extends react__WEBPACK_IMPORTED_MODULE_0__.Component {
|
|
|
73
101
|
}
|
|
74
102
|
|
|
75
103
|
TextDomain.propTypes = {
|
|
76
|
-
translations:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
104
|
+
translations: prop_types__WEBPACK_IMPORTED_MODULE_1__.oneOfType([
|
|
105
|
+
prop_types__WEBPACK_IMPORTED_MODULE_1__.func,
|
|
106
|
+
prop_types__WEBPACK_IMPORTED_MODULE_1__.objectOf(prop_types__WEBPACK_IMPORTED_MODULE_1__.oneOfType([
|
|
107
|
+
prop_types__WEBPACK_IMPORTED_MODULE_1__.string,
|
|
108
|
+
prop_types__WEBPACK_IMPORTED_MODULE_1__.arrayOf(prop_types__WEBPACK_IMPORTED_MODULE_1__.string),
|
|
81
109
|
])),
|
|
82
110
|
]),
|
|
83
|
-
plural:
|
|
84
|
-
|
|
85
|
-
|
|
111
|
+
plural: prop_types__WEBPACK_IMPORTED_MODULE_1__.oneOfType([
|
|
112
|
+
prop_types__WEBPACK_IMPORTED_MODULE_1__.func,
|
|
113
|
+
prop_types__WEBPACK_IMPORTED_MODULE_1__.string,
|
|
86
114
|
]),
|
|
87
|
-
children:
|
|
88
|
-
|
|
89
|
-
|
|
115
|
+
children: prop_types__WEBPACK_IMPORTED_MODULE_1__.oneOfType([
|
|
116
|
+
prop_types__WEBPACK_IMPORTED_MODULE_1__.node,
|
|
117
|
+
prop_types__WEBPACK_IMPORTED_MODULE_1__.arrayOf(prop_types__WEBPACK_IMPORTED_MODULE_1__.node),
|
|
90
118
|
]),
|
|
91
119
|
};
|
|
92
120
|
|
|
@@ -97,10 +125,10 @@ TextDomain.defaultProps = {
|
|
|
97
125
|
};
|
|
98
126
|
|
|
99
127
|
TextDomain.childContextTypes = {
|
|
100
|
-
gettext:
|
|
101
|
-
ngettext:
|
|
102
|
-
xgettext:
|
|
103
|
-
nxgettext:
|
|
128
|
+
gettext: prop_types__WEBPACK_IMPORTED_MODULE_1__.func,
|
|
129
|
+
ngettext: prop_types__WEBPACK_IMPORTED_MODULE_1__.func,
|
|
130
|
+
xgettext: prop_types__WEBPACK_IMPORTED_MODULE_1__.func,
|
|
131
|
+
nxgettext: prop_types__WEBPACK_IMPORTED_MODULE_1__.func,
|
|
104
132
|
};
|
|
105
133
|
|
|
106
134
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (TextDomain);
|
|
@@ -112,19 +140,18 @@ TextDomain.childContextTypes = {
|
|
|
112
140
|
/*!******************************!*\
|
|
113
141
|
!*** ./TextDomainContext.js ***!
|
|
114
142
|
\******************************/
|
|
115
|
-
/***/ ((
|
|
143
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
116
144
|
|
|
117
145
|
__webpack_require__.r(__webpack_exports__);
|
|
118
146
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
119
147
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
120
148
|
/* harmony export */ });
|
|
121
149
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
122
|
-
/* harmony import */ var
|
|
123
|
-
/* harmony import */ var _buildTextDomain__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buildTextDomain */ "./buildTextDomain.js");
|
|
150
|
+
/* harmony import */ var _buildTextDomain_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buildTextDomain.js */ "./buildTextDomain.js");
|
|
124
151
|
|
|
125
152
|
|
|
126
153
|
|
|
127
|
-
const TextDomainContext =
|
|
154
|
+
const TextDomainContext = react__WEBPACK_IMPORTED_MODULE_0__.createContext((0,_buildTextDomain_js__WEBPACK_IMPORTED_MODULE_1__["default"])({}, 'n != 1'));
|
|
128
155
|
|
|
129
156
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (TextDomainContext);
|
|
130
157
|
|
|
@@ -135,13 +162,13 @@ const TextDomainContext = react__WEBPACK_IMPORTED_MODULE_0___default().createCon
|
|
|
135
162
|
/*!****************************!*\
|
|
136
163
|
!*** ./buildTextDomain.js ***!
|
|
137
164
|
\****************************/
|
|
138
|
-
/***/ ((
|
|
165
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
139
166
|
|
|
140
167
|
__webpack_require__.r(__webpack_exports__);
|
|
141
168
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
142
169
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
143
170
|
/* harmony export */ });
|
|
144
|
-
/* harmony import */ var
|
|
171
|
+
/* harmony import */ var _gettext_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./gettext.js */ "./gettext.js");
|
|
145
172
|
|
|
146
173
|
|
|
147
174
|
/**
|
|
@@ -152,10 +179,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
152
179
|
*/
|
|
153
180
|
function buildTextDomain(translations = {}, plural = "n != 1") {
|
|
154
181
|
return {
|
|
155
|
-
gettext:
|
|
156
|
-
ngettext:
|
|
157
|
-
xgettext:
|
|
158
|
-
nxgettext:
|
|
182
|
+
gettext: _gettext_js__WEBPACK_IMPORTED_MODULE_0__.gettext.bind(null, translations),
|
|
183
|
+
ngettext: _gettext_js__WEBPACK_IMPORTED_MODULE_0__.ngettext.bind(null, translations, plural),
|
|
184
|
+
xgettext: _gettext_js__WEBPACK_IMPORTED_MODULE_0__.xgettext.bind(null, translations),
|
|
185
|
+
nxgettext: _gettext_js__WEBPACK_IMPORTED_MODULE_0__.nxgettext.bind(null, translations, plural)
|
|
159
186
|
};
|
|
160
187
|
}
|
|
161
188
|
|
|
@@ -168,7 +195,7 @@ function buildTextDomain(translations = {}, plural = "n != 1") {
|
|
|
168
195
|
/*!********************!*\
|
|
169
196
|
!*** ./gettext.js ***!
|
|
170
197
|
\********************/
|
|
171
|
-
/***/ ((
|
|
198
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
172
199
|
|
|
173
200
|
__webpack_require__.r(__webpack_exports__);
|
|
174
201
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
@@ -309,17 +336,15 @@ const allDomain = {
|
|
|
309
336
|
/*!************************!*\
|
|
310
337
|
!*** ./withGettext.js ***!
|
|
311
338
|
\************************/
|
|
312
|
-
/***/ ((
|
|
339
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
313
340
|
|
|
314
341
|
__webpack_require__.r(__webpack_exports__);
|
|
315
342
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
316
343
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
317
344
|
/* harmony export */ });
|
|
318
345
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
319
|
-
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
320
346
|
/* harmony import */ var hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! hoist-non-react-statics */ "hoist-non-react-statics");
|
|
321
|
-
/* harmony import */ var
|
|
322
|
-
/* harmony import */ var _TextDomain__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./TextDomain */ "./TextDomain.js");
|
|
347
|
+
/* harmony import */ var _TextDomain_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./TextDomain.js */ "./TextDomain.js");
|
|
323
348
|
|
|
324
349
|
|
|
325
350
|
|
|
@@ -327,7 +352,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
327
352
|
const withGettext = (translations = {}, pluralForm = 'n != 1', options = {}) => (WrappedComponent) => {
|
|
328
353
|
const args = Object.assign({ withRef: false }, options);
|
|
329
354
|
|
|
330
|
-
class WithGettext extends
|
|
355
|
+
class WithGettext extends _TextDomain_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
|
|
331
356
|
|
|
332
357
|
getWrappedComponent() {
|
|
333
358
|
return this.refs.wrappedComponent;
|
|
@@ -339,7 +364,7 @@ const withGettext = (translations = {}, pluralForm = 'n != 1', options = {}) =>
|
|
|
339
364
|
newprops.ref = 'wrappedComponent';
|
|
340
365
|
}
|
|
341
366
|
|
|
342
|
-
return
|
|
367
|
+
return react__WEBPACK_IMPORTED_MODULE_0__.createElement(WrappedComponent, newprops);
|
|
343
368
|
}
|
|
344
369
|
|
|
345
370
|
}
|
|
@@ -351,42 +376,12 @@ const withGettext = (translations = {}, pluralForm = 'n != 1', options = {}) =>
|
|
|
351
376
|
|
|
352
377
|
WithGettext.displayName = `withGettext(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;
|
|
353
378
|
|
|
354
|
-
return
|
|
379
|
+
return hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_1__(WithGettext, WrappedComponent);
|
|
355
380
|
};
|
|
356
381
|
|
|
357
382
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (withGettext);
|
|
358
383
|
|
|
359
384
|
|
|
360
|
-
/***/ }),
|
|
361
|
-
|
|
362
|
-
/***/ "prop-types":
|
|
363
|
-
/*!****************************!*\
|
|
364
|
-
!*** external "PropTypes" ***!
|
|
365
|
-
\****************************/
|
|
366
|
-
/***/ ((module) => {
|
|
367
|
-
|
|
368
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_prop_types__;
|
|
369
|
-
|
|
370
|
-
/***/ }),
|
|
371
|
-
|
|
372
|
-
/***/ "react":
|
|
373
|
-
/*!************************!*\
|
|
374
|
-
!*** external "React" ***!
|
|
375
|
-
\************************/
|
|
376
|
-
/***/ ((module) => {
|
|
377
|
-
|
|
378
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_react__;
|
|
379
|
-
|
|
380
|
-
/***/ }),
|
|
381
|
-
|
|
382
|
-
/***/ "hoist-non-react-statics":
|
|
383
|
-
/*!**************************************!*\
|
|
384
|
-
!*** external "hoistNonReactStatic" ***!
|
|
385
|
-
\**************************************/
|
|
386
|
-
/***/ ((module) => {
|
|
387
|
-
|
|
388
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE_hoist_non_react_statics__;
|
|
389
|
-
|
|
390
385
|
/***/ })
|
|
391
386
|
|
|
392
387
|
/******/ });
|
|
@@ -416,18 +411,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_hoist_non_react_statics__;
|
|
|
416
411
|
/******/ }
|
|
417
412
|
/******/
|
|
418
413
|
/************************************************************************/
|
|
419
|
-
/******/ /* webpack/runtime/compat get default export */
|
|
420
|
-
/******/ (() => {
|
|
421
|
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
422
|
-
/******/ __webpack_require__.n = (module) => {
|
|
423
|
-
/******/ var getter = module && module.__esModule ?
|
|
424
|
-
/******/ () => (module['default']) :
|
|
425
|
-
/******/ () => (module);
|
|
426
|
-
/******/ __webpack_require__.d(getter, { a: getter });
|
|
427
|
-
/******/ return getter;
|
|
428
|
-
/******/ };
|
|
429
|
-
/******/ })();
|
|
430
|
-
/******/
|
|
431
414
|
/******/ /* webpack/runtime/define property getters */
|
|
432
415
|
/******/ (() => {
|
|
433
416
|
/******/ // define getter functions for harmony exports
|
|
@@ -465,15 +448,15 @@ var __webpack_exports__ = {};
|
|
|
465
448
|
\******************/
|
|
466
449
|
__webpack_require__.r(__webpack_exports__);
|
|
467
450
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
468
|
-
/* harmony export */ TextDomain: () => (/* reexport safe */
|
|
469
|
-
/* harmony export */ TextDomainContext: () => (/* reexport safe */
|
|
470
|
-
/* harmony export */ buildTextDomain: () => (/* reexport safe */
|
|
451
|
+
/* harmony export */ TextDomain: () => (/* reexport safe */ _TextDomain_js__WEBPACK_IMPORTED_MODULE_1__["default"]),
|
|
452
|
+
/* harmony export */ TextDomainContext: () => (/* reexport safe */ _TextDomainContext_js__WEBPACK_IMPORTED_MODULE_2__["default"]),
|
|
453
|
+
/* harmony export */ buildTextDomain: () => (/* reexport safe */ _buildTextDomain_js__WEBPACK_IMPORTED_MODULE_3__["default"]),
|
|
471
454
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
472
455
|
/* harmony export */ });
|
|
473
|
-
/* harmony import */ var
|
|
474
|
-
/* harmony import */ var
|
|
475
|
-
/* harmony import */ var
|
|
476
|
-
/* harmony import */ var
|
|
456
|
+
/* harmony import */ var _withGettext_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./withGettext.js */ "./withGettext.js");
|
|
457
|
+
/* harmony import */ var _TextDomain_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./TextDomain.js */ "./TextDomain.js");
|
|
458
|
+
/* harmony import */ var _TextDomainContext_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./TextDomainContext.js */ "./TextDomainContext.js");
|
|
459
|
+
/* harmony import */ var _buildTextDomain_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./buildTextDomain.js */ "./buildTextDomain.js");
|
|
477
460
|
|
|
478
461
|
|
|
479
462
|
|
|
@@ -481,7 +464,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
481
464
|
|
|
482
465
|
|
|
483
466
|
|
|
484
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (
|
|
467
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_withGettext_js__WEBPACK_IMPORTED_MODULE_0__["default"]);
|
|
485
468
|
|
|
486
469
|
})();
|
|
487
470
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("React"),require("hoistNonReactStatic"),require("PropTypes")):"function"==typeof define&&define.amd?define(["React","hoistNonReactStatic","PropTypes"],e):"object"==typeof exports?exports.ReactGettext=e(require("React"),require("hoistNonReactStatic"),require("PropTypes")):t.ReactGettext=e(t.React,t.hoistNonReactStatic,t.PropTypes)}(self,((t,e,n)=>(()=>{"use strict";var r={262:t=>{t.exports=n},883:e=>{e.exports=t},419:t=>{t.exports=e}},o={};function s(t){var e=o[t];if(void 0!==e)return e.exports;var n=o[t]={exports:{}};return r[t](n,n.exports,s),n.exports}s.
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("React"),require("hoistNonReactStatic"),require("PropTypes")):"function"==typeof define&&define.amd?define(["React","hoistNonReactStatic","PropTypes"],e):"object"==typeof exports?exports.ReactGettext=e(require("React"),require("hoistNonReactStatic"),require("PropTypes")):t.ReactGettext=e(t.React,t.hoistNonReactStatic,t.PropTypes)}(self,((t,e,n)=>(()=>{"use strict";var r={262:t=>{t.exports=n},883:e=>{e.exports=t},419:t=>{t.exports=e}},o={};function s(t){var e=o[t];if(void 0!==e)return e.exports;var n=o[t]={exports:{}};return r[t](n,n.exports,s),n.exports}s.d=(t,e)=>{for(var n in e)s.o(e,n)&&!s.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{s.r(i),s.d(i,{TextDomain:()=>x,TextDomainContext:()=>d,buildTextDomain:()=>f,default:()=>y});var t=s(883),e=s(419),n=s(262);function r(t){return"function"==typeof t?t():t}function o(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 ${t}`)(e)}function a(t,e){const n=r(t);return Object.prototype.hasOwnProperty.call(n,e)?n[e]:e}function p(t,e,n,s,i){const a=r(t),p=o(e,i),c=i>1?s:n;return Object.prototype.hasOwnProperty.call(a,n)&&Array.isArray(a[n])&&a[n].length>p&&p>=0?a[n][p]:c}function c(t,e,n){const o=r(t),s=n+""+e;return Object.prototype.hasOwnProperty.call(o,s)?o[s]:e}function u(t,e,n,s,i,a){const p=r(t),c=o(e,i),u=i>1?s:n,l=a+""+n;return Object.prototype.hasOwnProperty.call(p,l)&&Array.isArray(p[l])&&p[l].length>c&&c>=0?p[l][c]:u}class l extends t.Component{getChildContext(){const t=this;return{gettext:t.gettext.bind(t),xgettext:t.xgettext.bind(t),ngettext:t.ngettext.bind(t),nxgettext:t.nxgettext.bind(t)}}gettext(t){const{translations:e}=this.props;return a(e,t)}ngettext(t,e,n){const{translations:r,plural:o}=this.props;return p(r,o,t,e,n)}xgettext(t,e){const{translations:n}=this.props;return c(n,t,e)}nxgettext(t,e,n,r){const{translations:o,plural:s}=this.props;return u(o,s,t,e,n,r)}render(){const{children:t}=this.props;return t}}l.propTypes={translations:n.oneOfType([n.func,n.objectOf(n.oneOfType([n.string,n.arrayOf(n.string)]))]),plural:n.oneOfType([n.func,n.string]),children:n.oneOfType([n.node,n.arrayOf(n.node)])},l.defaultProps={translations:{},plural:"n != 1",children:[]},l.childContextTypes={gettext:n.func,ngettext:n.func,xgettext:n.func,nxgettext:n.func};const x=l,f=function(t={},e="n != 1"){return{gettext:a.bind(null,t),ngettext:p.bind(null,t,e),xgettext:c.bind(null,t),nxgettext:u.bind(null,t,e)}},d=t.createContext(f({},"n != 1")),y=(n={},r="n != 1",o={})=>s=>{const i=Object.assign({withRef:!1},o);class a extends x{getWrappedComponent(){return this.refs.wrappedComponent}render(){const e=Object.assign({},this.props);return i.withRef&&(e.ref="wrappedComponent"),t.createElement(s,e)}}return a.defaultProps={translations:n,plural:r},a.displayName=`withGettext(${s.displayName||s.name||"Component"})`,e(a,s)}})(),i})()));
|
package/lib/TextDomain.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var _gettext = require("./gettext");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
class TextDomain extends _react.Component {
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { gettext, ngettext, xgettext, nxgettext } from './gettext.js';
|
|
4
|
+
class TextDomain extends Component {
|
|
12
5
|
getChildContext() {
|
|
13
6
|
const self = this;
|
|
14
7
|
return {
|
|
@@ -22,27 +15,27 @@ class TextDomain extends _react.Component {
|
|
|
22
15
|
const {
|
|
23
16
|
translations
|
|
24
17
|
} = this.props;
|
|
25
|
-
return
|
|
18
|
+
return gettext(translations, message);
|
|
26
19
|
}
|
|
27
20
|
ngettext(singular, plural, n) {
|
|
28
21
|
const {
|
|
29
22
|
translations,
|
|
30
23
|
plural: plurality
|
|
31
24
|
} = this.props;
|
|
32
|
-
return
|
|
25
|
+
return ngettext(translations, plurality, singular, plural, n);
|
|
33
26
|
}
|
|
34
27
|
xgettext(message, context) {
|
|
35
28
|
const {
|
|
36
29
|
translations
|
|
37
30
|
} = this.props;
|
|
38
|
-
return
|
|
31
|
+
return xgettext(translations, message, context);
|
|
39
32
|
}
|
|
40
33
|
nxgettext(singular, plural, n, context) {
|
|
41
34
|
const {
|
|
42
35
|
translations,
|
|
43
36
|
plural: plurality
|
|
44
37
|
} = this.props;
|
|
45
|
-
return
|
|
38
|
+
return nxgettext(translations, plurality, singular, plural, n, context);
|
|
46
39
|
}
|
|
47
40
|
render() {
|
|
48
41
|
const {
|
|
@@ -52,9 +45,9 @@ class TextDomain extends _react.Component {
|
|
|
52
45
|
}
|
|
53
46
|
}
|
|
54
47
|
TextDomain.propTypes = {
|
|
55
|
-
translations:
|
|
56
|
-
plural:
|
|
57
|
-
children:
|
|
48
|
+
translations: PropTypes.oneOfType([PropTypes.func, PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]))]),
|
|
49
|
+
plural: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
50
|
+
children: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)])
|
|
58
51
|
};
|
|
59
52
|
TextDomain.defaultProps = {
|
|
60
53
|
translations: {},
|
|
@@ -62,9 +55,9 @@ TextDomain.defaultProps = {
|
|
|
62
55
|
children: []
|
|
63
56
|
};
|
|
64
57
|
TextDomain.childContextTypes = {
|
|
65
|
-
gettext:
|
|
66
|
-
ngettext:
|
|
67
|
-
xgettext:
|
|
68
|
-
nxgettext:
|
|
58
|
+
gettext: PropTypes.func,
|
|
59
|
+
ngettext: PropTypes.func,
|
|
60
|
+
xgettext: PropTypes.func,
|
|
61
|
+
nxgettext: PropTypes.func
|
|
69
62
|
};
|
|
70
|
-
|
|
63
|
+
export default TextDomain;
|
package/lib/TextDomainContext.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _buildTextDomain = _interopRequireDefault(require("./buildTextDomain"));
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
const TextDomainContext = /*#__PURE__*/_react.default.createContext((0, _buildTextDomain.default)({}, 'n != 1'));
|
|
11
|
-
var _default = exports.default = TextDomainContext;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import buildTextDomain from './buildTextDomain.js';
|
|
3
|
+
const TextDomainContext = React.createContext(buildTextDomain({}, 'n != 1'));
|
|
4
|
+
export default TextDomainContext;
|
package/lib/buildTextDomain.js
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import { gettext, ngettext, nxgettext, xgettext } from "./gettext.js";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _gettext = require("./gettext");
|
|
8
3
|
/**
|
|
9
4
|
* TODO: We need to add description here
|
|
10
5
|
* @param {object} translations JSON
|
|
11
6
|
* @param {any} plural TODO: No idea obout type
|
|
12
7
|
* @returns {object} JSON
|
|
13
8
|
*/
|
|
14
|
-
function buildTextDomain() {
|
|
15
|
-
let translations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
16
|
-
let plural = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "n != 1";
|
|
9
|
+
function buildTextDomain(translations = {}, plural = "n != 1") {
|
|
17
10
|
return {
|
|
18
|
-
gettext:
|
|
19
|
-
ngettext:
|
|
20
|
-
xgettext:
|
|
21
|
-
nxgettext:
|
|
11
|
+
gettext: gettext.bind(null, translations),
|
|
12
|
+
ngettext: ngettext.bind(null, translations, plural),
|
|
13
|
+
xgettext: xgettext.bind(null, translations),
|
|
14
|
+
nxgettext: nxgettext.bind(null, translations, plural)
|
|
22
15
|
};
|
|
23
16
|
}
|
|
24
|
-
|
|
17
|
+
export default buildTextDomain;
|
package/lib/gettext.js
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
exports.gettext = gettext;
|
|
8
|
-
exports.ngettext = ngettext;
|
|
9
|
-
exports.nxgettext = nxgettext;
|
|
10
|
-
exports.xgettext = xgettext;
|
|
11
1
|
const DELIMITER = "\u0004"; // End of Transmission (EOT)
|
|
12
2
|
|
|
13
3
|
/**
|
|
@@ -53,7 +43,7 @@ function getPluralForm(plural, n) {
|
|
|
53
43
|
* @param {string} message Message
|
|
54
44
|
* @returns {string} Message
|
|
55
45
|
*/
|
|
56
|
-
function gettext(catalog, message) {
|
|
46
|
+
export function gettext(catalog, message) {
|
|
57
47
|
const messages = getTranslations(catalog);
|
|
58
48
|
return Object.prototype.hasOwnProperty.call(messages, message) ? messages[message] : message;
|
|
59
49
|
}
|
|
@@ -67,7 +57,7 @@ function gettext(catalog, message) {
|
|
|
67
57
|
* @param {number} n n
|
|
68
58
|
* @returns {string} Message
|
|
69
59
|
*/
|
|
70
|
-
function ngettext(catalog, plurality, singular, plural, n) {
|
|
60
|
+
export function ngettext(catalog, plurality, singular, plural, n) {
|
|
71
61
|
const messages = getTranslations(catalog);
|
|
72
62
|
const pluralIndex = getPluralForm(plurality, n);
|
|
73
63
|
const defaultValue = n > 1 ? plural : singular;
|
|
@@ -81,7 +71,7 @@ function ngettext(catalog, plurality, singular, plural, n) {
|
|
|
81
71
|
* @param {string} context Context
|
|
82
72
|
* @returns {string} Message
|
|
83
73
|
*/
|
|
84
|
-
function xgettext(catalog, message, context) {
|
|
74
|
+
export function xgettext(catalog, message, context) {
|
|
85
75
|
const messages = getTranslations(catalog);
|
|
86
76
|
const key = context + DELIMITER + message;
|
|
87
77
|
return Object.prototype.hasOwnProperty.call(messages, key) ? messages[key] : message;
|
|
@@ -97,7 +87,7 @@ function xgettext(catalog, message, context) {
|
|
|
97
87
|
* @param {string} context Context
|
|
98
88
|
* @returns {string} Message
|
|
99
89
|
*/
|
|
100
|
-
function nxgettext(catalog, plurality, singular, plural, n, context) {
|
|
90
|
+
export function nxgettext(catalog, plurality, singular, plural, n, context) {
|
|
101
91
|
const messages = getTranslations(catalog);
|
|
102
92
|
const pluralIndex = getPluralForm(plurality, n);
|
|
103
93
|
const defaultValue = n > 1 ? plural : singular;
|
|
@@ -110,4 +100,4 @@ const allDomain = {
|
|
|
110
100
|
xgettext,
|
|
111
101
|
nxgettext
|
|
112
102
|
};
|
|
113
|
-
|
|
103
|
+
export default allDomain;
|
package/lib/index.js
CHANGED
|
@@ -1,30 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _TextDomain.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "TextDomainContext", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _TextDomainContext.default;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "buildTextDomain", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _buildTextDomain.default;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
exports.default = void 0;
|
|
25
|
-
var _withGettext = _interopRequireDefault(require("./withGettext"));
|
|
26
|
-
var _TextDomain = _interopRequireDefault(require("./TextDomain"));
|
|
27
|
-
var _TextDomainContext = _interopRequireDefault(require("./TextDomainContext"));
|
|
28
|
-
var _buildTextDomain = _interopRequireDefault(require("./buildTextDomain"));
|
|
29
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
|
-
var _default = exports.default = _withGettext.default;
|
|
1
|
+
import withGettext from './withGettext.js';
|
|
2
|
+
import TextDomain from './TextDomain.js';
|
|
3
|
+
import TextDomainContext from './TextDomainContext.js';
|
|
4
|
+
import buildTextDomain from './buildTextDomain.js';
|
|
5
|
+
export { TextDomain, TextDomainContext, buildTextDomain };
|
|
6
|
+
export default withGettext;
|
package/lib/withGettext.js
CHANGED
|
@@ -1,39 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const args = Object.assign({
|
|
17
|
-
withRef: false
|
|
18
|
-
}, options);
|
|
19
|
-
class WithGettext extends _TextDomain.default {
|
|
20
|
-
getWrappedComponent() {
|
|
21
|
-
return this.refs.wrappedComponent;
|
|
22
|
-
}
|
|
23
|
-
render() {
|
|
24
|
-
const newprops = Object.assign({}, this.props);
|
|
25
|
-
if (args.withRef) {
|
|
26
|
-
newprops.ref = 'wrappedComponent';
|
|
27
|
-
}
|
|
28
|
-
return /*#__PURE__*/_react.default.createElement(WrappedComponent, newprops);
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import hoistNonReactStatic from 'hoist-non-react-statics';
|
|
3
|
+
import TextDomain from './TextDomain.js';
|
|
4
|
+
const withGettext = (translations = {}, pluralForm = 'n != 1', options = {}) => WrappedComponent => {
|
|
5
|
+
const args = Object.assign({
|
|
6
|
+
withRef: false
|
|
7
|
+
}, options);
|
|
8
|
+
class WithGettext extends TextDomain {
|
|
9
|
+
getWrappedComponent() {
|
|
10
|
+
return this.refs.wrappedComponent;
|
|
11
|
+
}
|
|
12
|
+
render() {
|
|
13
|
+
const newprops = Object.assign({}, this.props);
|
|
14
|
+
if (args.withRef) {
|
|
15
|
+
newprops.ref = 'wrappedComponent';
|
|
29
16
|
}
|
|
17
|
+
return React.createElement(WrappedComponent, newprops);
|
|
30
18
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
WithGettext.displayName = `withGettext(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;
|
|
36
|
-
return (0, _hoistNonReactStatics.default)(WithGettext, WrappedComponent);
|
|
19
|
+
}
|
|
20
|
+
WithGettext.defaultProps = {
|
|
21
|
+
translations,
|
|
22
|
+
plural: pluralForm
|
|
37
23
|
};
|
|
24
|
+
WithGettext.displayName = `withGettext(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;
|
|
25
|
+
return hoistNonReactStatic(WithGettext, WrappedComponent);
|
|
38
26
|
};
|
|
39
|
-
|
|
27
|
+
export default withGettext;
|
package/package.json
CHANGED
package/src/TextDomain.js
CHANGED
package/src/TextDomainContext.js
CHANGED
package/src/buildTextDomain.js
CHANGED
package/src/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import withGettext from './withGettext';
|
|
2
|
-
import TextDomain from './TextDomain';
|
|
3
|
-
import TextDomainContext from './TextDomainContext';
|
|
4
|
-
import buildTextDomain from './buildTextDomain';
|
|
1
|
+
import withGettext from './withGettext.js';
|
|
2
|
+
import TextDomain from './TextDomain.js';
|
|
3
|
+
import TextDomainContext from './TextDomainContext.js';
|
|
4
|
+
import buildTextDomain from './buildTextDomain.js';
|
|
5
5
|
|
|
6
6
|
export {
|
|
7
7
|
TextDomain,
|
package/src/withGettext.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import hoistNonReactStatic from 'hoist-non-react-statics';
|
|
3
|
-
import TextDomain from './TextDomain';
|
|
3
|
+
import TextDomain from './TextDomain.js';
|
|
4
4
|
|
|
5
5
|
const withGettext = (translations = {}, pluralForm = 'n != 1', options = {}) => (WrappedComponent) => {
|
|
6
6
|
const args = Object.assign({ withRef: false }, options);
|