@zohodesk/i18n 1.0.0-beta.23 → 1.0.0-beta.24
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 +97 -92
- package/es/components/__tests__/__snapshots__/DateTimeDiffFormat.spec.js.snap +258 -258
- package/es/components/__tests__/__snapshots__/FormatText.spec.js.snap +17 -17
- package/es/components/__tests__/__snapshots__/HOCI18N.spec.js.snap +15 -15
- package/es/components/__tests__/__snapshots__/I18N.spec.js.snap +17 -17
- package/es/components/__tests__/__snapshots__/I18NProvider.spec.js.snap +13 -13
- package/es/components/__tests__/__snapshots__/PluralFormat.spec.js.snap +17 -17
- package/es/components/__tests__/__snapshots__/UserTimeDiffFormat.spec.js.snap +366 -366
- package/es/index.js +1 -1
- package/es/utils.js +62 -9
- package/lib/components/__tests__/__snapshots__/DateTimeDiffFormat.spec.js.snap +258 -258
- package/lib/components/__tests__/__snapshots__/FormatText.spec.js.snap +17 -17
- package/lib/components/__tests__/__snapshots__/HOCI18N.spec.js.snap +15 -15
- package/lib/components/__tests__/__snapshots__/I18N.spec.js.snap +17 -17
- package/lib/components/__tests__/__snapshots__/I18NProvider.spec.js.snap +13 -13
- package/lib/components/__tests__/__snapshots__/PluralFormat.spec.js.snap +17 -17
- package/lib/components/__tests__/__snapshots__/UserTimeDiffFormat.spec.js.snap +366 -366
- package/lib/index.js +18 -0
- package/lib/utils.js +65 -9
- package/package.json +29 -29
- package/src/I18NContext.js +2 -2
- package/src/components/DateTimeDiffFormat.js +256 -256
- package/src/components/FormatText.js +14 -14
- package/src/components/HOCI18N.js +37 -37
- package/src/components/I18N.js +74 -74
- package/src/components/I18NProvider.js +110 -110
- package/src/components/PluralFormat.js +37 -37
- package/src/components/UserTimeDiffFormat.js +97 -97
- package/src/components/__tests__/DateTimeDiffFormat.spec.js +618 -618
- package/src/components/__tests__/FormatText.spec.js +26 -26
- package/src/components/__tests__/HOCI18N.spec.js +33 -33
- package/src/components/__tests__/I18N.spec.js +29 -29
- package/src/components/__tests__/I18NProvider.spec.js +65 -65
- package/src/components/__tests__/PluralFormat.spec.js +27 -27
- package/src/components/__tests__/UserTimeDiffFormat.spec.js +1076 -1076
- package/src/components/__tests__/__snapshots__/DateTimeDiffFormat.spec.js.snap +258 -258
- package/src/components/__tests__/__snapshots__/FormatText.spec.js.snap +17 -17
- package/src/components/__tests__/__snapshots__/HOCI18N.spec.js.snap +15 -15
- package/src/components/__tests__/__snapshots__/I18N.spec.js.snap +17 -17
- package/src/components/__tests__/__snapshots__/I18NProvider.spec.js.snap +13 -13
- package/src/components/__tests__/__snapshots__/PluralFormat.spec.js.snap +17 -17
- package/src/components/__tests__/__snapshots__/UserTimeDiffFormat.spec.js.snap +366 -366
- package/src/index.js +36 -33
- package/src/utils.js +585 -527
package/lib/index.js
CHANGED
|
@@ -53,6 +53,12 @@ Object.defineProperty(exports, "UserTimeDiffFormat", {
|
|
|
53
53
|
return _UserTimeDiffFormat["default"];
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
|
+
Object.defineProperty(exports, "dayi18n", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function get() {
|
|
59
|
+
return _utils.dayi18n;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
56
62
|
Object.defineProperty(exports, "formatDate", {
|
|
57
63
|
enumerable: true,
|
|
58
64
|
get: function get() {
|
|
@@ -132,6 +138,12 @@ Object.defineProperty(exports, "isYesterday", {
|
|
|
132
138
|
return _utils.isYesterday;
|
|
133
139
|
}
|
|
134
140
|
});
|
|
141
|
+
Object.defineProperty(exports, "monthi18n", {
|
|
142
|
+
enumerable: true,
|
|
143
|
+
get: function get() {
|
|
144
|
+
return _utils.monthi18n;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
135
147
|
Object.defineProperty(exports, "pad", {
|
|
136
148
|
enumerable: true,
|
|
137
149
|
get: function get() {
|
|
@@ -150,6 +162,12 @@ Object.defineProperty(exports, "setLocalizedData", {
|
|
|
150
162
|
return _utils.setLocalizedData;
|
|
151
163
|
}
|
|
152
164
|
});
|
|
165
|
+
Object.defineProperty(exports, "timei18n", {
|
|
166
|
+
enumerable: true,
|
|
167
|
+
get: function get() {
|
|
168
|
+
return _utils.timei18n;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
153
171
|
Object.defineProperty(exports, "unescapeUnicode", {
|
|
154
172
|
enumerable: true,
|
|
155
173
|
get: function get() {
|
package/lib/utils.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.dayi18n = void 0;
|
|
6
7
|
exports.formatDate = formatDate;
|
|
7
8
|
exports.getDatePatternWithoutYear = getDatePatternWithoutYear;
|
|
8
9
|
exports.getDiffObj = getDiffObj;
|
|
@@ -17,18 +18,73 @@ exports.isTomorrow = isTomorrow;
|
|
|
17
18
|
exports.isTwoWeeksOrMore = isTwoWeeksOrMore;
|
|
18
19
|
exports.isWithinAWeek = isWithinAWeek;
|
|
19
20
|
exports.isYesterday = isYesterday;
|
|
21
|
+
exports.monthi18n = void 0;
|
|
20
22
|
exports.pad = pad;
|
|
21
23
|
exports.replaceI18NValuesWithRegex = replaceI18NValuesWithRegex;
|
|
22
24
|
exports.setLocalizedData = setLocalizedData;
|
|
25
|
+
exports.timei18n = void 0;
|
|
23
26
|
exports.unescapeUnicode = unescapeUnicode;
|
|
24
27
|
exports.userDateFormat = userDateFormat;
|
|
25
28
|
|
|
26
29
|
var _datetimejs = _interopRequireDefault(require("@zohodesk/datetimejs"));
|
|
27
30
|
|
|
31
|
+
var _I18NProvider = require("./components/I18NProvider");
|
|
32
|
+
|
|
33
|
+
var _monthi18n;
|
|
34
|
+
|
|
28
35
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
29
36
|
|
|
30
37
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
31
38
|
|
|
39
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
40
|
+
|
|
41
|
+
var dayi18n = {
|
|
42
|
+
'Sun': 'deskreact.calendar.daynameshort.sunday',
|
|
43
|
+
'Mon': 'deskreact.calendar.daynameshort.monday',
|
|
44
|
+
'Tue': 'deskreact.calendar.daynameshort.tuesday',
|
|
45
|
+
'Wed': 'deskreact.calendar.daynameshort.wednesday',
|
|
46
|
+
'Thu': 'deskreact.calendar.daynameshort.thursday',
|
|
47
|
+
'Fri': 'deskreact.calendar.daynameshort.friday',
|
|
48
|
+
'Sat': 'deskreact.calendar.daynameshort.saturday',
|
|
49
|
+
'Sunday': 'deskreact.calendar.dayname.sunday',
|
|
50
|
+
'Monday': 'deskreact.calendar.dayname.monday',
|
|
51
|
+
'Tuesday': 'deskreact.calendar.dayname.tuesday',
|
|
52
|
+
'Wednesday': 'deskreact.calendar.dayname.wednesday',
|
|
53
|
+
'Thursday': 'deskreact.calendar.dayname.thursday',
|
|
54
|
+
'Friday': 'deskreact.calendar.dayname.friday',
|
|
55
|
+
'Saturday': 'deskreact.calendar.dayname.saturday'
|
|
56
|
+
};
|
|
57
|
+
exports.dayi18n = dayi18n;
|
|
58
|
+
var monthi18n = (_monthi18n = {
|
|
59
|
+
'Jan': 'deskreact.calendar.monthnameshort.january',
|
|
60
|
+
'Feb': 'deskreact.calendar.monthnameshort.february',
|
|
61
|
+
'Mar': 'deskreact.calendar.monthnameshort.march',
|
|
62
|
+
'Apr': 'deskreact.calendar.monthnameshort.april',
|
|
63
|
+
'May': 'deskreact.calendar.monthnameshort.may',
|
|
64
|
+
'Jun': 'deskreact.calendar.monthnameshort.june',
|
|
65
|
+
'Jul': 'deskreact.calendar.monthnameshort.july',
|
|
66
|
+
'Aug': 'deskreact.calendar.monthnameshort.august',
|
|
67
|
+
'Sep': 'deskreact.calendar.monthnameshort.september',
|
|
68
|
+
'Oct': 'deskreact.calendar.monthnameshort.october',
|
|
69
|
+
'Nov': 'deskreact.calendar.monthnameshort.november',
|
|
70
|
+
'Dec': 'deskreact.calendar.monthnameshort.december',
|
|
71
|
+
'January': 'deskreact.calendar.monthname.january',
|
|
72
|
+
'February': 'deskreact.calendar.monthname.february',
|
|
73
|
+
'March': 'deskreact.calendar.monthname.march',
|
|
74
|
+
'April': 'deskreact.calendar.monthname.april'
|
|
75
|
+
}, _defineProperty(_monthi18n, "May", 'deskreact.calendar.monthname.may'), _defineProperty(_monthi18n, 'June', 'deskreact.calendar.monthname.june'), _defineProperty(_monthi18n, 'July', 'deskreact.calendar.monthname.July'), _defineProperty(_monthi18n, 'August', 'deskreact.calendar.monthname.august'), _defineProperty(_monthi18n, 'September', 'deskreact.calendar.monthname.september'), _defineProperty(_monthi18n, 'October', 'deskreact.calendar.monthname.october'), _defineProperty(_monthi18n, 'November', 'deskreact.calendar.monthname.november'), _defineProperty(_monthi18n, 'December', 'deskreact.calendar.monthname.december'), _monthi18n);
|
|
76
|
+
exports.monthi18n = monthi18n;
|
|
77
|
+
var timei18n = {
|
|
78
|
+
'a': 'support.time.format.time.am.short.small',
|
|
79
|
+
'p': 'support.time.format.time.pm.short.small',
|
|
80
|
+
'am': 'support.time.format.time.am.small',
|
|
81
|
+
'pm': 'support.time.format.time.pm.small',
|
|
82
|
+
'A': 'support.time.format.time.am.short',
|
|
83
|
+
'P': 'support.time.format.time.pm.short',
|
|
84
|
+
'AM': 'deskreact.calendar.ampmtext.am',
|
|
85
|
+
'PM': 'deskreact.calendar.ampmtext.pm'
|
|
86
|
+
};
|
|
87
|
+
exports.timei18n = timei18n;
|
|
32
88
|
var dateFormat = {
|
|
33
89
|
dayNames: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
|
34
90
|
monthNames: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
|
@@ -86,16 +142,16 @@ function formatDate(dateMill, mask, dateDiffObj) {
|
|
|
86
142
|
var flags = {
|
|
87
143
|
d: d,
|
|
88
144
|
dd: pad(d, 2),
|
|
89
|
-
ddd: dateFormat.dayNames[D],
|
|
90
|
-
dddd: dateFormat.dayNames[D + 7],
|
|
145
|
+
ddd: _I18NProvider.i18NProviderUtils.getI18NValue(dayi18n[dateFormat.dayNames[D]]),
|
|
146
|
+
dddd: _I18NProvider.i18NProviderUtils.getI18NValue(dayi18n[dateFormat.dayNames[D + 7]]),
|
|
91
147
|
D: d,
|
|
92
148
|
DD: pad(d, 2),
|
|
93
|
-
DDD: dateFormat.dayNames[D],
|
|
94
|
-
DDDD: dateFormat.dayNames[D + 7],
|
|
149
|
+
DDD: _I18NProvider.i18NProviderUtils.getI18NValue(dayi18n[dateFormat.dayNames[D]]),
|
|
150
|
+
DDDD: _I18NProvider.i18NProviderUtils.getI18NValue(dayi18n[dateFormat.dayNames[D + 7]]),
|
|
95
151
|
M: m + 1,
|
|
96
152
|
MM: pad(m + 1, 2),
|
|
97
|
-
MMM: dateFormat.monthNames[m],
|
|
98
|
-
MMMM: dateFormat.monthNames[m + 12],
|
|
153
|
+
MMM: _I18NProvider.i18NProviderUtils.getI18NValue(monthi18n[dateFormat.monthNames[m]]),
|
|
154
|
+
MMMM: _I18NProvider.i18NProviderUtils.getI18NValue(monthi18n[dateFormat.monthNames[m + 12]]),
|
|
99
155
|
yy: String(y).slice(2),
|
|
100
156
|
YY: String(y).slice(2),
|
|
101
157
|
yyyy: y,
|
|
@@ -110,9 +166,9 @@ function formatDate(dateMill, mask, dateDiffObj) {
|
|
|
110
166
|
ss: pad(s, 2),
|
|
111
167
|
l: pad(L, 3),
|
|
112
168
|
L: pad(Math.round(L / 10)),
|
|
113
|
-
t: H < 12 ? dateFormat.timeNames[0] : dateFormat.timeNames[1],
|
|
114
|
-
A: H < 12 ? dateFormat.timeNames[6] : dateFormat.timeNames[7],
|
|
115
|
-
T: H < 12 ? dateFormat.timeNames[4] : dateFormat.timeNames[5]
|
|
169
|
+
t: H < 12 ? _I18NProvider.i18NProviderUtils.getI18NValue(timei18n[dateFormat.timeNames[0]]) : _I18NProvider.i18NProviderUtils.getI18NValue(timei18n[dateFormat.timeNames[1]]),
|
|
170
|
+
A: H < 12 ? _I18NProvider.i18NProviderUtils.getI18NValue(timei18n[dateFormat.timeNames[6]]) : _I18NProvider.i18NProviderUtils.getI18NValue(timei18n[dateFormat.timeNames[7]]),
|
|
171
|
+
T: H < 12 ? _I18NProvider.i18NProviderUtils.getI18NValue(timei18n[dateFormat.timeNames[4]]) : _I18NProvider.i18NProviderUtils.getI18NValue(timei18n[dateFormat.timeNames[5]])
|
|
116
172
|
};
|
|
117
173
|
var token = /D{1,4}|M{1,4}|YY(?:YY)?|([HhmsA])\1?|[LloSZWN]|\[[^\]]*\]|'[^']*'/gi;
|
|
118
174
|
var dat = mask.replace(token, function (match) {
|
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@zohodesk/i18n",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
4
|
-
"main": "lib/index",
|
|
5
|
-
"module": "es/index.js",
|
|
6
|
-
"jsnext:main": "es/index.js",
|
|
7
|
-
"private": false,
|
|
8
|
-
"umdVar": "i18n",
|
|
9
|
-
"author": "",
|
|
10
|
-
"license": "ISC",
|
|
11
|
-
"scripts": {
|
|
12
|
-
"clean": "react-cli clean lib es coverage",
|
|
13
|
-
"build": "react-cli build:component:cmjs",
|
|
14
|
-
"build:es": "react-cli build:library:es",
|
|
15
|
-
"build:dev": "npm run clean && npm run build --module:mode=dev -- -w",
|
|
16
|
-
"prepublish": "npm run init && npm run build && npm run build:es ",
|
|
17
|
-
"prepare": "npm run init && npm run build && npm run build:es",
|
|
18
|
-
"init": "npm run clean",
|
|
19
|
-
"lint": "react-cli lint"
|
|
20
|
-
},
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"@zoho/SecurityJS": "5.2.0"
|
|
23
|
-
},
|
|
24
|
-
"react-cli": {
|
|
25
|
-
"docs": {
|
|
26
|
-
"componentFolder": "./src"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@zohodesk/i18n",
|
|
3
|
+
"version": "1.0.0-beta.24",
|
|
4
|
+
"main": "lib/index",
|
|
5
|
+
"module": "es/index.js",
|
|
6
|
+
"jsnext:main": "es/index.js",
|
|
7
|
+
"private": false,
|
|
8
|
+
"umdVar": "i18n",
|
|
9
|
+
"author": "",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"clean": "react-cli clean lib es coverage",
|
|
13
|
+
"build": "react-cli build:component:cmjs",
|
|
14
|
+
"build:es": "react-cli build:library:es",
|
|
15
|
+
"build:dev": "npm run clean && npm run build --module:mode=dev -- -w",
|
|
16
|
+
"prepublish": "npm run init && npm run build && npm run build:es ",
|
|
17
|
+
"prepare": "npm run init && npm run build && npm run build:es",
|
|
18
|
+
"init": "npm run clean",
|
|
19
|
+
"lint": "react-cli lint"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@zoho/SecurityJS": "5.2.0"
|
|
23
|
+
},
|
|
24
|
+
"react-cli": {
|
|
25
|
+
"docs": {
|
|
26
|
+
"componentFolder": "./src"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/I18NContext.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
3
|
export const I18NContext = React.createContext();
|