@zohodesk/i18n 1.0.0-beta.3 → 1.0.0-beta.31

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 (60) hide show
  1. package/README.md +120 -2
  2. package/es/I18NContext.js +1 -2
  3. package/es/components/DateTimeDiffFormat.js +192 -200
  4. package/es/components/FormatText.js +4 -25
  5. package/es/components/HOCI18N.js +33 -45
  6. package/es/components/I18N.js +48 -63
  7. package/es/components/I18NProvider.js +60 -85
  8. package/es/components/PluralFormat.js +29 -48
  9. package/es/components/UserTimeDiffFormat.js +65 -74
  10. package/es/components/__tests__/DateTimeDiffFormat.spec.js +868 -657
  11. package/es/components/__tests__/FormatText.spec.js +20 -17
  12. package/es/components/__tests__/HOCI18N.spec.js +18 -22
  13. package/es/components/__tests__/I18N.spec.js +20 -19
  14. package/es/components/__tests__/I18NProvider.spec.js +36 -45
  15. package/es/components/__tests__/PluralFormat.spec.js +20 -17
  16. package/es/components/__tests__/UserTimeDiffFormat.spec.js +1343 -1095
  17. package/es/index.js +2 -6
  18. package/es/utils/__tests__/jsxTranslations.spec.js +174 -0
  19. package/es/utils/index.js +592 -0
  20. package/es/utils/jsxTranslations.js +193 -0
  21. package/lib/I18NContext.js +6 -6
  22. package/lib/components/DateTimeDiffFormat.js +151 -123
  23. package/lib/components/FormatText.js +32 -22
  24. package/lib/components/HOCI18N.js +47 -23
  25. package/lib/components/I18N.js +62 -36
  26. package/lib/components/I18NProvider.js +85 -72
  27. package/lib/components/PluralFormat.js +42 -32
  28. package/lib/components/UserTimeDiffFormat.js +79 -56
  29. package/lib/components/__tests__/DateTimeDiffFormat.spec.js +815 -629
  30. package/lib/components/__tests__/FormatText.spec.js +23 -25
  31. package/lib/components/__tests__/HOCI18N.spec.js +26 -34
  32. package/lib/components/__tests__/I18N.spec.js +21 -26
  33. package/lib/components/__tests__/I18NProvider.spec.js +43 -51
  34. package/lib/components/__tests__/PluralFormat.spec.js +24 -28
  35. package/lib/components/__tests__/UserTimeDiffFormat.spec.js +1256 -1039
  36. package/lib/index.js +85 -110
  37. package/lib/utils/__tests__/jsxTranslations.spec.js +183 -0
  38. package/lib/utils/index.js +658 -0
  39. package/lib/utils/jsxTranslations.js +242 -0
  40. package/package.json +3 -2
  41. package/src/components/DateTimeDiffFormat.js +86 -55
  42. package/src/components/I18N.js +2 -0
  43. package/src/components/I18NProvider.js +44 -33
  44. package/src/components/UserTimeDiffFormat.js +24 -18
  45. package/src/index.js +7 -9
  46. package/src/utils/__tests__/jsxTranslations.spec.js +213 -0
  47. package/src/utils/index.js +632 -0
  48. package/src/utils/jsxTranslations.js +180 -0
  49. package/es/components/NewDateFormat.js +0 -50
  50. package/es/offset.js +0 -629
  51. package/es/timezones.js +0 -118
  52. package/es/utils.js +0 -621
  53. package/lib/components/NewDateFormat.js +0 -68
  54. package/lib/offset.js +0 -634
  55. package/lib/timezones.js +0 -129
  56. package/lib/utils.js +0 -651
  57. package/src/components/NewDateFormat.js +0 -60
  58. package/src/offset.js +0 -629
  59. package/src/timezones.js +0 -113
  60. package/src/utils.js +0 -648
@@ -2,25 +2,28 @@ import FormatText from '../FormatText';
2
2
  import I18NProvider from '../I18NProvider';
