@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.
Files changed (62) hide show
  1. package/README.md +73 -69
  2. package/es/components/HOCI18N.js +33 -30
  3. package/es/components/UserTimeDiffFormat.js +6 -5
  4. package/es/components/__tests__/DateTimeDiffFormat.spec.js +177 -136
  5. package/es/components/__tests__/FormatText.spec.js +0 -1
  6. package/es/components/__tests__/HOCI18N.spec.js +0 -1
  7. package/es/components/__tests__/I18N.spec.js +0 -2
  8. package/es/components/__tests__/I18NProvider.spec.js +0 -1
  9. package/es/components/__tests__/PluralFormat.spec.js +0 -1
  10. package/es/components/__tests__/UserTimeDiffFormat.spec.js +287 -206
  11. package/es/components/__tests__/__snapshots__/DateTimeDiffFormat.spec.js.snap +258 -258
  12. package/es/components/__tests__/__snapshots__/FormatText.spec.js.snap +17 -17
  13. package/es/components/__tests__/__snapshots__/HOCI18N.spec.js.snap +15 -15
  14. package/es/components/__tests__/__snapshots__/I18N.spec.js.snap +17 -17
  15. package/es/components/__tests__/__snapshots__/I18NProvider.spec.js.snap +13 -13
  16. package/es/components/__tests__/__snapshots__/PluralFormat.spec.js.snap +17 -17
  17. package/es/components/__tests__/__snapshots__/UserTimeDiffFormat.spec.js.snap +366 -366
  18. package/es/index.js +1 -1
  19. package/es/utils.js +51 -12
  20. package/lib/components/DateTimeDiffFormat.js +3 -3
  21. package/lib/components/FormatText.js +3 -3
  22. package/lib/components/HOCI18N.js +3 -3
  23. package/lib/components/I18N.js +3 -3
  24. package/lib/components/I18NProvider.js +4 -4
  25. package/lib/components/PluralFormat.js +3 -3
  26. package/lib/components/UserTimeDiffFormat.js +3 -3
  27. package/lib/components/__tests__/I18NProvider.spec.js +1 -1
  28. package/lib/components/__tests__/UserTimeDiffFormat.spec.js +1 -1
  29. package/lib/components/__tests__/__snapshots__/DateTimeDiffFormat.spec.js.snap +258 -258
  30. package/lib/components/__tests__/__snapshots__/FormatText.spec.js.snap +17 -17
  31. package/lib/components/__tests__/__snapshots__/HOCI18N.spec.js.snap +15 -15
  32. package/lib/components/__tests__/__snapshots__/I18N.spec.js.snap +17 -17
  33. package/lib/components/__tests__/__snapshots__/I18NProvider.spec.js.snap +13 -13
  34. package/lib/components/__tests__/__snapshots__/PluralFormat.spec.js.snap +17 -17
  35. package/lib/components/__tests__/__snapshots__/UserTimeDiffFormat.spec.js.snap +366 -366
  36. package/lib/index.js +58 -52
  37. package/lib/utils.js +58 -20
  38. package/package.json +28 -28
  39. package/src/I18NContext.js +2 -2
  40. package/src/components/DateTimeDiffFormat.js +254 -254
  41. package/src/components/FormatText.js +14 -14
  42. package/src/components/HOCI18N.js +37 -37
  43. package/src/components/I18N.js +72 -72
  44. package/src/components/I18NProvider.js +106 -106
  45. package/src/components/PluralFormat.js +37 -37
  46. package/src/components/UserTimeDiffFormat.js +94 -94
  47. package/src/components/__tests__/DateTimeDiffFormat.spec.js +618 -618
  48. package/src/components/__tests__/FormatText.spec.js +26 -26
  49. package/src/components/__tests__/HOCI18N.spec.js +33 -33
  50. package/src/components/__tests__/I18N.spec.js +29 -29
  51. package/src/components/__tests__/I18NProvider.spec.js +65 -65
  52. package/src/components/__tests__/PluralFormat.spec.js +27 -27
  53. package/src/components/__tests__/UserTimeDiffFormat.spec.js +1076 -1076
  54. package/src/components/__tests__/__snapshots__/DateTimeDiffFormat.spec.js.snap +258 -258
  55. package/src/components/__tests__/__snapshots__/FormatText.spec.js.snap +17 -17
  56. package/src/components/__tests__/__snapshots__/HOCI18N.spec.js.snap +15 -15
  57. package/src/components/__tests__/__snapshots__/I18N.spec.js.snap +17 -17
  58. package/src/components/__tests__/__snapshots__/I18NProvider.spec.js.snap +13 -13
  59. package/src/components/__tests__/__snapshots__/PluralFormat.spec.js.snap +17 -17
  60. package/src/components/__tests__/__snapshots__/UserTimeDiffFormat.spec.js.snap +366 -366
  61. package/src/index.js +33 -32
  62. package/src/utils.js +527 -497
