@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.
- package/README.md +130 -4
- 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/I18NContext.js +1 -2
- package/es/components/DateTimeDiffFormat.js +185 -209
- package/es/components/FormatText.js +7 -27
- package/es/components/HOCI18N.js +35 -58
- package/es/components/I18N.js +48 -74
- package/es/components/I18NProvider.js +59 -93
- package/es/components/PluralFormat.js +28 -51
- package/es/components/UserTimeDiffFormat.js +66 -81
- package/es/components/__tests__/DateTimeDiffFormat.spec.js +810 -663
- package/es/components/__tests__/FormatText.spec.js +22 -19
- package/es/components/__tests__/HOCI18N.spec.js +19 -25
- package/es/components/__tests__/I18N.spec.js +23 -21
- package/es/components/__tests__/I18NProvider.spec.js +38 -47
- package/es/components/__tests__/PluralFormat.spec.js +23 -20
- package/es/components/__tests__/UserTimeDiffFormat.spec.js +1259 -1110
- package/es/index.js +13 -15
- package/es/utils/__tests__/jsxTranslations.spec.js +170 -0
- package/es/utils/errorReporter.js +41 -0
- package/es/utils/index.js +543 -0
- package/es/utils/jsxTranslations.js +185 -0
- package/lib/I18NContext.js +5 -10
- package/lib/components/DateTimeDiffFormat.js +131 -146
- package/lib/components/FormatText.js +29 -42
- package/lib/components/HOCI18N.js +34 -45
- package/lib/components/I18N.js +46 -57
- package/lib/components/I18NProvider.js +72 -95
- package/lib/components/PluralFormat.js +39 -55
- package/lib/components/UserTimeDiffFormat.js +76 -84
- package/lib/components/__tests__/DateTimeDiffFormat.spec.js +751 -635
- package/lib/components/__tests__/FormatText.spec.js +21 -30
- package/lib/components/__tests__/HOCI18N.spec.js +22 -41
- package/lib/components/__tests__/I18N.spec.js +20 -33
- package/lib/components/__tests__/I18NProvider.spec.js +40 -63
- package/lib/components/__tests__/PluralFormat.spec.js +23 -35
- package/lib/components/__tests__/UserTimeDiffFormat.spec.js +1195 -1046
- package/lib/index.js +83 -104
- package/lib/utils/__tests__/jsxTranslations.spec.js +172 -0
- package/lib/utils/errorReporter.js +49 -0
- package/lib/utils/index.js +583 -0
- package/lib/utils/jsxTranslations.js +216 -0
- package/package.json +4 -3
- package/src/components/DateTimeDiffFormat.js +84 -55
- package/src/components/I18N.js +2 -0
- package/src/components/I18NProvider.js +44 -33
- package/src/components/UserTimeDiffFormat.js +22 -18
- package/src/index.js +12 -9
- package/src/utils/__tests__/jsxTranslations.spec.js +213 -0
- package/src/utils/errorReporter.js +48 -0
- package/src/utils/index.js +644 -0
- package/src/utils/jsxTranslations.js +199 -0
- package/es/components/NewDateFormat.js +0 -50
- package/es/offset.js +0 -629
- package/es/timezones.js +0 -118
- package/es/utils.js +0 -621
- package/lib/components/NewDateFormat.js +0 -68
- package/lib/offset.js +0 -634
- package/lib/timezones.js +0 -129
- package/lib/utils.js +0 -651
- package/src/components/NewDateFormat.js +0 -60
- package/src/offset.js +0 -629
- package/src/timezones.js +0 -113
- package/src/utils.js +0 -648
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
import FormatText from
|
|
2
|
-
import I18NProvider from
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|
2
|
-
import I18NProvider from
|
|
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
|
-
|
|
10
|
+
const defaultProps = {
|
|
19
11
|
i18NKey: 'key1<b>vimal</b>'
|
|
20
12
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
it('Should display i18n value', function () {
|
|
13
|
+
describe('I18N component', () => {
|
|
14
|
+
it('Should display i18n value', () => {
|
|
24
15
|
Test = HOCI18N(['placeHolder'])(Test);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
37
|
-
|
|
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
|
|
2
|
-
import
|
|
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',
|
|
11
|
-
it('Should display i18n value as html',
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
|
2
|
-
import I18N from
|
|
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
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
2
|
-
import I18NProvider from
|
|
3
|
-
import FormatText from
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
});
|