@zohodesk/i18n 1.0.0-beta.33 → 1.0.0-beta.35-murphy
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/README.md +4 -0
- package/docs/murphy/01-MURPHY_OVERVIEW.md +148 -0
- package/docs/murphy/02-MURPHY_ARCHITECTURE.md +283 -0
- package/docs/murphy/03-MURPHY_BACKEND_CONFIG.md +337 -0
- package/docs/murphy/04-MURPHY_FRONTEND_INIT.md +437 -0
- package/docs/murphy/05-MURPHY_DESK_CLIENT_USAGE.md +467 -0
- package/docs/murphy/06-MURPHY_I18N_INTEGRATION.md +402 -0
- package/docs/murphy/07-MURPHY_WHY_I18N_APPROACH.md +391 -0
- package/es/components/DateTimeDiffFormat.js +5 -19
- package/es/components/FormatText.js +2 -2
- package/es/components/HOCI18N.js +32 -43
- package/es/components/I18N.js +2 -13
- package/es/components/I18NProvider.js +0 -9
- package/es/components/PluralFormat.js +3 -5
- package/es/components/UserTimeDiffFormat.js +5 -9
- package/es/components/__tests__/DateTimeDiffFormat.spec.js +157 -221
- package/es/components/__tests__/FormatText.spec.js +2 -2
- package/es/components/__tests__/HOCI18N.spec.js +2 -4
- package/es/components/__tests__/I18N.spec.js +6 -4
- package/es/components/__tests__/I18NProvider.spec.js +4 -4
- package/es/components/__tests__/PluralFormat.spec.js +2 -2
- package/es/components/__tests__/UserTimeDiffFormat.spec.js +249 -348
- package/es/index.js +2 -0
- package/es/utils/__tests__/jsxTranslations.spec.js +3 -7
- package/es/utils/errorReporter.js +31 -0
- package/es/utils/index.js +42 -92
- package/es/utils/jsxTranslations.js +53 -61
- package/lib/I18NContext.js +2 -7
- package/lib/components/DateTimeDiffFormat.js +46 -87
- package/lib/components/FormatText.js +18 -41
- package/lib/components/HOCI18N.js +24 -59
- package/lib/components/I18N.js +27 -64
- package/lib/components/I18NProvider.js +27 -63
- package/lib/components/PluralFormat.js +24 -50
- package/lib/components/UserTimeDiffFormat.js +43 -72
- package/lib/components/__tests__/DateTimeDiffFormat.spec.js +95 -165
- package/lib/components/__tests__/FormatText.spec.js +3 -10
- package/lib/components/__tests__/HOCI18N.spec.js +3 -14
- package/lib/components/__tests__/I18N.spec.js +4 -12
- package/lib/components/__tests__/I18NProvider.spec.js +8 -23
- package/lib/components/__tests__/PluralFormat.spec.js +3 -11
- package/lib/components/__tests__/UserTimeDiffFormat.spec.js +157 -225
- package/lib/index.js +32 -22
- package/lib/utils/__tests__/jsxTranslations.spec.js +1 -12
- package/lib/utils/errorReporter.js +39 -0
- package/lib/utils/index.js +49 -125
- package/lib/utils/jsxTranslations.js +79 -105
- package/package.json +1 -1
- package/src/index.js +6 -0
- package/src/utils/errorReporter.js +36 -0
- package/src/utils/index.js +8 -1
- package/src/utils/jsxTranslations.js +31 -12
|
@@ -4,9 +4,7 @@ import { getI18NValue, userDateFormat } from "../utils";
|
|
|
4
4
|
import { getI18NComponent } from "../utils/jsxTranslations";
|
|
5
5
|
import { I18NContext } from "../I18NContext";
|
|
6
6
|
const emptyObj = {};
|
|
7
|
-
|
|
8
7
|
const dummy = (key, values) => key;
|
|
9
|
-
|
|
10
8
|
export const i18NProviderUtils = {
|
|
11
9
|
getI18NValue: dummy,
|
|
12
10
|
userDateFormat: dummy,
|
|
@@ -17,12 +15,10 @@ export default class I18NProvider extends React.Component {
|
|
|
17
15
|
super(props, context);
|
|
18
16
|
i18NProviderUtils.getI18NValue = getI18NValue(props.i18n);
|
|
19
17
|
i18NProviderUtils.getI18NComponent = getI18NComponent(props.i18n);
|
|
20
|
-
|
|
21
18
|
if (props.tzData) {
|
|
22
19
|
i18NProviderUtils.userDateFormat = userDateFormat(i18NProviderUtils.getI18NValue, props.tzData, props.timeFormat, props.datePattern, props.isEnabledCurrentYear);
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
|
-
|
|
26
22
|
componentDidUpdate(prevProps) {
|
|
27
23
|
let {
|
|
28
24
|
i18n,
|
|
@@ -34,7 +30,6 @@ export default class I18NProvider extends React.Component {
|
|
|
34
30
|
tzData,
|
|
35
31
|
isEnabledCurrentYear
|
|
36
32
|
} = this.props;
|
|
37
|
-
|
|
38
33
|
if (i18n !== prevProps.i18n || timeZone !== prevProps.timeZone || datePattern !== prevProps.datePattern || timeFormat !== prevProps.timeFormat || direction !== prevProps.direction || tzData !== prevProps.tzData || isEnabledCurrentYear !== prevProps.isEnabledCurrentYear) {
|
|
39
34
|
this.promise = new Promise((res, rej) => {
|
|
40
35
|
this.resolve = res;
|
|
@@ -42,11 +37,9 @@ export default class I18NProvider extends React.Component {
|
|
|
42
37
|
}).then(() => {
|
|
43
38
|
i18NProviderUtils.getI18NValue = getI18NValue(this.props.i18n);
|
|
44
39
|
i18NProviderUtils.getI18NComponent = getI18NComponent(this.props.i18n);
|
|
45
|
-
|
|
46
40
|
if (this.props.tzData) {
|
|
47
41
|
i18NProviderUtils.userDateFormat = userDateFormat(i18NProviderUtils.getI18NValue, this.props.tzData, this.props.timeFormat, this.props.datePattern, this.props.isEnabledCurrentYear);
|
|
48
42
|
}
|
|
49
|
-
|
|
50
43
|
this.promise = null;
|
|
51
44
|
}, () => {
|
|
52
45
|
this.promise = null;
|
|
@@ -54,7 +47,6 @@ export default class I18NProvider extends React.Component {
|
|
|
54
47
|
onChange && onChange(this.resolve, this.reject);
|
|
55
48
|
}
|
|
56
49
|
}
|
|
57
|
-
|
|
58
50
|
render() {
|
|
59
51
|
return /*#__PURE__*/React.createElement(I18NContext.Provider, {
|
|
60
52
|
value: {
|
|
@@ -68,7 +60,6 @@ export default class I18NProvider extends React.Component {
|
|
|
68
60
|
}
|
|
69
61
|
}, this.props.children);
|
|
70
62
|
}
|
|
71
|
-
|
|
72
63
|
}
|
|
73
64
|
I18NProvider.defaultProps = {
|
|
74
65
|
i18n: emptyObj,
|
|
@@ -10,8 +10,7 @@ export default class PluralFormat extends React.Component {
|
|
|
10
10
|
value
|
|
11
11
|
} = this.props;
|
|
12
12
|
let key = '',
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
values = '';
|
|
15
14
|
if (value > 1) {
|
|
16
15
|
key = many;
|
|
17
16
|
} else if (value == 1) {
|
|
@@ -19,9 +18,9 @@ export default class PluralFormat extends React.Component {
|
|
|
19
18
|
} else if (value == 0) {
|
|
20
19
|
key = zero;
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
values = `${value}`;
|
|
24
|
-
return /*#__PURE__*/React.createElement(FormatText, {
|
|
22
|
+
return /*#__PURE__*/React.createElement(FormatText, {
|
|
23
|
+
...this.props,
|
|
25
24
|
i18NKey: key,
|
|
26
25
|
values: values,
|
|
27
26
|
one: null,
|
|
@@ -29,7 +28,6 @@ export default class PluralFormat extends React.Component {
|
|
|
29
28
|
zero: null
|
|
30
29
|
});
|
|
31
30
|
}
|
|
32
|
-
|
|
33
31
|
}
|
|
34
32
|
PluralFormat.propTypes = {
|
|
35
33
|
many: PropTypes.string,
|
|
@@ -31,18 +31,15 @@ export default class UserTimeDiffFormat extends Component {
|
|
|
31
31
|
datePattern,
|
|
32
32
|
isEnabledCurrentYear
|
|
33
33
|
} = this.context || {};
|
|
34
|
-
|
|
35
34
|
if (!format && !others) {
|
|
36
|
-
format =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} = _ref;
|
|
35
|
+
format = ({
|
|
36
|
+
dateTimeFormat,
|
|
37
|
+
dateFormat,
|
|
38
|
+
timeFormat
|
|
39
|
+
}) => {
|
|
42
40
|
displayType === 'dateTime' ? dateTimeFormat : displayType === 'date' ? dateFormat : timeFormat;
|
|
43
41
|
};
|
|
44
42
|
}
|
|
45
|
-
|
|
46
43
|
return /*#__PURE__*/React.createElement(DateTimeDiffFormat, {
|
|
47
44
|
type: type,
|
|
48
45
|
page: page,
|
|
@@ -68,7 +65,6 @@ export default class UserTimeDiffFormat extends Component {
|
|
|
68
65
|
isDateField: isDateField
|
|
69
66
|
});
|
|
70
67
|
}
|
|
71
|
-
|
|
72
68
|
}
|
|
73
69
|
UserTimeDiffFormat.propTypes = {
|
|
74
70
|
ago: PropTypes.string,
|