3
3
  import React from 'react';
4
4
  import renderer from 'react-test-renderer';
5
-
6
- describe('FormatText component', function () {
7
- it('Should display i18n value as html', function () {
8
- var ele = renderer.create(React.createElement(
9
- I18NProvider,
10
- { i18n: { key1: 'vimal1<b>vimal</b>' } },
11
- React.createElement(FormatText, { i18NKey: 'key1', isHtml: true })
12
- ));
13
- var tree = ele.toJSON();
5
+ describe('FormatText component', () => {
6
+ it('Should display i18n value as html', () => {
7
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
8
+ i18n: {
9
+ key1: 'vimal1<b>vimal</b>'
10
+ }
11
+ }, /*#__PURE__*/React.createElement(FormatText, {
12
+ i18NKey: "key1",
13
+ isHtml: true
14
+ })));
15
+ let tree = ele.toJSON();
14
16
  expect(tree).toMatchSnapshot();
15
17
  });
16
-
17
- it('Should display i18n value', function () {
18
- var ele = renderer.create(React.createElement(
19
- I18NProvider,
20
- { i18n: { key1: 'vimal1<b>vimal</b>' } },
21
- React.createElement(FormatText, { i18NKey: 'key1' })
22
- ));
23
- var tree = ele.toJSON();
18
+ it('Should display i18n value', () => {
19
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
20
+ i18n: {
21
+ key1: 'vimal1<b>vimal</b>'
22
+ }
23
+ }, /*#__PURE__*/React.createElement(FormatText, {
24
+ i18NKey: "key1"
25
+ })));
26
+ let tree = ele.toJSON();
24
27
  expect(tree).toMatchSnapshot();
25
28
  });
26
29
  });
@@ -4,37 +4,33 @@ import PropTypes from 'prop-types';
4
4
  import React from 'react';
5
5
  import renderer from 'react-test-renderer';
6
6
 
7
- var Test = function Test(props) {
8
- return React.createElement(
9
- 'div',
10
- null,
11
- 'test',
12
- props.placeHolder
13
- );
14
- };
7
+ let Test = props => /*#__PURE__*/React.createElement("div", null, "test", props.placeHolder);
8
+
15
9
  Test.propTypes = {
16
10
  placeHolder: PropTypes.string
17
11
  };
