@zohodesk/i18n 1.0.0-beta.17 → 1.0.0-beta.18
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 +73 -69
- package/es/components/HOCI18N.js +33 -30
- package/es/components/UserTimeDiffFormat.js +6 -5
- package/es/components/__tests__/DateTimeDiffFormat.spec.js +177 -136
- package/es/components/__tests__/FormatText.spec.js +0 -1
- package/es/components/__tests__/HOCI18N.spec.js +0 -1
- package/es/components/__tests__/I18N.spec.js +0 -2
- package/es/components/__tests__/I18NProvider.spec.js +0 -1
- package/es/components/__tests__/PluralFormat.spec.js +0 -1
- package/es/components/__tests__/UserTimeDiffFormat.spec.js +287 -206
- package/es/components/__tests__/__snapshots__/DateTimeDiffFormat.spec.js.snap +258 -258
- package/es/components/__tests__/__snapshots__/FormatText.spec.js.snap +17 -17
- package/es/components/__tests__/__snapshots__/HOCI18N.spec.js.snap +15 -15
- package/es/components/__tests__/__snapshots__/I18N.spec.js.snap +17 -17
- package/es/components/__tests__/__snapshots__/I18NProvider.spec.js.snap +13 -13
- package/es/components/__tests__/__snapshots__/PluralFormat.spec.js.snap +17 -17
- package/es/components/__tests__/__snapshots__/UserTimeDiffFormat.spec.js.snap +366 -366
- package/es/index.js +1 -1
- package/es/utils.js +51 -12
- package/lib/components/DateTimeDiffFormat.js +3 -3
- package/lib/components/FormatText.js +3 -3
- package/lib/components/HOCI18N.js +3 -3
- package/lib/components/I18N.js +3 -3
- package/lib/components/I18NProvider.js +4 -4
- package/lib/components/PluralFormat.js +3 -3
- package/lib/components/UserTimeDiffFormat.js +3 -3
- package/lib/components/__tests__/I18NProvider.spec.js +1 -1
- package/lib/components/__tests__/UserTimeDiffFormat.spec.js +1 -1
- package/lib/components/__tests__/__snapshots__/DateTimeDiffFormat.spec.js.snap +258 -258
- package/lib/components/__tests__/__snapshots__/FormatText.spec.js.snap +17 -17
- package/lib/components/__tests__/__snapshots__/HOCI18N.spec.js.snap +15 -15
- package/lib/components/__tests__/__snapshots__/I18N.spec.js.snap +17 -17
- package/lib/components/__tests__/__snapshots__/I18NProvider.spec.js.snap +13 -13
- package/lib/components/__tests__/__snapshots__/PluralFormat.spec.js.snap +17 -17
- package/lib/components/__tests__/__snapshots__/UserTimeDiffFormat.spec.js.snap +366 -366
- package/lib/index.js +58 -52
- package/lib/utils.js +58 -20
- package/package.json +28 -28
- package/src/I18NContext.js +2 -2
- package/src/components/DateTimeDiffFormat.js +254 -254
- package/src/components/FormatText.js +14 -14
- package/src/components/HOCI18N.js +37 -37
- package/src/components/I18N.js +72 -72
- package/src/components/I18NProvider.js +106 -106
- package/src/components/PluralFormat.js +37 -37
- package/src/components/UserTimeDiffFormat.js +94 -94
- package/src/components/__tests__/DateTimeDiffFormat.spec.js +618 -618
- package/src/components/__tests__/FormatText.spec.js +26 -26
- package/src/components/__tests__/HOCI18N.spec.js +33 -33
- package/src/components/__tests__/I18N.spec.js +29 -29
- package/src/components/__tests__/I18NProvider.spec.js +65 -65
- package/src/components/__tests__/PluralFormat.spec.js +27 -27
- package/src/components/__tests__/UserTimeDiffFormat.spec.js +1076 -1076
- package/src/components/__tests__/__snapshots__/DateTimeDiffFormat.spec.js.snap +258 -258
- package/src/components/__tests__/__snapshots__/FormatText.spec.js.snap +17 -17
- package/src/components/__tests__/__snapshots__/HOCI18N.spec.js.snap +15 -15
- package/src/components/__tests__/__snapshots__/I18N.spec.js.snap +17 -17
- package/src/components/__tests__/__snapshots__/I18NProvider.spec.js.snap +13 -13
- package/src/components/__tests__/__snapshots__/PluralFormat.spec.js.snap +17 -17
- package/src/components/__tests__/__snapshots__/UserTimeDiffFormat.spec.js.snap +366 -366
- package/src/index.js +33 -32
- package/src/utils.js +527 -497
package/README.md
CHANGED
|
@@ -1,69 +1,73 @@
|
|
|
1
|
-
# i18n
|
|
2
|
-
|
|
3
|
-
# 1.0.0-beta.
|
|
4
|
-
|
|
5
|
-
-
|
|
6
|
-
|
|
7
|
-
# 1.0.0-beta.
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
# 1.0.0-beta.
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
# 1.0.0-beta.15
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
# 1.0.0-beta.
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
# 1.0.0-beta.
|
|
24
|
-
|
|
25
|
-
- Issue fixed in
|
|
26
|
-
|
|
27
|
-
# 1.0.0-beta.
|
|
28
|
-
|
|
29
|
-
- Issue fixed in date
|
|
30
|
-
|
|
31
|
-
# 1.0.0-beta.
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
# 1.0.0-beta.
|
|
36
|
-
|
|
37
|
-
- Date Format
|
|
38
|
-
|
|
39
|
-
# 1.0.0-beta.
|
|
40
|
-
|
|
41
|
-
- Date Format
|
|
42
|
-
|
|
43
|
-
# 1.0.0-beta.
|
|
44
|
-
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
# 1.0.0-beta.
|
|
48
|
-
|
|
49
|
-
-
|
|
50
|
-
|
|
51
|
-
# 1.0.0-beta.
|
|
52
|
-
|
|
53
|
-
-
|
|
54
|
-
|
|
55
|
-
# 1.0.0-beta.
|
|
56
|
-
|
|
57
|
-
-
|
|
58
|
-
|
|
59
|
-
# 1.0.0-beta.
|
|
60
|
-
|
|
61
|
-
-
|
|
62
|
-
|
|
63
|
-
# 1.0.0-beta.
|
|
64
|
-
|
|
65
|
-
- Added
|
|
66
|
-
|
|
67
|
-
# 1.0.0-beta.
|
|
68
|
-
|
|
69
|
-
-
|
|
1
|
+
# i18n
|
|
2
|
+
|
|
3
|
+
# 1.0.0-beta.18
|
|
4
|
+
|
|
5
|
+
- Localization feature added and incorporated into getI18NValue Method.
|
|
6
|
+
|
|
7
|
+
# 1.0.0-beta.17
|
|
8
|
+
|
|
9
|
+
- There was some i18n changes done in live before moving the date format build to live. Since we need these changes we have published it as new version.
|
|
10
|
+
|
|
11
|
+
# 1.0.0-beta.16
|
|
12
|
+
|
|
13
|
+
- DatePattern and dateTimePattern key has been changed for the date format build.
|
|
14
|
+
|
|
15
|
+
# 1.0.0-beta.15.1
|
|
16
|
+
|
|
17
|
+
- Zoho security version updated.
|
|
18
|
+
|
|
19
|
+
# 1.0.0-beta.15
|
|
20
|
+
|
|
21
|
+
- When working on date format build we have published I18n. Also, before moving date format build to master we had a emergency fix that need to be sent, so when publishing I18n we have published the date format changes with the next version.
|
|
22
|
+
|
|
23
|
+
# 1.0.0-beta.14
|
|
24
|
+
|
|
25
|
+
- Issue fixed in enable current year.
|
|
26
|
+
|
|
27
|
+
# 1.0.0-beta.13
|
|
28
|
+
|
|
29
|
+
- Issue fixed in due date.
|
|
30
|
+
|
|
31
|
+
# 1.0.0-beta.12
|
|
32
|
+
|
|
33
|
+
- Issue fixed in date Format Pattern.
|
|
34
|
+
|
|
35
|
+
# 1.0.0-beta.11
|
|
36
|
+
|
|
37
|
+
- Date Format Changes
|
|
38
|
+
|
|
39
|
+
# 1.0.0-beta.10
|
|
40
|
+
|
|
41
|
+
- Date Format Issue Fixes
|
|
42
|
+
|
|
43
|
+
# 1.0.0-beta.9
|
|
44
|
+
|
|
45
|
+
- Date Format Changes
|
|
46
|
+
|
|
47
|
+
# 1.0.0-beta.8
|
|
48
|
+
|
|
49
|
+
- ES Module Support Changes
|
|
50
|
+
|
|
51
|
+
# 1.0.0-beta.7
|
|
52
|
+
|
|
53
|
+
- 'userDateFormat' util method - 'others' function fix
|
|
54
|
+
|
|
55
|
+
# 1.0.0-beta.6
|
|
56
|
+
|
|
57
|
+
- Added new prop 'isNeedTime' for DateTimeDiffFormat Component
|
|
58
|
+
|
|
59
|
+
# 1.0.0-beta.5
|
|
60
|
+
|
|
61
|
+
- Timezone logic moved to @zohodesk/datetimejs
|
|
62
|
+
|
|
63
|
+
# 1.0.0-beta.4
|
|
64
|
+
|
|
65
|
+
- Added new prop 'page' for DateTimeDiffFormat Component
|
|
66
|
+
|
|
67
|
+
# 1.0.0-beta.3
|
|
68
|
+
|
|
69
|
+
- Added support for exact times along with relative times in format() function
|
|
70
|
+
|
|
71
|
+
# 1.0.0-beta.0
|
|
72
|
+
|
|
73
|
+
- Test Publish
|
package/es/components/HOCI18N.js
CHANGED
|
@@ -4,44 +4,47 @@ import React, { Children } from 'react';
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { replaceI18NValuesWithRegex, unescapeUnicode } from '../utils';
|
|
6
6
|
import { I18NContext } from '../I18NContext';
|
|
7
|
-
export default ((
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
export default (function () {
|
|
8
|
+
let i18NKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
9
|
+
return Component => {
|
|
10
|
+
class HOCI18N extends React.Component {
|
|
11
|
+
constructor(props) {
|
|
12
|
+
super(props);
|
|
13
|
+
this.getI18NValue = this.getI18NValue.bind(this);
|
|
14
|
+
}
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
getI18NValue(key) {
|
|
17
|
+
const {
|
|
18
|
+
i18n
|
|
19
|
+
} = this.context || {};
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
if (typeof i18n === 'undefined') {
|
|
22
|
+
return key;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let i18nStr = i18n[key];
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
if (i18nStr === undefined) {
|
|
28
|
+
return key;
|
|
29
|
+
}
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
return key;
|
|
31
|
+
return unescapeUnicode(i18nStr);
|
|
27
32
|
}
|
|
28
33
|
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
render() {
|
|
35
|
+
let i18nProps = i18NKeys.reduce((result, key) => {
|
|
36
|
+
if (this.props[key]) {
|
|
37
|
+
result[key] = this.getI18NValue(this.props[key]);
|
|
38
|
+
}
|
|
31
39
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
40
|
+
return result;
|
|
41
|
+
}, {});
|
|
42
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, this.props, i18nProps));
|
|
43
|
+
}
|
|
37
44
|
|
|
38
|
-
return result;
|
|
39
|
-
}, {});
|
|
40
|
-
return /*#__PURE__*/React.createElement(Component, _extends({}, this.props, i18nProps));
|
|
41
45
|
}
|
|
42
46
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return HOCI18N;
|
|
47
|
+
HOCI18N.contextType = I18NContext;
|
|
48
|
+
return HOCI18N;
|
|
49
|
+
};
|
|
47
50
|
});
|
|
@@ -32,11 +32,12 @@ export default class UserTimeDiffFormat extends Component {
|
|
|
32
32
|
} = this.context || {};
|
|
33
33
|
|
|
34
34
|
if (!format && !others) {
|
|
35
|
-
format =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
format = _ref => {
|
|
36
|
+
let {
|
|
37
|
+
dateTimeFormat,
|
|
38
|
+
dateFormat,
|
|
39
|
+
timeFormat
|
|
40
|
+
} = _ref;
|
|
40
41
|
displayType === 'dateTime' ? dateTimeFormat : displayType === 'date' ? dateFormat : timeFormat;
|
|
41
42
|
};
|
|
42
43
|
}
|