@zohodesk/i18n 1.0.0-beta.4 → 1.0.0-beta.41-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.
Files changed (70) hide show
  1. package/README.md +130 -4
  2. package/docs/murphy/01-MURPHY_OVERVIEW.md +148 -0
  3. package/docs/murphy/02-MURPHY_ARCHITECTURE.md +283 -0
  4. package/docs/murphy/03-MURPHY_BACKEND_CONFIG.md +337 -0
  5. package/docs/murphy/04-MURPHY_FRONTEND_INIT.md +437 -0
  6. package/docs/murphy/05-MURPHY_DESK_CLIENT_USAGE.md +467 -0
  7. package/docs/murphy/06-MURPHY_I18N_INTEGRATION.md +402 -0
  8. package/docs/murphy/07-MURPHY_WHY_I18N_APPROACH.md +391 -0
  9. package/es/I18NContext.js +1 -2
  10. package/es/components/DateTimeDiffFormat.js +185 -209
  11. package/es/components/FormatText.js +7 -27
  12. package/es/components/HOCI18N.js +35 -58
  13. package/es/components/I18N.js +48 -74
  14. package/es/components/I18NProvider.js +59 -93
  15. package/es/components/PluralFormat.js +28 -51
  16. package/es/components/UserTimeDiffFormat.js +66 -81
  17. package/es/components/__tests__/DateTimeDiffFormat.spec.js +810 -663
  18. package/es/components/__tests__/FormatText.spec.js +22 -19
  19. package/es/components/__tests__/HOCI18N.spec.js +19 -25
  20. package/es/components/__tests__/I18N.spec.js +23 -21
  21. package/es/components/__tests__/I18NProvider.spec.js +38 -47
  22. package/es/components/__tests__/PluralFormat.spec.js +23 -20
  23. package/es/components/__tests__/UserTimeDiffFormat.spec.js +1259 -1110
  24. package/es/index.js +13 -15
  25. package/es/utils/__tests__/jsxTranslations.spec.js +170 -0
  26. package/es/utils/errorReporter.js +41 -0
  27. package/es/utils/index.js +543 -0
  28. package/es/utils/jsxTranslations.js +185 -0
  29. package/lib/I18NContext.js +5 -10
  30. package/lib/components/DateTimeDiffFormat.js +131 -146
  31. package/lib/components/FormatText.js +29 -42
  32. package/lib/components/HOCI18N.js +34 -45
  33. package/lib/components/I18N.js +46 -57
  34. package/lib/components/I18NProvider.js +72 -95
  35. package/lib/components/PluralFormat.js +39 -55
  36. package/lib/components/UserTimeDiffFormat.js +76 -84
  37. package/lib/components/__tests__/DateTimeDiffFormat.spec.js +751 -635
  38. package/lib/components/__tests__/FormatText.spec.js +21 -30
  39. package/lib/components/__tests__/HOCI18N.spec.js +22 -41
  40. package/lib/components/__tests__/I18N.spec.js +20 -33
  41. package/lib/components/__tests__/I18NProvider.spec.js +40 -63
  42. package/lib/components/__tests__/PluralFormat.spec.js +23 -35
  43. package/lib/components/__tests__/UserTimeDiffFormat.spec.js +1195 -1046
  44. package/lib/index.js +83 -104
  45. package/lib/utils/__tests__/jsxTranslations.spec.js +172 -0
  46. package/lib/utils/errorReporter.js +49 -0
  47. package/lib/utils/index.js +583 -0
  48. package/lib/utils/jsxTranslations.js +216 -0
  49. package/package.json +4 -3
  50. package/src/components/DateTimeDiffFormat.js +84 -55
  51. package/src/components/I18N.js +2 -0
  52. package/src/components/I18NProvider.js +44 -33
  53. package/src/components/UserTimeDiffFormat.js +22 -18
  54. package/src/index.js +12 -9
  55. package/src/utils/__tests__/jsxTranslations.spec.js +213 -0
  56. package/src/utils/errorReporter.js +48 -0
  57. package/src/utils/index.js +644 -0
  58. package/src/utils/jsxTranslations.js +199 -0
  59. package/es/components/NewDateFormat.js +0 -50
  60. package/es/offset.js +0 -629
  61. package/es/timezones.js +0 -118
  62. package/es/utils.js +0 -621
  63. package/lib/components/NewDateFormat.js +0 -68
  64. package/lib/offset.js +0 -634
  65. package/lib/timezones.js +0 -129
  66. package/lib/utils.js +0 -651
  67. package/src/components/NewDateFormat.js +0 -60
  68. package/src/offset.js +0 -629
  69. package/src/timezones.js +0 -113
  70. package/src/utils.js +0 -648
