@absolutesight/react-gettext 1.0.6 → 1.0.7
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 +5 -5
- package/LICENSE +21 -21
- package/README.md +431 -365
- package/dist/react-gettext.js +267 -267
- package/dist/react-gettext.min.js +1 -0
- package/lib/TextDomain.js +63 -0
- package/lib/TextDomainContext.js +4 -0
- package/lib/Textdomain.js +69 -69
- package/lib/TextdomainContext.js +10 -10
- package/lib/buildTextDomain.js +17 -0
- package/lib/buildTextdomain.js +23 -23
- package/lib/gettext.js +102 -102
- package/lib/index.js +5 -5
- package/lib/withGettext.js +26 -26
- package/package.json +81 -84
- package/src/TextDomain.js +82 -82
- package/src/TextDomainContext.js +6 -6
- package/src/buildTextDomain.js +18 -18
- package/src/gettext.js +123 -123
- package/src/index.js +12 -12
- package/src/withGettext.js +35 -35
package/src/withGettext.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import hoistNonReactStatic from 'hoist-non-react-statics';
|
|
3
|
-
import TextDomain from './TextDomain.js';
|
|
4
|
-
|
|
5
|
-
const withGettext = (translations = {}, pluralForm = 'n != 1', options = {}) => (WrappedComponent) => {
|
|
6
|
-
const args = Object.assign({ withRef: false }, options);
|
|
7
|
-
|
|
8
|
-
class WithGettext extends TextDomain {
|
|
9
|
-
|
|
10
|
-
getWrappedComponent() {
|
|
11
|
-
return this.refs.wrappedComponent;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
render() {
|
|
15
|
-
const newprops = Object.assign({}, this.props);
|
|
16
|
-
if (args.withRef) {
|
|
17
|
-
newprops.ref = 'wrappedComponent';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return React.createElement(WrappedComponent, newprops);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
WithGettext.defaultProps = {
|
|
26
|
-
translations,
|
|
27
|
-
plural: pluralForm,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
WithGettext.displayName = `withGettext(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;
|
|
31
|
-
|
|
32
|
-
return hoistNonReactStatic(WithGettext, WrappedComponent);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export default withGettext;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import hoistNonReactStatic from 'hoist-non-react-statics';
|
|
3
|
+
import TextDomain from './TextDomain.js';
|
|
4
|
+
|
|
5
|
+
const withGettext = (translations = {}, pluralForm = 'n != 1', options = {}) => (WrappedComponent) => {
|
|
6
|
+
const args = Object.assign({ withRef: false }, options);
|
|
7
|
+
|
|
8
|
+
class WithGettext extends TextDomain {
|
|
9
|
+
|
|
10
|
+
getWrappedComponent() {
|
|
11
|
+
return this.refs.wrappedComponent;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
render() {
|
|
15
|
+
const newprops = Object.assign({}, this.props);
|
|
16
|
+
if (args.withRef) {
|
|
17
|
+
newprops.ref = 'wrappedComponent';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return React.createElement(WrappedComponent, newprops);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
WithGettext.defaultProps = {
|
|
26
|
+
translations,
|
|
27
|
+
plural: pluralForm,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
WithGettext.displayName = `withGettext(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;
|
|
31
|
+
|
|
32
|
+
return hoistNonReactStatic(WithGettext, WrappedComponent);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default withGettext;
|