18
- var defaultProps = {
12
+ const defaultProps = {
19
13
  i18NKey: 'key1<b>vimal</b>'
20
14
  };
21
-
22
- describe('I18N component', function () {
23
- it('Should display i18n value', function () {
15
+ describe('I18N component', () => {
16
+ it('Should display i18n value', () => {
24
17
  Test = HOCI18N(['placeHolder'])(Test);
25
- var ele = renderer.create(React.createElement(
26
- I18NProvider,
27
- { i18n: { key1: 'vimal1' } },
28
- React.createElement(Test, { placeHolder: 'key1' })
29
- ));
30
- var tree = ele.toJSON();
18
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
19
+ i18n: {
20
+ key1: 'vimal1'
21
+ }
22
+ }, /*#__PURE__*/React.createElement(Test, {
23
+ placeHolder: "key1"
24
+ })));
25
+ let tree = ele.toJSON();
31
26
  expect(tree).toMatchSnapshot();
32
27
  });
33
-
34
- it('Should display i18n key', function () {
28
+ it('Should display i18n key', () => {
35
29
  Test = HOCI18N(['placeHolder'])(Test);
36
- var ele = renderer.create(React.createElement(Test, { placeHolder: 'key1' }));
37
- var tree = ele.toJSON();
30
+ let ele = renderer.create( /*#__PURE__*/React.createElement(Test, {
31
+ placeHolder: "key1"
32
+ }));
33
+ let tree = ele.toJSON();
38
34
  expect(tree).toMatchSnapshot();
39
35
  });
40
36
  });
@@ -1,30 +1,31 @@
1
- import _extends from 'babel-runtime/helpers/extends';
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
2
3
  import I18N from '../I18N';
3
4
  import I18NProvider from '../I18NProvider';
4
5
  import React from 'react';
5
6
  import renderer from 'react-test-renderer';
6
-
7
- var defaultProps = {
7
+ const defaultProps = {
8
8
  i18NKey: 'key1'
9
9
  };
10
- describe('I18N component', function () {
11
- it('Should display i18n value as html', function () {
12
- var ele = renderer.create(React.createElement(
13
- I18NProvider,
14
- { i18n: { key1: 'vimal1<b>vimal</b>' } },
15
- React.createElement(I18N, _extends({}, defaultProps, { isHtml: true }))
16
- ));
17
- var tree = ele.toJSON();
10
+ describe('I18N component', () => {
11
+ it('Should display i18n value as html', () => {
12
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
13
+ i18n: {
14
+ key1: 'vimal1<b>vimal</b>'
15
+ }
16
+ }, /*#__PURE__*/React.createElement(I18N, _extends({}, defaultProps, {
17
+ isHtml: true
18
+ }))));
19
+ let tree = ele.toJSON();
18
20
  expect(tree).toMatchSnapshot();
19
21
  });
20
-
21
- it('Should display i18n value', function () {
22
- var ele = renderer.create(React.createElement(
23
- I18NProvider,
24
- { i18n: { key1: 'vimal1<b>vimal</b>' } },
25
- React.createElement(I18N, defaultProps)
26
- ));
27
- var tree = ele.toJSON();
22
+ it('Should display i18n value', () => {
23
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
24
+ i18n: {
25
+ key1: 'vimal1<b>vimal</b>'
26
+ }
27
+ }, /*#__PURE__*/React.createElement(I18N, defaultProps)));
28
+ let tree = ele.toJSON();
28
29
  expect(tree).toMatchSnapshot();
29
30
  });
30
31
  });
@@ -5,63 +5,54 @@ import renderer from 'react-test-renderer';
5
5
  import { Provider } from 'react-redux';
6
6
  import configureStore from 'redux-mock-store';
7
7
  import thunk from 'redux-thunk';
8
-
9
- describe('I18NProvider component', function () {
10
- it('Should display i18n value using i18n utils function without I18NProvider', function () {
8
+ describe('I18NProvider component', () => {
9
+ it('Should display i18n value using i18n utils function without I18NProvider', () => {
11
10
  expect(i18NProviderUtils.getI18NValue('key1')).toBe('key1');
12
11
  });
13
-
14
- it('Should display i18n value', function () {
15
- var ele = renderer.create(React.createElement(
16
- I18NProvider,
17
- { i18n: { key1: 'vimal' }, timeZone: 'Asia/Calcutta' },
18
- React.createElement(I18N, { i18NKey: 'key1' })
19
- ));
20
- var tree = ele.toJSON();
12
+ it('Should display i18n value', () => {
13
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
14
+ i18n: {
15
+ key1: 'vimal'
16
+ },
17
+ timeZone: "Asia/Calcutta"
18
+ }, /*#__PURE__*/React.createElement(I18N, {
19
+ i18NKey: "key1"
20
+ })));
21
+ let tree = ele.toJSON();
21
22
  expect(tree).toMatchSnapshot();
22
23
  });
23
-
24
- it('Should display key not available case', function () {
25
- var ele = renderer.create(React.createElement(
26
- I18NProvider,
27
- { i18n: { key1: 'vimal' }, timeZone: 'Asia/Calcutta' },
28
- React.createElement(I18N, { i18NKey: 'key2' })
29
- ));
30
- var tree = ele.toJSON();
24
+ it('Should display key not available case', () => {
25
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
26
+ i18n: {
27
+ key1: 'vimal'
28
+ },
29
+ timeZone: "Asia/Calcutta"
30
+ }, /*#__PURE__*/React.createElement(I18N, {
31
+ i18NKey: "key2"
32
+ })));
33
+ let tree = ele.toJSON();
31
34
  expect(tree).toMatchSnapshot();
32
35
  });
33
-
34
- it('Should display i18n value using i18n utils function', function () {
35
- var ele = renderer.create(React.createElement(
36
- I18NProvider,
37
- { i18n: { key1: 'vimal' } },
38
- React.createElement(
39
- 'div',
40
- null,
41
- 'test'
42
- )
43
- ));
36
+ it('Should display i18n value using i18n utils function', () => {
37
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
38
+ i18n: {
39
+ key1: 'vimal'
40
+ }
41
+ }, /*#__PURE__*/React.createElement("div", null, "test")));
44
42
  expect(i18NProviderUtils.getI18NValue('key1')).toBe('vimal');
45
43
  });
46
-
47
- it('Should display user date format using i18n utils function', function () {
48
- var ele = renderer.create(React.createElement(
49
- I18NProvider,
50
- { i18n: { key1: 'vimal' }, timeZone: 'Asia/Calcutta' },
51
- React.createElement(
52
- 'div',
53
- null,
54
- 'test'
55
- )
56
- ));
44
+ it('Should display user date format using i18n utils function', () => {
45
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
46
+ i18n: {
47
+ key1: 'vimal'
48
+ },
49
+ timeZone: "Asia/Calcutta"
50
+ }, /*#__PURE__*/React.createElement("div", null, "test")));
57
51
  expect(i18NProviderUtils.userDateFormat('2016-12-27T08:36:03.837Z', {
58
52
  today: 'DD-MM-YYYY[today]',
59
53
  tomorrow: 'DD-MM-YYYY[tomorrow]',
60
54
  yesterday: 'DD-MM-YYYY-[yesterday]',
61
-
62
- others: function others() {
63
- return 'DD-MM-YYYY-[others]';
64
- }
55
+ others: () => 'DD-MM-YYYY-[others]'
65
56
  }, '', '', true)).toBe('27-12-2016tomorrow');
66
57
  });
67
58
  });
@@ -3,25 +3,28 @@ import I18NProvider from '../I18NProvider';
3
3
  import FormatText from '../FormatText';
4
4
  import React from 'react';
5
5
  import renderer from 'react-test-renderer';
6
-
7
- describe('PluralFormat component', function () {
8
- it('Should display i18n value as html', function () {
9
- var ele = renderer.create(React.createElement(
10
- I18NProvider,
11
- { i18n: { key1: 'vimal1<b>vimal</b>' } },
12
- React.createElement(FormatText, { i18NKey: 'key1', isHtml: true })
13
- ));
14
- var tree = ele.toJSON();
6
+ describe('PluralFormat component', () => {
7
+ it('Should display i18n value as html', () => {
8
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
9
+ i18n: {
10
+ key1: 'vimal1<b>vimal</b>'
11
+ }
12
+ }, /*#__PURE__*/React.createElement(FormatText, {
13
+ i18NKey: "key1",
14
+ isHtml: true
15
+ })));
16
+ let tree = ele.toJSON();
15
17
  expect(tree).toMatchSnapshot();
16
18
  });
17
-
18
- it('Should display i18n value', function () {
19
- var ele = renderer.create(React.createElement(
20
- I18NProvider,
21
- { i18n: { key1: 'vimal1<b>vimal</b>' } },
22
- React.createElement(FormatText, { i18NKey: 'key1' })
23
- ));
24
- var tree = ele.toJSON();
19
+ it('Should display i18n value', () => {
20
+ let ele = renderer.create( /*#__PURE__*/React.createElement(I18NProvider, {
21
+ i18n: {
22
+ key1: 'vimal1<b>vimal</b>'
23
+ }
24
+ }, /*#__PURE__*/React.createElement(FormatText, {
25
+ i18NKey: "key1"
26
+ })));
27
+ let tree = ele.toJSON();
25
28
  expect(tree).toMatchSnapshot();
26
29
  });
27
30
  });