@@ -1,26 +1,29 @@
1
- import FormatText from '../FormatText';
2
- import I18NProvider from '../I18NProvider';
1
+ import FormatText from "../FormatText";
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
  });
@@ -1,40 +1,34 @@
1
- import HOCI18N from '..//HOCI18N';
2
- import I18NProvider from '../I18NProvider';
1
+ import HOCI18N from "..//HOCI18N";
2
+ import I18NProvider from "../I18NProvider";
3
3
  import PropTypes from 'prop-types';
4
4
  import React from 'react';
5
5
  import renderer from 'react-test-renderer';
6
-
7
- var Test = function Test(props) {
8
- return React.createElement(
9
- 'div',
10
- null,
11
- 'test',
12
- props.placeHolder
13
- );
14
- };
6
+ let Test = props => /*#__PURE__*/React.createElement("div", null, "test", props.placeHolder);
15
7
  Test.propTypes = {
16
8
  placeHolder: PropTypes.string
17
9
  };
18
- var defaultProps = {
10
+ const defaultProps = {
19
11
  i18NKey: 'key1<b>vimal</b>'
20
12
  };
21
-
22
- describe('I18N component', function () {
23
- it('Should display i18n value', function () {
13
+ describe('I18N component', () => {
14
+ it('Should display i18n value', () => {
24
15
  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();
16
+ let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
17
+ i18n: {
18
+ key1: 'vimal1'
19
+ }
20
+ }, /*#__PURE__*/React.createElement(Test, {
21
+ placeHolder: "key1"
22
+ })));
23
+ let tree = ele.toJSON();
31
24
  expect(tree).toMatchSnapshot();
32
25
  });
33
-
34
- it('Should display i18n key', function () {
26
+ it('Should display i18n key', () => {
35
27
  Test = HOCI18N(['placeHolder'])(Test);
36
- var ele = renderer.create(React.createElement(Test, { placeHolder: 'key1' }));
37
- var tree = ele.toJSON();
28
+ let ele = renderer.create(/*#__PURE__*/React.createElement(Test, {
29
+ placeHolder: "key1"
30
+ }));
31
+ let tree = ele.toJSON();
38
32
  expect(tree).toMatchSnapshot();
39
33
  });
40
34
  });
@@ -1,30 +1,32 @@
1
- import _extends from 'babel-runtime/helpers/extends';
2
- import I18N from '../I18N';
3
- import I18NProvider from '../I18NProvider';
1
+ import I18N from "../I18N";
2
+ import I18NProvider from "../I18NProvider";
4
3
  import React from 'react';
5
4
  import renderer from 'react-test-renderer';
6
-
7
- var defaultProps = {
5
+ const defaultProps = {
8
6
  i18NKey: 'key1'
9
7
  };
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();
8
+ describe('I18N component', () => {
9
+ it('Should display i18n value as html', () => {
10
+ let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
11
+ i18n: {
12
+ key1: 'vimal1<b>vimal</b>'
13
+ }
14
+ }, /*#__PURE__*/React.createElement(I18N, {
15
+ ...defaultProps,
16
+ isHtml: true
17
+ })));
18
+ let tree = ele.toJSON();
18
19
  expect(tree).toMatchSnapshot();
19
20
  });
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();
21
+ it('Should display i18n value', () => {
22
+ let ele = renderer.create(/*#__PURE__*/React.createElement(I18NProvider, {
23
+ i18n: {
24
+ key1: 'vimal1<b>vimal</b>'
25
+ }
26
+ }, /*#__PURE__*/React.createElement(I18N, {
27
+ ...defaultProps
28
+ })));
29
+ let tree = ele.toJSON();
28
30
  expect(tree).toMatchSnapshot();
29
31
  });
30
32
  });
@@ -1,67 +1,58 @@
1
- import I18NProvider, { i18NProviderUtils } from '../I18NProvider';
2
- import I18N from '../I18N';
1
+ import I18NProvider, { i18NProviderUtils } from "../I18NProvider";
2
+ import I18N from "../I18N";
3
3
  import React from 'react';
4
4
  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
  });
@@ -1,27 +1,30 @@
1
- import PluralFormat from '../PluralFormat';
2
- import I18NProvider from '../I18NProvider';
3
- import FormatText from '../FormatText';
1
+ import PluralFormat from "../PluralFormat";
2
+ import I18NProvider from "../I18NProvider";
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
  });