@zohodesk/i18n 1.0.0-beta.3 → 1.0.0-beta.30
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 +116 -2
- package/es/I18NContext.js +1 -2
- package/es/components/DateTimeDiffFormat.js +192 -200
- package/es/components/FormatText.js +4 -25
- package/es/components/HOCI18N.js +33 -45
- package/es/components/I18N.js +48 -63
- package/es/components/I18NProvider.js +59 -85
- package/es/components/PluralFormat.js +29 -48
- package/es/components/UserTimeDiffFormat.js +65 -74
- package/es/components/__tests__/DateTimeDiffFormat.spec.js +868 -657
- package/es/components/__tests__/FormatText.spec.js +20 -17
- package/es/components/__tests__/HOCI18N.spec.js +18 -22
- package/es/components/__tests__/I18N.spec.js +20 -19
- package/es/components/__tests__/I18NProvider.spec.js +36 -45
- package/es/components/__tests__/PluralFormat.spec.js +20 -17
- package/es/components/__tests__/UserTimeDiffFormat.spec.js +1343 -1095
- package/es/index.js +2 -6
- package/es/utils/__tests__/jsxTranslations.spec.js +174 -0
- package/es/utils/index.js +592 -0
- package/es/utils/jsxTranslations.js +193 -0
- package/lib/I18NContext.js +6 -6
- package/lib/components/DateTimeDiffFormat.js +151 -123
- package/lib/components/FormatText.js +32 -22
- package/lib/components/HOCI18N.js +47 -23
- package/lib/components/I18N.js +62 -36
- package/lib/components/I18NProvider.js +82 -70
- package/lib/components/PluralFormat.js +42 -32
- package/lib/components/UserTimeDiffFormat.js +79 -56
- package/lib/components/__tests__/DateTimeDiffFormat.spec.js +815 -629
- package/lib/components/__tests__/FormatText.spec.js +23 -25
- package/lib/components/__tests__/HOCI18N.spec.js +26 -34
- package/lib/components/__tests__/I18N.spec.js +21 -26
- package/lib/components/__tests__/I18NProvider.spec.js +43 -51
- package/lib/components/__tests__/PluralFormat.spec.js +24 -28
- package/lib/components/__tests__/UserTimeDiffFormat.spec.js +1256 -1039
- package/lib/index.js +85 -110
- package/lib/utils/__tests__/jsxTranslations.spec.js +183 -0
- package/lib/utils/index.js +658 -0
- package/lib/utils/jsxTranslations.js +242 -0
- package/package.json +3 -2
- package/src/components/DateTimeDiffFormat.js +86 -55
- package/src/components/I18N.js +2 -0
- package/src/components/I18NProvider.js +34 -25
- package/src/components/UserTimeDiffFormat.js +24 -18
- package/src/index.js +7 -9
- package/src/utils/__tests__/jsxTranslations.spec.js +213 -0
- package/src/utils/index.js +632 -0
- package/src/utils/jsxTranslations.js +180 -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
|
@@ -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
|
-
|
|
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
|
});
|
|
@@ -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
|
-
|
|
8
|
-
|
|
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
|
-
|
|
12
|
+
const defaultProps = {
|
|
19
13
|
i18NKey: 'key1<b>vimal</b>'
|
|
20
14
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
it('Should display i18n value', function () {
|
|
15
|
+
describe('I18N component', () => {
|
|
16
|
+
it('Should display i18n value', () => {
|
|
24
17
|
Test = HOCI18N(['placeHolder'])(Test);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
37
|
-
|
|
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
|
-
|
|
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',
|
|
11
|
-
it('Should display i18n value as html',
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
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
|
});
|
|
@@ -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
|
-
|
|
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
|
});
|