@zohodesk/i18n 1.0.0-beta.4 → 1.0.0-beta.40-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 +109 -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 +95 -104
  45. package/lib/utils/__tests__/jsxTranslations.spec.js +172 -0
  46. package/lib/utils/errorReporter.js +137 -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 +14 -9
  55. package/src/utils/__tests__/jsxTranslations.spec.js +213 -0
  56. package/src/utils/errorReporter.js +129 -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
package/lib/timezones.js DELETED
@@ -1,129 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getTimezoneOffset = exports.unpack = undefined;
7
-
8
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
9
-
10
- var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
11
-
12
- var _offset = require('./offset');
13
-
14
- function charCodeToInt(charCode) {
15
- if (charCode > 96) {
16
- return charCode - 87;
17
- } else if (charCode > 64) {
18
- return charCode - 29;
19
- }
20
- return charCode - 48;
21
- }
22
-
23
- function unpackBase60(string) {
24
- var i = 0,
25
- parts = string.split('.'),
26
- _parts = _slicedToArray(parts, 1),
27
- whole = _parts[0],
28
- fractional = parts[1] || '',
29
- multiplier = 1,
30
- num = void 0,
31
- out = 0,
32
- sign = 1;
33
-
34
- // handle negative numbers
35
- if (string.charCodeAt(0) === 45) {
36
- i = 1;
37
- sign = -1;
38
- }
39
-
40
- // handle digits before the decimal
41
- for (i; i < whole.length; i++) {
42
- num = charCodeToInt(whole.charCodeAt(i));
43
- out = 60 * out + num;
44
- }
45
-
46
- // handle digits after the decimal
47
- for (i = 0; i < fractional.length; i++) {
48
- multiplier = multiplier / 60;
49
- num = charCodeToInt(fractional.charCodeAt(i));
50
- out += num * multiplier;
51
- }
52
-
53
- return out * sign;
54
- }
55
-
56
- function arrayToInt(array) {
57
- for (var i = 0; i < array.length; i++) {
58
- array[i] = unpackBase60(array[i]);
59
- }
60
- }
61
-
62
- function intToUntil(array, length) {
63
- for (var i = 0; i < length; i++) {
64
- array[i] = Math.round((array[i - 1] || 0) + array[i] * 60000); // minutes to milliseconds
65
- }
66
-
67
- array[length - 1] = Infinity;
68
- }
69
-
70
- function mapIndices(source, indices) {
71
- var out = [],
72
- i = void 0;
73
-
74
- for (i = 0; i < indices.length; i++) {
75
- out[i] = source[indices[i]];
76
- }
77
-
78
- return out;
79
- }
80
-
81
- function unpack(string) {
82
- if (string) {
83
- var data = string.split('|'),
84
- offsets = data[0].split(' '),
85
- indices = data[1].split(''),
86
- untils = data[2].split(' ');
87
-
88
- arrayToInt(offsets);
89
- arrayToInt(indices);
90
- arrayToInt(untils);
91
-
92
- intToUntil(untils, indices.length);
93
-
94
- return {
95
- offsets: mapIndices(offsets, indices),
96
- untils: untils
97
- };
98
- }
99
- }
100
-
101
- var utcOffset = function utcOffset(timestamp, tzData) {
102
- var target = +timestamp,
103
- i = void 0;
104
- var untils = tzData.untils,
105
- offsets = tzData.offsets;
106
-
107
-
108
- for (i = 0; i < untils.length; i++) {
109
- var diff = target + offsets[i] * 60000; //minutes to milliseconds
110
- if (diff < untils[i]) {
111
- return offsets[i];
112
- }
113
- }
114
- };
115
-
116
- var getTimezoneOffset = function getTimezoneOffset(timestamp, tzData) {
117
- if ((typeof tzData === 'undefined' ? 'undefined' : _typeof(tzData)) === 'object') {
118
- var offset = utcOffset(timestamp, tzData);
119
- if (Math.abs(offset) < 16) {
120
- offset = offset / 60;
121
- }
122
- return -offset;
123
- } else {
124
- return _offset.offsetMap[tzData] || -new Date().getTimezoneOffset();
125
- }
126
- };
127
-
128
- exports.unpack = unpack;
129
- exports.getTimezoneOffset = getTimezoneOffset;