@absolutesight/react-gettext 0.0.1
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/CHANGELOG.md +48 -0
- package/LICENSE +21 -0
- package/README.md +369 -0
- package/dist/react-gettext.js +500 -0
- package/dist/react-gettext.min.js +1 -0
- package/lib/TextDomain.js +70 -0
- package/lib/TextDomainContext.js +11 -0
- package/lib/Textdomain.js +70 -0
- package/lib/TextdomainContext.js +11 -0
- package/lib/buildTextDomain.js +24 -0
- package/lib/buildTextdomain.js +24 -0
- package/lib/gettext.js +113 -0
- package/lib/index.js +30 -0
- package/lib/withGettext.js +39 -0
- package/package.json +81 -0
- package/src/TextDomain.js +82 -0
- package/src/TextDomainContext.js +7 -0
- package/src/buildTextDomain.js +19 -0
- package/src/gettext.js +123 -0
- package/src/index.js +12 -0
- package/src/withGettext.js +40 -0
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
+
module.exports = factory(require("React"), require("PropTypes"), require("hoistNonReactStatic"));
|
|
4
|
+
else if(typeof define === 'function' && define.amd)
|
|
5
|
+
define(["React", "PropTypes", "hoistNonReactStatic"], factory);
|
|
6
|
+
else if(typeof exports === 'object')
|
|
7
|
+
exports["ReactGettext"] = factory(require("React"), require("PropTypes"), require("hoistNonReactStatic"));
|
|
8
|
+
else
|
|
9
|
+
root["ReactGettext"] = factory(root["React"], root["PropTypes"], root["hoistNonReactStatic"]);
|
|
10
|
+
})(self, (__WEBPACK_EXTERNAL_MODULE_react__, __WEBPACK_EXTERNAL_MODULE_prop_types__, __WEBPACK_EXTERNAL_MODULE_hoist_non_react_statics__) => {
|
|
11
|
+
return /******/ (() => { // webpackBootstrap
|
|
12
|
+
/******/ "use strict";
|
|
13
|
+
/******/ var __webpack_modules__ = ({
|
|
14
|
+
|
|
15
|
+
/***/ "./TextDomain.js":
|
|
16
|
+
/*!***********************!*\
|
|
17
|
+
!*** ./TextDomain.js ***!
|
|
18
|
+
\***********************/
|
|
19
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
20
|
+
|
|
21
|
+
__webpack_require__.r(__webpack_exports__);
|
|
22
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
23
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
24
|
+
/* harmony export */ });
|
|
25
|
+
/* harmony import */ var _gettext__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./gettext */ "./gettext.js");
|
|
26
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "react");
|
|
27
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
28
|
+
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! prop-types */ "prop-types");
|
|
29
|
+
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_2__);
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class TextDomain extends react__WEBPACK_IMPORTED_MODULE_1__.Component {
|
|
37
|
+
|
|
38
|
+
getChildContext() {
|
|
39
|
+
const self = this;
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
gettext: self.gettext.bind(self),
|
|
43
|
+
xgettext: self.xgettext.bind(self),
|
|
44
|
+
ngettext: self.ngettext.bind(self),
|
|
45
|
+
nxgettext: self.nxgettext.bind(self),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
gettext(message) {
|
|
50
|
+
const { translations } = this.props;
|
|
51
|
+
return (0,_gettext__WEBPACK_IMPORTED_MODULE_0__.gettext)(translations, message);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
ngettext(singular, plural, n) {
|
|
55
|
+
const { translations, plural: plurality } = this.props;
|
|
56
|
+
return (0,_gettext__WEBPACK_IMPORTED_MODULE_0__.ngettext)(translations, plurality, singular, plural, n);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
xgettext(message, context) {
|
|
60
|
+
const { translations } = this.props;
|
|
61
|
+
return (0,_gettext__WEBPACK_IMPORTED_MODULE_0__.xgettext)(translations, message, context);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
nxgettext(singular, plural, n, context) {
|
|
65
|
+
const { translations, plural: plurality } = this.props;
|
|
66
|
+
return (0,_gettext__WEBPACK_IMPORTED_MODULE_0__.nxgettext)(translations, plurality, singular, plural, n, context);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
render() {
|
|
70
|
+
const { children } = this.props;
|
|
71
|
+
return children;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
TextDomain.propTypes = {
|
|
77
|
+
translations: prop_types__WEBPACK_IMPORTED_MODULE_2___default().oneOfType([
|
|
78
|
+
(prop_types__WEBPACK_IMPORTED_MODULE_2___default().func),
|
|
79
|
+
prop_types__WEBPACK_IMPORTED_MODULE_2___default().objectOf(prop_types__WEBPACK_IMPORTED_MODULE_2___default().oneOfType([
|
|
80
|
+
(prop_types__WEBPACK_IMPORTED_MODULE_2___default().string),
|
|
81
|
+
prop_types__WEBPACK_IMPORTED_MODULE_2___default().arrayOf((prop_types__WEBPACK_IMPORTED_MODULE_2___default().string)),
|
|
82
|
+
])),
|
|
83
|
+
]),
|
|
84
|
+
plural: prop_types__WEBPACK_IMPORTED_MODULE_2___default().oneOfType([
|
|
85
|
+
(prop_types__WEBPACK_IMPORTED_MODULE_2___default().func),
|
|
86
|
+
(prop_types__WEBPACK_IMPORTED_MODULE_2___default().string),
|
|
87
|
+
]),
|
|
88
|
+
children: prop_types__WEBPACK_IMPORTED_MODULE_2___default().oneOfType([
|
|
89
|
+
(prop_types__WEBPACK_IMPORTED_MODULE_2___default().node),
|
|
90
|
+
prop_types__WEBPACK_IMPORTED_MODULE_2___default().arrayOf((prop_types__WEBPACK_IMPORTED_MODULE_2___default().node)),
|
|
91
|
+
]),
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
TextDomain.defaultProps = {
|
|
95
|
+
translations: {
|
|
96
|
+
},
|
|
97
|
+
plural: 'n != 1',
|
|
98
|
+
children: [],
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
TextDomain.childContextTypes = {
|
|
102
|
+
gettext: (prop_types__WEBPACK_IMPORTED_MODULE_2___default().func),
|
|
103
|
+
ngettext: (prop_types__WEBPACK_IMPORTED_MODULE_2___default().func),
|
|
104
|
+
xgettext: (prop_types__WEBPACK_IMPORTED_MODULE_2___default().func),
|
|
105
|
+
nxgettext: (prop_types__WEBPACK_IMPORTED_MODULE_2___default().func),
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (TextDomain);
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
/***/ }),
|
|
112
|
+
|
|
113
|
+
/***/ "./TextDomainContext.js":
|
|
114
|
+
/*!******************************!*\
|
|
115
|
+
!*** ./TextDomainContext.js ***!
|
|
116
|
+
\******************************/
|
|
117
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
118
|
+
|
|
119
|
+
__webpack_require__.r(__webpack_exports__);
|
|
120
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
121
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
122
|
+
/* harmony export */ });
|
|
123
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
124
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
125
|
+
/* harmony import */ var _buildTextDomain__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buildTextDomain */ "./buildTextDomain.js");
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
const TextDomainContext = react__WEBPACK_IMPORTED_MODULE_0___default().createContext((0,_buildTextDomain__WEBPACK_IMPORTED_MODULE_1__["default"])({
|
|
130
|
+
}, 'n != 1'));
|
|
131
|
+
|
|
132
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (TextDomainContext);
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
/***/ }),
|
|
136
|
+
|
|
137
|
+
/***/ "./buildTextDomain.js":
|
|
138
|
+
/*!****************************!*\
|
|
139
|
+
!*** ./buildTextDomain.js ***!
|
|
140
|
+
\****************************/
|
|
141
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
142
|
+
|
|
143
|
+
__webpack_require__.r(__webpack_exports__);
|
|
144
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
145
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
146
|
+
/* harmony export */ });
|
|
147
|
+
/* harmony import */ var _gettext__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./gettext */ "./gettext.js");
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* TODO: We need to add description here
|
|
152
|
+
* @param {object} translations JSON
|
|
153
|
+
* @param {any} plural TODO: No idea obout type
|
|
154
|
+
* @returns {object} JSON
|
|
155
|
+
*/
|
|
156
|
+
function buildTextDomain(translations = {
|
|
157
|
+
}, plural = "n != 1") {
|
|
158
|
+
return {
|
|
159
|
+
gettext: _gettext__WEBPACK_IMPORTED_MODULE_0__.gettext.bind(null, translations),
|
|
160
|
+
ngettext: _gettext__WEBPACK_IMPORTED_MODULE_0__.ngettext.bind(null, translations, plural),
|
|
161
|
+
xgettext: _gettext__WEBPACK_IMPORTED_MODULE_0__.xgettext.bind(null, translations),
|
|
162
|
+
nxgettext: _gettext__WEBPACK_IMPORTED_MODULE_0__.nxgettext.bind(null, translations, plural)
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (buildTextDomain);
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
/***/ }),
|
|
170
|
+
|
|
171
|
+
/***/ "./gettext.js":
|
|
172
|
+
/*!********************!*\
|
|
173
|
+
!*** ./gettext.js ***!
|
|
174
|
+
\********************/
|
|
175
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
176
|
+
|
|
177
|
+
__webpack_require__.r(__webpack_exports__);
|
|
178
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
179
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
|
|
180
|
+
/* harmony export */ gettext: () => (/* binding */ gettext),
|
|
181
|
+
/* harmony export */ ngettext: () => (/* binding */ ngettext),
|
|
182
|
+
/* harmony export */ nxgettext: () => (/* binding */ nxgettext),
|
|
183
|
+
/* harmony export */ xgettext: () => (/* binding */ xgettext)
|
|
184
|
+
/* harmony export */ });
|
|
185
|
+
const DELIMITER = "\u0004"; // End of Transmission (EOT)
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* TODO: We need to add description here
|
|
189
|
+
* @param {any} catalog string or function
|
|
190
|
+
* @returns {string} string or string from a function
|
|
191
|
+
*/
|
|
192
|
+
function getTranslations(catalog) {
|
|
193
|
+
return typeof catalog === "function" ? catalog() : catalog;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* TODO: We need to add description here
|
|
198
|
+
* @param {any} plural string or function
|
|
199
|
+
* @param {any} n TODO: No idea what will pass in it
|
|
200
|
+
* @returns {any} 0 if nothing
|
|
201
|
+
*/
|
|
202
|
+
function getPluralForm(plural, n) {
|
|
203
|
+
// return 0 if n is not integer
|
|
204
|
+
if (Number.isNaN(parseInt(n, 10))) {
|
|
205
|
+
return 0;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// if pluralForm is function, use it to get plural form index
|
|
209
|
+
if (typeof plural === "function") {
|
|
210
|
+
return plural(n);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// if pluralForm is string and contains only "n", "0-9", " ", "!=?:%+-/*><&|()"
|
|
214
|
+
// characters, then we can "eval" it to calculate plural form
|
|
215
|
+
if (typeof plural === "string" && !plural.match(/[^n0-9 !=?:%+-/*><&|()]/i)) {
|
|
216
|
+
/* eslint-disable no-new-func */
|
|
217
|
+
const calcPlural = Function("n", `return ${plural}`);
|
|
218
|
+
/* eslint-enable no-new-func */
|
|
219
|
+
return +calcPlural(n);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return 0;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* TODO: We need to add description here
|
|
227
|
+
* @param {string} catalog Catalog
|
|
228
|
+
* @param {string} message Message
|
|
229
|
+
* @returns {string} Message
|
|
230
|
+
*/
|
|
231
|
+
function gettext(catalog, message) {
|
|
232
|
+
const messages = getTranslations(catalog);
|
|
233
|
+
return Object.prototype.hasOwnProperty.call(messages, message)
|
|
234
|
+
? messages[message]
|
|
235
|
+
: message;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* TODO: WE need to add description here
|
|
240
|
+
* @param {string} catalog Catalog
|
|
241
|
+
* @param {string} plurality Plurality
|
|
242
|
+
* @param {string} singular Singular
|
|
243
|
+
* @param {string} plural Plural
|
|
244
|
+
* @param {number} n n
|
|
245
|
+
* @returns {string} Message
|
|
246
|
+
*/
|
|
247
|
+
function ngettext(catalog, plurality, singular, plural, n) {
|
|
248
|
+
const messages = getTranslations(catalog);
|
|
249
|
+
const pluralIndex = getPluralForm(plurality, n);
|
|
250
|
+
const defaultValue = n > 1 ? plural : singular;
|
|
251
|
+
|
|
252
|
+
return Object.prototype.hasOwnProperty.call(messages, singular) &&
|
|
253
|
+
Array.isArray(messages[singular]) &&
|
|
254
|
+
messages[singular].length > pluralIndex &&
|
|
255
|
+
pluralIndex >= 0
|
|
256
|
+
? messages[singular][pluralIndex]
|
|
257
|
+
: defaultValue;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* TODO: We need to add description here
|
|
262
|
+
* @param {string} catalog Catalog
|
|
263
|
+
* @param {string} message Message
|
|
264
|
+
* @param {string} context Context
|
|
265
|
+
* @returns {string} Message
|
|
266
|
+
*/
|
|
267
|
+
function xgettext(catalog, message, context) {
|
|
268
|
+
const messages = getTranslations(catalog);
|
|
269
|
+
const key = context + DELIMITER + message;
|
|
270
|
+
|
|
271
|
+
return Object.prototype.hasOwnProperty.call(messages, key)
|
|
272
|
+
? messages[key]
|
|
273
|
+
: message;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* TODO: We need to add description here
|
|
278
|
+
* @param {string} catalog Catalog
|
|
279
|
+
* @param {string} plurality Plurality
|
|
280
|
+
* @param {string} singular Singular
|
|
281
|
+
* @param {string} plural Plural
|
|
282
|
+
* @param {number} n n
|
|
283
|
+
* @param {string} context Context
|
|
284
|
+
* @returns {string} Message
|
|
285
|
+
*/
|
|
286
|
+
function nxgettext(catalog, plurality, singular, plural, n, context) {
|
|
287
|
+
const messages = getTranslations(catalog);
|
|
288
|
+
const pluralIndex = getPluralForm(plurality, n);
|
|
289
|
+
const defaultValue = n > 1 ? plural : singular;
|
|
290
|
+
const key = context + DELIMITER + singular;
|
|
291
|
+
|
|
292
|
+
return Object.prototype.hasOwnProperty.call(messages, key) &&
|
|
293
|
+
Array.isArray(messages[key]) &&
|
|
294
|
+
messages[key].length > pluralIndex &&
|
|
295
|
+
pluralIndex >= 0
|
|
296
|
+
? messages[key][pluralIndex]
|
|
297
|
+
: defaultValue;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const allDomain = {
|
|
301
|
+
gettext,
|
|
302
|
+
ngettext,
|
|
303
|
+
xgettext,
|
|
304
|
+
nxgettext
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (allDomain);
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
/***/ }),
|
|
311
|
+
|
|
312
|
+
/***/ "./withGettext.js":
|
|
313
|
+
/*!************************!*\
|
|
314
|
+
!*** ./withGettext.js ***!
|
|
315
|
+
\************************/
|
|
316
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
317
|
+
|
|
318
|
+
__webpack_require__.r(__webpack_exports__);
|
|
319
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
320
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
321
|
+
/* harmony export */ });
|
|
322
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
323
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
324
|
+
/* harmony import */ var _TextDomain__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./TextDomain */ "./TextDomain.js");
|
|
325
|
+
/* harmony import */ var hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! hoist-non-react-statics */ "hoist-non-react-statics");
|
|
326
|
+
/* harmony import */ var hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_2__);
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
const withGettext = (translations = {
|
|
332
|
+
}, pluralForm = 'n != 1', options = {
|
|
333
|
+
}) => (WrappedComponent) => {
|
|
334
|
+
const args = Object.assign({
|
|
335
|
+
withRef: false
|
|
336
|
+
}, options);
|
|
337
|
+
|
|
338
|
+
class WithGettext extends _TextDomain__WEBPACK_IMPORTED_MODULE_1__["default"] {
|
|
339
|
+
|
|
340
|
+
getWrappedComponent() {
|
|
341
|
+
return this.refs.wrappedComponent;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
render() {
|
|
345
|
+
const newprops = Object.assign({
|
|
346
|
+
}, this.props);
|
|
347
|
+
if (args.withRef) {
|
|
348
|
+
newprops.ref = 'wrappedComponent';
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return react__WEBPACK_IMPORTED_MODULE_0___default().createElement(WrappedComponent, newprops);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
WithGettext.defaultProps = {
|
|
357
|
+
translations,
|
|
358
|
+
plural: pluralForm,
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
WithGettext.displayName = `withGettext(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;
|
|
362
|
+
|
|
363
|
+
return hoist_non_react_statics__WEBPACK_IMPORTED_MODULE_2___default()(WithGettext, WrappedComponent);
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (withGettext);
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
/***/ }),
|
|
370
|
+
|
|
371
|
+
/***/ "prop-types":
|
|
372
|
+
/*!****************************!*\
|
|
373
|
+
!*** external "PropTypes" ***!
|
|
374
|
+
\****************************/
|
|
375
|
+
/***/ ((module) => {
|
|
376
|
+
|
|
377
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_prop_types__;
|
|
378
|
+
|
|
379
|
+
/***/ }),
|
|
380
|
+
|
|
381
|
+
/***/ "react":
|
|
382
|
+
/*!************************!*\
|
|
383
|
+
!*** external "React" ***!
|
|
384
|
+
\************************/
|
|
385
|
+
/***/ ((module) => {
|
|
386
|
+
|
|
387
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_react__;
|
|
388
|
+
|
|
389
|
+
/***/ }),
|
|
390
|
+
|
|
391
|
+
/***/ "hoist-non-react-statics":
|
|
392
|
+
/*!**************************************!*\
|
|
393
|
+
!*** external "hoistNonReactStatic" ***!
|
|
394
|
+
\**************************************/
|
|
395
|
+
/***/ ((module) => {
|
|
396
|
+
|
|
397
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_hoist_non_react_statics__;
|
|
398
|
+
|
|
399
|
+
/***/ })
|
|
400
|
+
|
|
401
|
+
/******/ });
|
|
402
|
+
/************************************************************************/
|
|
403
|
+
/******/ // The module cache
|
|
404
|
+
/******/ var __webpack_module_cache__ = {};
|
|
405
|
+
/******/
|
|
406
|
+
/******/ // The require function
|
|
407
|
+
/******/ function __webpack_require__(moduleId) {
|
|
408
|
+
/******/ // Check if module is in cache
|
|
409
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
410
|
+
/******/ if (cachedModule !== undefined) {
|
|
411
|
+
/******/ return cachedModule.exports;
|
|
412
|
+
/******/ }
|
|
413
|
+
/******/ // Create a new module (and put it into the cache)
|
|
414
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
415
|
+
/******/ // no module.id needed
|
|
416
|
+
/******/ // no module.loaded needed
|
|
417
|
+
/******/ exports: {}
|
|
418
|
+
/******/ };
|
|
419
|
+
/******/
|
|
420
|
+
/******/ // Execute the module function
|
|
421
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
422
|
+
/******/
|
|
423
|
+
/******/ // Return the exports of the module
|
|
424
|
+
/******/ return module.exports;
|
|
425
|
+
/******/ }
|
|
426
|
+
/******/
|
|
427
|
+
/************************************************************************/
|
|
428
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
429
|
+
/******/ (() => {
|
|
430
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
431
|
+
/******/ __webpack_require__.n = (module) => {
|
|
432
|
+
/******/ var getter = module && module.__esModule ?
|
|
433
|
+
/******/ () => (module['default']) :
|
|
434
|
+
/******/ () => (module);
|
|
435
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
436
|
+
/******/ return getter;
|
|
437
|
+
/******/ };
|
|
438
|
+
/******/ })();
|
|
439
|
+
/******/
|
|
440
|
+
/******/ /* webpack/runtime/define property getters */
|
|
441
|
+
/******/ (() => {
|
|
442
|
+
/******/ // define getter functions for harmony exports
|
|
443
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
444
|
+
/******/ for(var key in definition) {
|
|
445
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
446
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
447
|
+
/******/ }
|
|
448
|
+
/******/ }
|
|
449
|
+
/******/ };
|
|
450
|
+
/******/ })();
|
|
451
|
+
/******/
|
|
452
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
453
|
+
/******/ (() => {
|
|
454
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
455
|
+
/******/ })();
|
|
456
|
+
/******/
|
|
457
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
458
|
+
/******/ (() => {
|
|
459
|
+
/******/ // define __esModule on exports
|
|
460
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
461
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
462
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
463
|
+
/******/ }
|
|
464
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
465
|
+
/******/ };
|
|
466
|
+
/******/ })();
|
|
467
|
+
/******/
|
|
468
|
+
/************************************************************************/
|
|
469
|
+
var __webpack_exports__ = {};
|
|
470
|
+
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
471
|
+
(() => {
|
|
472
|
+
/*!******************!*\
|
|
473
|
+
!*** ./index.js ***!
|
|
474
|
+
\******************/
|
|
475
|
+
__webpack_require__.r(__webpack_exports__);
|
|
476
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
477
|
+
/* harmony export */ TextDomain: () => (/* reexport safe */ _TextDomain__WEBPACK_IMPORTED_MODULE_0__["default"]),
|
|
478
|
+
/* harmony export */ TextDomainContext: () => (/* reexport safe */ _TextDomainContext__WEBPACK_IMPORTED_MODULE_1__["default"]),
|
|
479
|
+
/* harmony export */ buildTextDomain: () => (/* reexport safe */ _buildTextDomain__WEBPACK_IMPORTED_MODULE_2__["default"]),
|
|
480
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
481
|
+
/* harmony export */ });
|
|
482
|
+
/* harmony import */ var _TextDomain__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./TextDomain */ "./TextDomain.js");
|
|
483
|
+
/* harmony import */ var _TextDomainContext__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./TextDomainContext */ "./TextDomainContext.js");
|
|
484
|
+
/* harmony import */ var _buildTextDomain__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buildTextDomain */ "./buildTextDomain.js");
|
|
485
|
+
/* harmony import */ var _withGettext__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./withGettext */ "./withGettext.js");
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_withGettext__WEBPACK_IMPORTED_MODULE_3__["default"]);
|
|
494
|
+
|
|
495
|
+
})();
|
|
496
|
+
|
|
497
|
+
/******/ return __webpack_exports__;
|
|
498
|
+
/******/ })()
|
|
499
|
+
;
|
|
500
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("React"),require("PropTypes"),require("hoistNonReactStatic")):"function"==typeof define&&define.amd?define(["React","PropTypes","hoistNonReactStatic"],e):"object"==typeof exports?exports.ReactGettext=e(require("React"),require("PropTypes"),require("hoistNonReactStatic")):t.ReactGettext=e(t.React,t.PropTypes,t.hoistNonReactStatic)}(self,((t,e,n)=>(()=>{"use strict";var r={552:t=>{t.exports=e},624:e=>{e.exports=t},42:t=>{t.exports=n}},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.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},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 a={};return(()=>{s.r(a),s.d(a,{TextDomain:()=>f,TextDomainContext:()=>y,buildTextDomain:()=>d,default:()=>h});function t(t){return"function"==typeof t?t():t}function e(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 n(e,n){const r=t(e);return Object.prototype.hasOwnProperty.call(r,n)?r[n]:n}function r(n,r,o,s,a){const i=t(n),p=e(r,a),c=a>1?s:o;return Object.prototype.hasOwnProperty.call(i,o)&&Array.isArray(i[o])&&i[o].length>p&&p>=0?i[o][p]:c}function o(e,n,r){const o=t(e),s=r+""+n;return Object.prototype.hasOwnProperty.call(o,s)?o[s]:n}function i(n,r,o,s,a,i){const p=t(n),c=e(r,a),u=a>1?s:o,l=i+""+o;return Object.prototype.hasOwnProperty.call(p,l)&&Array.isArray(p[l])&&p[l].length>c&&c>=0?p[l][c]:u}var p=s(624),c=s.n(p),u=s(552),l=s.n(u);class x extends p.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 n(e,t)}ngettext(t,e,n){const{translations:o,plural:s}=this.props;return r(o,s,t,e,n)}xgettext(t,e){const{translations:n}=this.props;return o(n,t,e)}nxgettext(t,e,n,r){const{translations:o,plural:s}=this.props;return i(o,s,t,e,n,r)}render(){const{children:t}=this.props;return t}}x.propTypes={translations:l().oneOfType([l().func,l().objectOf(l().oneOfType([l().string,l().arrayOf(l().string)]))]),plural:l().oneOfType([l().func,l().string]),children:l().oneOfType([l().node,l().arrayOf(l().node)])},x.defaultProps={translations:{},plural:"n != 1",children:[]},x.childContextTypes={gettext:l().func,ngettext:l().func,xgettext:l().func,nxgettext:l().func};const f=x,d=function(t={},e="n != 1"){return{gettext:n.bind(null,t),ngettext:r.bind(null,t,e),xgettext:o.bind(null,t),nxgettext:i.bind(null,t,e)}},y=c().createContext(d({},"n != 1"));var g=s(42),b=s.n(g);const h=(t={},e="n != 1",n={})=>r=>{const o=Object.assign({withRef:!1},n);class s extends f{getWrappedComponent(){return this.refs.wrappedComponent}render(){const t=Object.assign({},this.props);return o.withRef&&(t.ref="wrappedComponent"),c().createElement(r,t)}}return s.defaultProps={translations:t,plural:e},s.displayName=`withGettext(${r.displayName||r.name||"Component"})`,b()(s,r)}})(),a})()));
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _gettext = require("./gettext");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
class TextDomain extends _react.Component {
|
|
12
|
+
getChildContext() {
|
|
13
|
+
const self = this;
|
|
14
|
+
return {
|
|
15
|
+
gettext: self.gettext.bind(self),
|
|
16
|
+
xgettext: self.xgettext.bind(self),
|
|
17
|
+
ngettext: self.ngettext.bind(self),
|
|
18
|
+
nxgettext: self.nxgettext.bind(self)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
gettext(message) {
|
|
22
|
+
const {
|
|
23
|
+
translations
|
|
24
|
+
} = this.props;
|
|
25
|
+
return (0, _gettext.gettext)(translations, message);
|
|
26
|
+
}
|
|
27
|
+
ngettext(singular, plural, n) {
|
|
28
|
+
const {
|
|
29
|
+
translations,
|
|
30
|
+
plural: plurality
|
|
31
|
+
} = this.props;
|
|
32
|
+
return (0, _gettext.ngettext)(translations, plurality, singular, plural, n);
|
|
33
|
+
}
|
|
34
|
+
xgettext(message, context) {
|
|
35
|
+
const {
|
|
36
|
+
translations
|
|
37
|
+
} = this.props;
|
|
38
|
+
return (0, _gettext.xgettext)(translations, message, context);
|
|
39
|
+
}
|
|
40
|
+
nxgettext(singular, plural, n, context) {
|
|
41
|
+
const {
|
|
42
|
+
translations,
|
|
43
|
+
plural: plurality
|
|
44
|
+
} = this.props;
|
|
45
|
+
return (0, _gettext.nxgettext)(translations, plurality, singular, plural, n, context);
|
|
46
|
+
}
|
|
47
|
+
render() {
|
|
48
|
+
const {
|
|
49
|
+
children
|
|
50
|
+
} = this.props;
|
|
51
|
+
return children;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
TextDomain.propTypes = {
|
|
55
|
+
translations: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.objectOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]))]),
|
|
56
|
+
plural: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.string]),
|
|
57
|
+
children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.arrayOf(_propTypes.default.node)])
|
|
58
|
+
};
|
|
59
|
+
TextDomain.defaultProps = {
|
|
60
|
+
translations: {},
|
|
61
|
+
plural: 'n != 1',
|
|
62
|
+
children: []
|
|
63
|
+
};
|
|
64
|
+
TextDomain.childContextTypes = {
|
|
65
|
+
gettext: _propTypes.default.func,
|
|
66
|
+
ngettext: _propTypes.default.func,
|
|
67
|
+
xgettext: _propTypes.default.func,
|
|
68
|
+
nxgettext: _propTypes.default.func
|
|
69
|
+
};
|
|
70
|
+
var _default = exports.default = TextDomain;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
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;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
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 {
|
|
12
|
+
getChildContext() {
|
|
13
|
+
const self = this;
|
|
14
|
+
return {
|
|
15
|
+
gettext: self.gettext.bind(self),
|
|
16
|
+
xgettext: self.xgettext.bind(self),
|
|
17
|
+
ngettext: self.ngettext.bind(self),
|
|
18
|
+
nxgettext: self.nxgettext.bind(self)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
gettext(message) {
|
|
22
|
+
const {
|
|
23
|
+
translations
|
|
24
|
+
} = this.props;
|
|
25
|
+
return (0, _gettext.gettext)(translations, message);
|
|
26
|
+
}
|
|
27
|
+
ngettext(singular, plural, n) {
|
|
28
|
+
const {
|
|
29
|
+
translations,
|
|
30
|
+
plural: plurality
|
|
31
|
+
} = this.props;
|
|
32
|
+
return (0, _gettext.ngettext)(translations, plurality, singular, plural, n);
|
|
33
|
+
}
|
|
34
|
+
xgettext(message, context) {
|
|
35
|
+
const {
|
|
36
|
+
translations
|
|
37
|
+
} = this.props;
|
|
38
|
+
return (0, _gettext.xgettext)(translations, message, context);
|
|
39
|
+
}
|
|
40
|
+
nxgettext(singular, plural, n, context) {
|
|
41
|
+
const {
|
|
42
|
+
translations,
|
|
43
|
+
plural: plurality
|
|
44
|
+
} = this.props;
|
|
45
|
+
return (0, _gettext.nxgettext)(translations, plurality, singular, plural, n, context);
|
|
46
|
+
}
|
|
47
|
+
render() {
|
|
48
|
+
const {
|
|
49
|
+
children
|
|
50
|
+
} = this.props;
|
|
51
|
+
return children;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
Textdomain.propTypes = {
|
|
55
|
+
translations: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.objectOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]))]),
|
|
56
|
+
plural: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.string]),
|
|
57
|
+
children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.arrayOf(_propTypes.default.node)])
|
|
58
|
+
};
|
|
59
|
+
Textdomain.defaultProps = {
|
|
60
|
+
translations: {},
|
|
61
|
+
plural: 'n != 1',
|
|
62
|
+
children: []
|
|
63
|
+
};
|
|
64
|
+
Textdomain.childContextTypes = {
|
|
65
|
+
gettext: _propTypes.default.func,
|
|
66
|
+
ngettext: _propTypes.default.func,
|
|
67
|
+
xgettext: _propTypes.default.func,
|
|
68
|
+
nxgettext: _propTypes.default.func
|
|
69
|
+
};
|
|
70
|
+
var _default = exports.default = Textdomain;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
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;
|