package/README.md CHANGED
@@ -1,69 +1,73 @@
1
- # i18n
2
-
3
- # 1.0.0-beta.17
4
-
5
- - 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.
6
-
7
- # 1.0.0-beta.16
8
-
9
- - DatePattern and dateTimePattern key has been changed for the date format build.
10
-
11
- # 1.0.0-beta.15.1
12
-
13
- - Zoho security version updated.
14
-
15
- # 1.0.0-beta.15
16
-
17
- - 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.
18
-
19
- # 1.0.0-beta.14
20
-
21
- - Issue fixed in enable current year.
22
-
23
- # 1.0.0-beta.13
24
-
25
- - Issue fixed in due date.
26
-
27
- # 1.0.0-beta.12
28
-
29
- - Issue fixed in date Format Pattern.
30
-
31
- # 1.0.0-beta.11
32
-
33
- - Date Format Changes
34
-
35
- # 1.0.0-beta.10
36
-
37
- - Date Format Issue Fixes
38
-
39
- # 1.0.0-beta.9
40
-
41
- - Date Format Changes
42
-
43
- # 1.0.0-beta.8
44
-
45
- - ES Module Support Changes
46
-
47
- # 1.0.0-beta.7
48
-
49
- - 'userDateFormat' util method - 'others' function fix
50
-
51
- # 1.0.0-beta.6
52
-
53
- - Added new prop 'isNeedTime' for DateTimeDiffFormat Component
54
-
55
- # 1.0.0-beta.5
56
-
57
- - Timezone logic moved to @zohodesk/datetimejs
58
-
59
- # 1.0.0-beta.4
60
-
61
- - Added new prop 'page' for DateTimeDiffFormat Component
62
-
63
- # 1.0.0-beta.3
64
-
65
- - Added support for exact times along with relative times in format() function
66
-
67
- # 1.0.0-beta.0
68
-
69
- - Test Publish
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
@@ -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 ((i18NKeys = []) => Component => {
8
- class HOCI18N extends React.Component {
9
- constructor(props) {
10
- super(props);
11
- this.getI18NValue = this.getI18NValue.bind(this);
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
- getI18NValue(key) {
15
- const {
16
- i18n
17
- } = this.context || {};
16
+ getI18NValue(key) {
17
+ const {
18
+ i18n
19
+ } = this.context || {};
18
20
 
19
- if (typeof i18n === 'undefined') {
20
- return key;
21
- }
21
+ if (typeof i18n === 'undefined') {
22
+ return key;
23
+ }
24
+
25
+ let i18nStr = i18n[key];
22
26
 
23
- let i18nStr = i18n[key];
27
+ if (i18nStr === undefined) {
28
+ return key;
29
+ }
24
30
 
25
- if (i18nStr === undefined) {
26
- return key;
31
+ return unescapeUnicode(i18nStr);
27
32
  }
28
33
 
29
- return unescapeUnicode(i18nStr);
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
- render() {
33
- let i18nProps = i18NKeys.reduce((result, key) => {
34
- if (this.props[key]) {
35
- result[key] = this.getI18NValue(this.props[key]);
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
- HOCI18N.contextType = I18NContext;
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
- dateTimeFormat,
37
- dateFormat,
38
- timeFormat
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
  }