@zohodesk/i18n 1.0.0-beta.15.1 → 1.0.0-beta.18
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 +73 -41
- package/es/components/DateTimeDiffFormat.js +46 -12
- package/es/components/HOCI18N.js +33 -30
- package/es/components/I18NProvider.js +7 -16
- package/es/components/UserTimeDiffFormat.js +11 -9
- package/es/components/__tests__/DateTimeDiffFormat.spec.js +177 -136
- package/es/components/__tests__/FormatText.spec.js +0 -1
- package/es/components/__tests__/HOCI18N.spec.js +0 -1
- package/es/components/__tests__/I18N.spec.js +0 -2
- package/es/components/__tests__/I18NProvider.spec.js +0 -1
- package/es/components/__tests__/PluralFormat.spec.js +0 -1
- package/es/components/__tests__/UserTimeDiffFormat.spec.js +287 -206
- 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 +2 -3
- package/es/utils.js +119 -171
- package/lib/components/DateTimeDiffFormat.js +49 -15
- package/lib/components/FormatText.js +4 -4
- package/lib/components/HOCI18N.js +4 -4
- package/lib/components/I18N.js +4 -4
- package/lib/components/I18NProvider.js +12 -21
- package/lib/components/PluralFormat.js +4 -4
- package/lib/components/UserTimeDiffFormat.js +12 -14
- package/lib/components/__tests__/I18NProvider.spec.js +1 -1
- package/lib/components/__tests__/UserTimeDiffFormat.spec.js +1 -1
- 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 +54 -56
- package/lib/utils.js +130 -212
- package/package.json +28 -28
- package/src/I18NContext.js +2 -2
- package/src/components/DateTimeDiffFormat.js +254 -211
- package/src/components/FormatText.js +14 -14
- package/src/components/HOCI18N.js +37 -37
- package/src/components/I18N.js +72 -72
- package/src/components/I18NProvider.js +106 -116
- package/src/components/PluralFormat.js +37 -37
- package/src/components/UserTimeDiffFormat.js +94 -103
- 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 +33 -33
- package/src/utils.js +527 -587
- package/es/components/NewDateFormat.js +0 -53
- package/lib/components/NewDateFormat.js +0 -60
- package/src/components/NewDateFormat.js +0 -60
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "core-js/modules/web.url.to-json";
|
|
2
1
|
import DateTimeDiffFormat from '../DateTimeDiffFormat';
|
|
3
2
|
import I18NProvider from '../I18NProvider';
|
|
4
3
|
import React from 'react';
|
|
@@ -33,12 +32,14 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
33
32
|
key: 'tomorrow',
|
|
34
33
|
params: ['hh', 'mm', 'ss']
|
|
35
34
|
},
|
|
36
|
-
others:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
others: _ref => {
|
|
36
|
+
let {
|
|
37
|
+
years,
|
|
38
|
+
days,
|
|
39
|
+
hours,
|
|
40
|
+
minutes
|
|
41
|
+
} = _ref;
|
|
42
|
+
|
|
42
43
|
if (days > 7) {
|
|
43
44
|
return 'DD-MM-YYYY';
|
|
44
45
|
}
|
|
@@ -74,12 +75,14 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
74
75
|
key: 'tomorrow',
|
|
75
76
|
params: ['hh', 'mm', 'ss']
|
|
76
77
|
},
|
|
77
|
-
others:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
others: _ref2 => {
|
|
79
|
+
let {
|
|
80
|
+
years,
|
|
81
|
+
days,
|
|
82
|
+
hours,
|
|
83
|
+
minutes
|
|
84
|
+
} = _ref2;
|
|
85
|
+
|
|
83
86
|
if (days > 7) {
|
|
84
87
|
return 'DD-MM-YYYY';
|
|
85
88
|
}
|
|
@@ -115,12 +118,14 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
115
118
|
key: 'tomorrow',
|
|
116
119
|
params: ['hh', 'mm', 'ss']
|
|
117
120
|
},
|
|
118
|
-
others:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
others: _ref3 => {
|
|
122
|
+
let {
|
|
123
|
+
years,
|
|
124
|
+
days,
|
|
125
|
+
hours,
|
|
126
|
+
minutes
|
|
127
|
+
} = _ref3;
|
|
128
|
+
|
|
124
129
|
if (days > 7) {
|
|
125
130
|
return 'DD-MM-YYYY';
|
|
126
131
|
}
|
|
@@ -156,12 +161,14 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
156
161
|
key: 'tomorrow',
|
|
157
162
|
params: ['hh', 'mm', 'ss']
|
|
158
163
|
},
|
|
159
|
-
others:
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
others: _ref4 => {
|
|
165
|
+
let {
|
|
166
|
+
years,
|
|
167
|
+
days,
|
|
168
|
+
hours,
|
|
169
|
+
minutes
|
|
170
|
+
} = _ref4;
|
|
171
|
+
|
|
165
172
|
if (days > 7) {
|
|
166
173
|
return 'DD-MM-YYYY';
|
|
167
174
|
}
|
|
@@ -197,12 +204,14 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
197
204
|
key: 'tomorrow',
|
|
198
205
|
params: ['hh', 'mm', 'ss']
|
|
199
206
|
},
|
|
200
|
-
others:
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
207
|
+
others: _ref5 => {
|
|
208
|
+
let {
|
|
209
|
+
years,
|
|
210
|
+
days,
|
|
211
|
+
hours,
|
|
212
|
+
minutes
|
|
213
|
+
} = _ref5;
|
|
214
|
+
|
|
206
215
|
if (days > 7) {
|
|
207
216
|
return 'DD-MM-YYYY';
|
|
208
217
|
}
|
|
@@ -238,12 +247,14 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
238
247
|
key: 'tomorrow',
|
|
239
248
|
params: ['hh', 'mm', 'ss']
|
|
240
249
|
},
|
|
241
|
-
others:
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
250
|
+
others: _ref6 => {
|
|
251
|
+
let {
|
|
252
|
+
years,
|
|
253
|
+
days,
|
|
254
|
+
hours,
|
|
255
|
+
minutes
|
|
256
|
+
} = _ref6;
|
|
257
|
+
|
|
247
258
|
if (days > 7) {
|
|
248
259
|
return 'DD-MM-YYYY';
|
|
249
260
|
}
|
|
@@ -279,12 +290,14 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
279
290
|
key: 'tomorrow',
|
|
280
291
|
params: ['hh', 'mm', 'ss']
|
|
281
292
|
},
|
|
282
|
-
others:
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
293
|
+
others: _ref7 => {
|
|
294
|
+
let {
|
|
295
|
+
years,
|
|
296
|
+
days,
|
|
297
|
+
hours,
|
|
298
|
+
minutes
|
|
299
|
+
} = _ref7;
|
|
300
|
+
|
|
288
301
|
if (days > 7) {
|
|
289
302
|
return 'DD-MM-YYYY';
|
|
290
303
|
}
|
|
@@ -320,12 +333,14 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
320
333
|
key: 'tomorrow',
|
|
321
334
|
params: ['hh', 'mm', 'ss']
|
|
322
335
|
},
|
|
323
|
-
others:
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
336
|
+
others: _ref8 => {
|
|
337
|
+
let {
|
|
338
|
+
years,
|
|
339
|
+
days,
|
|
340
|
+
hours,
|
|
341
|
+
minutes
|
|
342
|
+
} = _ref8;
|
|
343
|
+
|
|
329
344
|
if (days > 7) {
|
|
330
345
|
return 'DD-MM-YYYY';
|
|
331
346
|
}
|
|
@@ -361,12 +376,14 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
361
376
|
key: 'tomorrow',
|
|
362
377
|
params: ['hh', 'mm', 'ss']
|
|
363
378
|
},
|
|
364
|
-
others:
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
379
|
+
others: _ref9 => {
|
|
380
|
+
let {
|
|
381
|
+
years,
|
|
382
|
+
days,
|
|
383
|
+
hours,
|
|
384
|
+
minutes
|
|
385
|
+
} = _ref9;
|
|
386
|
+
|
|
370
387
|
if (days > 7) {
|
|
371
388
|
return 'DD-MM-YYYY';
|
|
372
389
|
}
|
|
@@ -402,13 +419,15 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
402
419
|
key: 'tomorrow',
|
|
403
420
|
params: ['hh', 'mm', 'ss']
|
|
404
421
|
},
|
|
405
|
-
others:
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
422
|
+
others: _ref10 => {
|
|
423
|
+
let {
|
|
424
|
+
years,
|
|
425
|
+
days,
|
|
426
|
+
hours,
|
|
427
|
+
minutes,
|
|
428
|
+
suffix
|
|
429
|
+
} = _ref10;
|
|
430
|
+
|
|
412
431
|
if (days > 7) {
|
|
413
432
|
return 'DD-MM-YYYY';
|
|
414
433
|
}
|
|
@@ -444,13 +463,15 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
444
463
|
key: 'tomorrow',
|
|
445
464
|
params: ['hh', 'mm', 'ss']
|
|
446
465
|
},
|
|
447
|
-
others:
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
466
|
+
others: _ref11 => {
|
|
467
|
+
let {
|
|
468
|
+
years,
|
|
469
|
+
days,
|
|
470
|
+
hours,
|
|
471
|
+
minutes,
|
|
472
|
+
suffix
|
|
473
|
+
} = _ref11;
|
|
474
|
+
|
|
454
475
|
if (days > 7) {
|
|
455
476
|
return 'DD-MM-YYYY';
|
|
456
477
|
}
|
|
@@ -486,13 +507,15 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
486
507
|
key: 'tomorrow',
|
|
487
508
|
params: ['hh', 'mm', 'ss']
|
|
488
509
|
},
|
|
489
|
-
others:
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
510
|
+
others: _ref12 => {
|
|
511
|
+
let {
|
|
512
|
+
years,
|
|
513
|
+
days,
|
|
514
|
+
hours,
|
|
515
|
+
minutes,
|
|
516
|
+
suffix
|
|
517
|
+
} = _ref12;
|
|
518
|
+
|
|
496
519
|
if (days > 7) {
|
|
497
520
|
return 'DD-MM-YYYY';
|
|
498
521
|
}
|
|
@@ -528,14 +551,16 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
528
551
|
key: 'tomorrow',
|
|
529
552
|
params: ['hh', 'mm', 'ss']
|
|
530
553
|
},
|
|
531
|
-
others:
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
554
|
+
others: _ref13 => {
|
|
555
|
+
let {
|
|
556
|
+
years,
|
|
557
|
+
days,
|
|
558
|
+
hours,
|
|
559
|
+
minutes,
|
|
560
|
+
suffix,
|
|
561
|
+
isWithInAWeek
|
|
562
|
+
} = _ref13;
|
|
563
|
+
|
|
539
564
|
if (days > 7) {
|
|
540
565
|
return 'DD-MM-YYYY';
|
|
541
566
|
}
|
|
@@ -571,13 +596,15 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
571
596
|
key: 'tomorrow',
|
|
572
597
|
params: ['hh', 'mm', 'ss']
|
|
573
598
|
},
|
|
574
|
-
others:
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
599
|
+
others: _ref14 => {
|
|
600
|
+
let {
|
|
601
|
+
years,
|
|
602
|
+
days,
|
|
603
|
+
hours,
|
|
604
|
+
minutes,
|
|
605
|
+
suffix
|
|
606
|
+
} = _ref14;
|
|
607
|
+
|
|
581
608
|
if (days > 7) {
|
|
582
609
|
return 'DD-MM-YYYY';
|
|
583
610
|
}
|
|
@@ -613,13 +640,15 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
613
640
|
key: 'tomorrow',
|
|
614
641
|
params: ['hh', 'mm', 'ss']
|
|
615
642
|
},
|
|
616
|
-
others:
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
643
|
+
others: _ref15 => {
|
|
644
|
+
let {
|
|
645
|
+
years,
|
|
646
|
+
days,
|
|
647
|
+
hours,
|
|
648
|
+
minutes,
|
|
649
|
+
suffix
|
|
650
|
+
} = _ref15;
|
|
651
|
+
|
|
623
652
|
if (days > 7) {
|
|
624
653
|
return 'DD-MM-YYYY';
|
|
625
654
|
}
|
|
@@ -655,14 +684,16 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
655
684
|
key: 'tomorrow',
|
|
656
685
|
params: ['hh', 'mm', 'ss']
|
|
657
686
|
},
|
|
658
|
-
others:
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
687
|
+
others: _ref16 => {
|
|
688
|
+
let {
|
|
689
|
+
years,
|
|
690
|
+
days,
|
|
691
|
+
hours,
|
|
692
|
+
minutes,
|
|
693
|
+
suffix,
|
|
694
|
+
isWithInAWeek
|
|
695
|
+
} = _ref16;
|
|
696
|
+
|
|
666
697
|
if (days > 7) {
|
|
667
698
|
return 'DD-MM-YYYY';
|
|
668
699
|
}
|
|
@@ -693,12 +724,14 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
693
724
|
fromTzData: fromTzData,
|
|
694
725
|
to: to,
|
|
695
726
|
toTzData: toTzData,
|
|
696
|
-
format: ({
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
727
|
+
format: (_ref17, pattern) => {
|
|
728
|
+
let {
|
|
729
|
+
years,
|
|
730
|
+
days,
|
|
731
|
+
months,
|
|
732
|
+
hours
|
|
733
|
+
} = _ref17;
|
|
734
|
+
|
|
702
735
|
switch (pattern) {
|
|
703
736
|
case '000000':
|
|
704
737
|
case '000001':
|
|
@@ -767,12 +800,14 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
767
800
|
key: 'tomorrow',
|
|
768
801
|
params: ['hh', 'mm', 'ss']
|
|
769
802
|
},
|
|
770
|
-
others:
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
803
|
+
others: _ref18 => {
|
|
804
|
+
let {
|
|
805
|
+
years,
|
|
806
|
+
days,
|
|
807
|
+
hours,
|
|
808
|
+
minutes
|
|
809
|
+
} = _ref18;
|
|
810
|
+
|
|
776
811
|
if (days > 7) {
|
|
777
812
|
return 'DD-MM-YYYY';
|
|
778
813
|
}
|
|
@@ -810,12 +845,14 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
810
845
|
key: 'tomorrow',
|
|
811
846
|
params: ['hh', 'mm', 'ss']
|
|
812
847
|
},
|
|
813
|
-
others:
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
848
|
+
others: _ref19 => {
|
|
849
|
+
let {
|
|
850
|
+
years,
|
|
851
|
+
days,
|
|
852
|
+
hours,
|
|
853
|
+
minutes
|
|
854
|
+
} = _ref19;
|
|
855
|
+
|
|
819
856
|
if (days > 7) {
|
|
820
857
|
return 'DD-MM-YYYY';
|
|
821
858
|
}
|
|
@@ -839,12 +876,14 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
839
876
|
fromTzData: fromTzData,
|
|
840
877
|
to: "2015-08-25T05:55:28.000Z",
|
|
841
878
|
toTzData: toTzData,
|
|
842
|
-
format: ({
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
879
|
+
format: (_ref20, pattern) => {
|
|
880
|
+
let {
|
|
881
|
+
years,
|
|
882
|
+
days,
|
|
883
|
+
months,
|
|
884
|
+
hours
|
|
885
|
+
} = _ref20;
|
|
886
|
+
|
|
848
887
|
if (years > 1) {
|
|
849
888
|
return {
|
|
850
889
|
key: 'nyear.ndays',
|
|
@@ -869,12 +908,14 @@ describe('DateTimeDiffFormat component', () => {
|
|
|
869
908
|
fromTzData: fromTzData,
|
|
870
909
|
to: "2017-10-25T05:55:28.000Z",
|
|
871
910
|
toTzData: toTzData,
|
|
872
|
-
format: ({
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
911
|
+
format: (_ref21, pattern) => {
|
|
912
|
+
let {
|
|
913
|
+
years,
|
|
914
|
+
days,
|
|
915
|
+
months,
|
|
916
|
+
hours
|
|
917
|
+
} = _ref21;
|
|
918
|
+
|
|
878
919
|
if (years > 1) {
|
|
879
920
|
return {
|
|
880
921
|
key: 'nyear.ndays',
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import "core-js/modules/web.url.to-json";
|
|
2
|
-
|
|
3
1
|
function _extends() { _extends = Object.assign || 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); }
|
|
4
2
|
|
|
5
3
|
import I18N from '../I18N';
|