@itwin/core-i18n 5.14.0-dev.7 → 5.14.0-dev.9
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/lib/cjs/ITwinLocalization.d.ts.map +1 -1
- package/lib/cjs/ITwinLocalization.js +3 -17
- package/lib/cjs/ITwinLocalization.js.map +1 -1
- package/lib/cjs/test/ITwinLocalization.test.js +60 -0
- package/lib/cjs/test/ITwinLocalization.test.js.map +1 -1
- package/lib/cjs/test/webpack/bundled-tests.instrumented.js +211 -302
- package/lib/cjs/test/webpack/bundled-tests.instrumented.js.map +1 -1
- package/lib/cjs/test/webpack/bundled-tests.js +63 -17
- package/lib/cjs/test/webpack/bundled-tests.js.map +1 -1
- package/lib/esm/ITwinLocalization.d.ts.map +1 -1
- package/lib/esm/ITwinLocalization.js +3 -17
- package/lib/esm/ITwinLocalization.js.map +1 -1
- package/lib/esm/test/ITwinLocalization.test.js +60 -0
- package/lib/esm/test/ITwinLocalization.test.js.map +1 -1
- package/package.json +6 -6
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
function cov_1wctd2lw3r() {
|
|
21
21
|
var path = "C:\\agent\\_work\\2\\s\\core\\i18n\\lib\\cjs\\ITwinLocalization.js";
|
|
22
|
-
var hash = "
|
|
22
|
+
var hash = "11843a9389894bd74427d7137f54e50ca9e52905";
|
|
23
23
|
var global = new Function("return this")();
|
|
24
24
|
var gcv = "__coverage__";
|
|
25
25
|
var coverageData = {
|
|
@@ -521,7 +521,7 @@ function cov_1wctd2lw3r() {
|
|
|
521
521
|
column: 31
|
|
522
522
|
},
|
|
523
523
|
end: {
|
|
524
|
-
line:
|
|
524
|
+
line: 176,
|
|
525
525
|
column: 10
|
|
526
526
|
}
|
|
527
527
|
},
|
|
@@ -531,7 +531,7 @@ function cov_1wctd2lw3r() {
|
|
|
531
531
|
column: 12
|
|
532
532
|
},
|
|
533
533
|
end: {
|
|
534
|
-
line:
|
|
534
|
+
line: 175,
|
|
535
535
|
column: 15
|
|
536
536
|
}
|
|
537
537
|
},
|
|
@@ -557,251 +557,191 @@ function cov_1wctd2lw3r() {
|
|
|
557
557
|
},
|
|
558
558
|
"53": {
|
|
559
559
|
start: {
|
|
560
|
-
line:
|
|
561
|
-
column:
|
|
560
|
+
line: 171,
|
|
561
|
+
column: 34
|
|
562
562
|
},
|
|
563
563
|
end: {
|
|
564
|
-
line:
|
|
565
|
-
column:
|
|
564
|
+
line: 171,
|
|
565
|
+
column: 123
|
|
566
566
|
}
|
|
567
567
|
},
|
|
568
568
|
"54": {
|
|
569
569
|
start: {
|
|
570
|
-
line:
|
|
571
|
-
column:
|
|
570
|
+
line: 171,
|
|
571
|
+
column: 76
|
|
572
572
|
},
|
|
573
573
|
end: {
|
|
574
|
-
line:
|
|
575
|
-
column:
|
|
574
|
+
line: 171,
|
|
575
|
+
column: 122
|
|
576
576
|
}
|
|
577
577
|
},
|
|
578
578
|
"55": {
|
|
579
579
|
start: {
|
|
580
|
-
line:
|
|
581
|
-
column: 16
|
|
582
|
-
},
|
|
583
|
-
end: {
|
|
584
|
-
line: 184,
|
|
585
|
-
column: 17
|
|
586
|
-
}
|
|
587
|
-
},
|
|
588
|
-
"56": {
|
|
589
|
-
start: {
|
|
590
|
-
line: 177,
|
|
591
|
-
column: 20
|
|
592
|
-
},
|
|
593
|
-
end: {
|
|
594
|
-
line: 180,
|
|
595
|
-
column: 21
|
|
596
|
-
}
|
|
597
|
-
},
|
|
598
|
-
"57": {
|
|
599
|
-
start: {
|
|
600
|
-
line: 178,
|
|
601
|
-
column: 24
|
|
602
|
-
},
|
|
603
|
-
end: {
|
|
604
|
-
line: 179,
|
|
605
|
-
column: 102
|
|
606
|
-
}
|
|
607
|
-
},
|
|
608
|
-
"58": {
|
|
609
|
-
start: {
|
|
610
|
-
line: 179,
|
|
611
|
-
column: 28
|
|
612
|
-
},
|
|
613
|
-
end: {
|
|
614
|
-
line: 179,
|
|
615
|
-
column: 102
|
|
616
|
-
}
|
|
617
|
-
},
|
|
618
|
-
"59": {
|
|
619
|
-
start: {
|
|
620
|
-
line: 179,
|
|
621
|
-
column: 69
|
|
622
|
-
},
|
|
623
|
-
end: {
|
|
624
|
-
line: 179,
|
|
625
|
-
column: 100
|
|
626
|
-
}
|
|
627
|
-
},
|
|
628
|
-
"60": {
|
|
629
|
-
start: {
|
|
630
|
-
line: 183,
|
|
631
|
-
column: 20
|
|
632
|
-
},
|
|
633
|
-
end: {
|
|
634
|
-
line: 183,
|
|
635
|
-
column: 33
|
|
636
|
-
}
|
|
637
|
-
},
|
|
638
|
-
"61": {
|
|
639
|
-
start: {
|
|
640
|
-
line: 186,
|
|
580
|
+
line: 172,
|
|
641
581
|
column: 16
|
|
642
582
|
},
|
|
643
583
|
end: {
|
|
644
|
-
line:
|
|
584
|
+
line: 173,
|
|
645
585
|
column: 113
|
|
646
586
|
}
|
|
647
587
|
},
|
|
648
|
-
"
|
|
588
|
+
"56": {
|
|
649
589
|
start: {
|
|
650
|
-
line:
|
|
590
|
+
line: 173,
|
|
651
591
|
column: 20
|
|
652
592
|
},
|
|
653
593
|
end: {
|
|
654
|
-
line:
|
|
594
|
+
line: 173,
|
|
655
595
|
column: 113
|
|
656
596
|
}
|
|
657
597
|
},
|
|
658
|
-
"
|
|
598
|
+
"57": {
|
|
659
599
|
start: {
|
|
660
|
-
line:
|
|
600
|
+
line: 174,
|
|
661
601
|
column: 16
|
|
662
602
|
},
|
|
663
603
|
end: {
|
|
664
|
-
line:
|
|
604
|
+
line: 174,
|
|
665
605
|
column: 26
|
|
666
606
|
}
|
|
667
607
|
},
|
|
668
|
-
"
|
|
608
|
+
"58": {
|
|
669
609
|
start: {
|
|
670
|
-
line:
|
|
610
|
+
line: 177,
|
|
671
611
|
column: 8
|
|
672
612
|
},
|
|
673
613
|
end: {
|
|
674
|
-
line:
|
|
614
|
+
line: 177,
|
|
675
615
|
column: 51
|
|
676
616
|
}
|
|
677
617
|
},
|
|
678
|
-
"
|
|
618
|
+
"59": {
|
|
679
619
|
start: {
|
|
680
|
-
line:
|
|
620
|
+
line: 178,
|
|
681
621
|
column: 8
|
|
682
622
|
},
|
|
683
623
|
end: {
|
|
684
|
-
line:
|
|
624
|
+
line: 178,
|
|
685
625
|
column: 30
|
|
686
626
|
}
|
|
687
627
|
},
|
|
688
|
-
"
|
|
628
|
+
"60": {
|
|
689
629
|
start: {
|
|
690
|
-
line:
|
|
630
|
+
line: 182,
|
|
691
631
|
column: 8
|
|
692
632
|
},
|
|
693
633
|
end: {
|
|
694
|
-
line:
|
|
634
|
+
line: 182,
|
|
695
635
|
column: 38
|
|
696
636
|
}
|
|
697
637
|
},
|
|
698
|
-
"
|
|
638
|
+
"61": {
|
|
699
639
|
start: {
|
|
700
|
-
line:
|
|
640
|
+
line: 185,
|
|
701
641
|
column: 0
|
|
702
642
|
},
|
|
703
643
|
end: {
|
|
704
|
-
line:
|
|
644
|
+
line: 185,
|
|
705
645
|
column: 46
|
|
706
646
|
}
|
|
707
647
|
},
|
|
708
|
-
"
|
|
648
|
+
"62": {
|
|
709
649
|
start: {
|
|
710
|
-
line:
|
|
650
|
+
line: 187,
|
|
711
651
|
column: 18
|
|
712
652
|
},
|
|
713
653
|
end: {
|
|
714
|
-
line:
|
|
654
|
+
line: 187,
|
|
715
655
|
column: 26
|
|
716
656
|
}
|
|
717
657
|
},
|
|
718
|
-
"
|
|
658
|
+
"63": {
|
|
719
659
|
start: {
|
|
720
|
-
line:
|
|
660
|
+
line: 188,
|
|
721
661
|
column: 16
|
|
722
662
|
},
|
|
723
663
|
end: {
|
|
724
|
-
line:
|
|
664
|
+
line: 188,
|
|
725
665
|
column: 83
|
|
726
666
|
}
|
|
727
667
|
},
|
|
728
|
-
"
|
|
668
|
+
"64": {
|
|
729
669
|
start: {
|
|
730
|
-
line:
|
|
670
|
+
line: 189,
|
|
731
671
|
column: 17
|
|
732
672
|
},
|
|
733
673
|
end: {
|
|
734
|
-
line:
|
|
674
|
+
line: 189,
|
|
735
675
|
column: 87
|
|
736
676
|
}
|
|
737
677
|
},
|
|
738
|
-
"
|
|
678
|
+
"65": {
|
|
739
679
|
start: {
|
|
740
|
-
line:
|
|
680
|
+
line: 190,
|
|
741
681
|
column: 18
|
|
742
682
|
},
|
|
743
683
|
end: {
|
|
744
|
-
line:
|
|
684
|
+
line: 190,
|
|
745
685
|
column: 86
|
|
746
686
|
}
|
|
747
687
|
},
|
|
748
|
-
"
|
|
688
|
+
"66": {
|
|
749
689
|
start: {
|
|
750
|
-
line:
|
|
690
|
+
line: 192,
|
|
751
691
|
column: 22
|
|
752
692
|
},
|
|
753
693
|
end: {
|
|
754
|
-
line:
|
|
694
|
+
line: 192,
|
|
755
695
|
column: 29
|
|
756
696
|
}
|
|
757
697
|
},
|
|
758
|
-
"
|
|
698
|
+
"67": {
|
|
759
699
|
start: {
|
|
760
|
-
line:
|
|
700
|
+
line: 193,
|
|
761
701
|
column: 8
|
|
762
702
|
},
|
|
763
703
|
end: {
|
|
764
|
-
line:
|
|
704
|
+
line: 196,
|
|
765
705
|
column: 9
|
|
766
706
|
}
|
|
767
707
|
},
|
|
768
|
-
"
|
|
708
|
+
"68": {
|
|
769
709
|
start: {
|
|
770
|
-
line:
|
|
710
|
+
line: 193,
|
|
771
711
|
column: 21
|
|
772
712
|
},
|
|
773
713
|
end: {
|
|
774
|
-
line:
|
|
714
|
+
line: 193,
|
|
775
715
|
column: 22
|
|
776
716
|
}
|
|
777
717
|
},
|
|
778
|
-
"
|
|
718
|
+
"69": {
|
|
779
719
|
start: {
|
|
780
|
-
line:
|
|
720
|
+
line: 194,
|
|
781
721
|
column: 12
|
|
782
722
|
},
|
|
783
723
|
end: {
|
|
784
|
-
line:
|
|
724
|
+
line: 195,
|
|
785
725
|
column: 44
|
|
786
726
|
}
|
|
787
727
|
},
|
|
788
|
-
"
|
|
728
|
+
"70": {
|
|
789
729
|
start: {
|
|
790
|
-
line:
|
|
730
|
+
line: 195,
|
|
791
731
|
column: 16
|
|
792
732
|
},
|
|
793
733
|
end: {
|
|
794
|
-
line:
|
|
734
|
+
line: 195,
|
|
795
735
|
column: 44
|
|
796
736
|
}
|
|
797
737
|
},
|
|
798
|
-
"
|
|
738
|
+
"71": {
|
|
799
739
|
start: {
|
|
800
|
-
line:
|
|
740
|
+
line: 197,
|
|
801
741
|
column: 8
|
|
802
742
|
},
|
|
803
743
|
end: {
|
|
804
|
-
line:
|
|
744
|
+
line: 197,
|
|
805
745
|
column: 23
|
|
806
746
|
}
|
|
807
747
|
}
|
|
@@ -1065,7 +1005,7 @@ function cov_1wctd2lw3r() {
|
|
|
1065
1005
|
column: 34
|
|
1066
1006
|
},
|
|
1067
1007
|
end: {
|
|
1068
|
-
line:
|
|
1008
|
+
line: 179,
|
|
1069
1009
|
column: 5
|
|
1070
1010
|
}
|
|
1071
1011
|
},
|
|
@@ -1089,7 +1029,7 @@ function cov_1wctd2lw3r() {
|
|
|
1089
1029
|
column: 56
|
|
1090
1030
|
},
|
|
1091
1031
|
end: {
|
|
1092
|
-
line:
|
|
1032
|
+
line: 176,
|
|
1093
1033
|
column: 9
|
|
1094
1034
|
}
|
|
1095
1035
|
},
|
|
@@ -1113,7 +1053,7 @@ function cov_1wctd2lw3r() {
|
|
|
1113
1053
|
column: 55
|
|
1114
1054
|
},
|
|
1115
1055
|
end: {
|
|
1116
|
-
line:
|
|
1056
|
+
line: 175,
|
|
1117
1057
|
column: 13
|
|
1118
1058
|
}
|
|
1119
1059
|
},
|
|
@@ -1123,169 +1063,145 @@ function cov_1wctd2lw3r() {
|
|
|
1123
1063
|
name: "(anonymous_13)",
|
|
1124
1064
|
decl: {
|
|
1125
1065
|
start: {
|
|
1126
|
-
line:
|
|
1127
|
-
column:
|
|
1066
|
+
line: 171,
|
|
1067
|
+
column: 62
|
|
1128
1068
|
},
|
|
1129
1069
|
end: {
|
|
1130
|
-
line:
|
|
1131
|
-
column:
|
|
1070
|
+
line: 171,
|
|
1071
|
+
column: 63
|
|
1132
1072
|
}
|
|
1133
1073
|
},
|
|
1134
1074
|
loc: {
|
|
1135
1075
|
start: {
|
|
1136
|
-
line:
|
|
1137
|
-
column:
|
|
1076
|
+
line: 171,
|
|
1077
|
+
column: 76
|
|
1138
1078
|
},
|
|
1139
1079
|
end: {
|
|
1140
|
-
line:
|
|
1141
|
-
column:
|
|
1080
|
+
line: 171,
|
|
1081
|
+
column: 122
|
|
1142
1082
|
}
|
|
1143
1083
|
},
|
|
1144
|
-
line:
|
|
1084
|
+
line: 171
|
|
1145
1085
|
},
|
|
1146
1086
|
"14": {
|
|
1147
1087
|
name: "(anonymous_14)",
|
|
1148
1088
|
decl: {
|
|
1149
1089
|
start: {
|
|
1150
|
-
line:
|
|
1151
|
-
column: 53
|
|
1152
|
-
},
|
|
1153
|
-
end: {
|
|
1154
|
-
line: 179,
|
|
1155
|
-
column: 54
|
|
1156
|
-
}
|
|
1157
|
-
},
|
|
1158
|
-
loc: {
|
|
1159
|
-
start: {
|
|
1160
|
-
line: 179,
|
|
1161
|
-
column: 69
|
|
1162
|
-
},
|
|
1163
|
-
end: {
|
|
1164
|
-
line: 179,
|
|
1165
|
-
column: 100
|
|
1166
|
-
}
|
|
1167
|
-
},
|
|
1168
|
-
line: 179
|
|
1169
|
-
},
|
|
1170
|
-
"15": {
|
|
1171
|
-
name: "(anonymous_15)",
|
|
1172
|
-
decl: {
|
|
1173
|
-
start: {
|
|
1174
|
-
line: 195,
|
|
1090
|
+
line: 181,
|
|
1175
1091
|
column: 4
|
|
1176
1092
|
},
|
|
1177
1093
|
end: {
|
|
1178
|
-
line:
|
|
1094
|
+
line: 181,
|
|
1179
1095
|
column: 5
|
|
1180
1096
|
}
|
|
1181
1097
|
},
|
|
1182
1098
|
loc: {
|
|
1183
1099
|
start: {
|
|
1184
|
-
line:
|
|
1100
|
+
line: 181,
|
|
1185
1101
|
column: 30
|
|
1186
1102
|
},
|
|
1187
1103
|
end: {
|
|
1188
|
-
line:
|
|
1104
|
+
line: 183,
|
|
1189
1105
|
column: 5
|
|
1190
1106
|
}
|
|
1191
1107
|
},
|
|
1192
|
-
line:
|
|
1108
|
+
line: 181
|
|
1193
1109
|
},
|
|
1194
|
-
"
|
|
1195
|
-
name: "(
|
|
1110
|
+
"15": {
|
|
1111
|
+
name: "(anonymous_15)",
|
|
1196
1112
|
decl: {
|
|
1197
1113
|
start: {
|
|
1198
|
-
line:
|
|
1114
|
+
line: 188,
|
|
1199
1115
|
column: 4
|
|
1200
1116
|
},
|
|
1201
1117
|
end: {
|
|
1202
|
-
line:
|
|
1118
|
+
line: 188,
|
|
1203
1119
|
column: 5
|
|
1204
1120
|
}
|
|
1205
1121
|
},
|
|
1206
1122
|
loc: {
|
|
1207
1123
|
start: {
|
|
1208
|
-
line:
|
|
1124
|
+
line: 188,
|
|
1209
1125
|
column: 14
|
|
1210
1126
|
},
|
|
1211
1127
|
end: {
|
|
1212
|
-
line:
|
|
1128
|
+
line: 188,
|
|
1213
1129
|
column: 85
|
|
1214
1130
|
}
|
|
1215
1131
|
},
|
|
1216
|
-
line:
|
|
1132
|
+
line: 188
|
|
1217
1133
|
},
|
|
1218
|
-
"
|
|
1219
|
-
name: "(
|
|
1134
|
+
"16": {
|
|
1135
|
+
name: "(anonymous_16)",
|
|
1220
1136
|
decl: {
|
|
1221
1137
|
start: {
|
|
1222
|
-
line:
|
|
1138
|
+
line: 189,
|
|
1223
1139
|
column: 4
|
|
1224
1140
|
},
|
|
1225
1141
|
end: {
|
|
1226
|
-
line:
|
|
1142
|
+
line: 189,
|
|
1227
1143
|
column: 5
|
|
1228
1144
|
}
|
|
1229
1145
|
},
|
|
1230
1146
|
loc: {
|
|
1231
1147
|
start: {
|
|
1232
|
-
line:
|
|
1148
|
+
line: 189,
|
|
1233
1149
|
column: 15
|
|
1234
1150
|
},
|
|
1235
1151
|
end: {
|
|
1236
|
-
line:
|
|
1152
|
+
line: 189,
|
|
1237
1153
|
column: 89
|
|
1238
1154
|
}
|
|
1239
1155
|
},
|
|
1240
|
-
line:
|
|
1156
|
+
line: 189
|
|
1241
1157
|
},
|
|
1242
|
-
"
|
|
1243
|
-
name: "(
|
|
1158
|
+
"17": {
|
|
1159
|
+
name: "(anonymous_17)",
|
|
1244
1160
|
decl: {
|
|
1245
1161
|
start: {
|
|
1246
|
-
line:
|
|
1162
|
+
line: 190,
|
|
1247
1163
|
column: 4
|
|
1248
1164
|
},
|
|
1249
1165
|
end: {
|
|
1250
|
-
line:
|
|
1166
|
+
line: 190,
|
|
1251
1167
|
column: 5
|
|
1252
1168
|
}
|
|
1253
1169
|
},
|
|
1254
1170
|
loc: {
|
|
1255
1171
|
start: {
|
|
1256
|
-
line:
|
|
1172
|
+
line: 190,
|
|
1257
1173
|
column: 16
|
|
1258
1174
|
},
|
|
1259
1175
|
end: {
|
|
1260
|
-
line:
|
|
1176
|
+
line: 190,
|
|
1261
1177
|
column: 88
|
|
1262
1178
|
}
|
|
1263
1179
|
},
|
|
1264
|
-
line:
|
|
1180
|
+
line: 190
|
|
1265
1181
|
},
|
|
1266
|
-
"
|
|
1267
|
-
name: "(
|
|
1182
|
+
"18": {
|
|
1183
|
+
name: "(anonymous_18)",
|
|
1268
1184
|
decl: {
|
|
1269
1185
|
start: {
|
|
1270
|
-
line:
|
|
1186
|
+
line: 191,
|
|
1271
1187
|
column: 4
|
|
1272
1188
|
},
|
|
1273
1189
|
end: {
|
|
1274
|
-
line:
|
|
1190
|
+
line: 191,
|
|
1275
1191
|
column: 5
|
|
1276
1192
|
}
|
|
1277
1193
|
},
|
|
1278
1194
|
loc: {
|
|
1279
1195
|
start: {
|
|
1280
|
-
line:
|
|
1196
|
+
line: 191,
|
|
1281
1197
|
column: 27
|
|
1282
1198
|
},
|
|
1283
1199
|
end: {
|
|
1284
|
-
line:
|
|
1200
|
+
line: 198,
|
|
1285
1201
|
column: 5
|
|
1286
1202
|
}
|
|
1287
1203
|
},
|
|
1288
|
-
line:
|
|
1204
|
+
line: 191
|
|
1289
1205
|
}
|
|
1290
1206
|
},
|
|
1291
1207
|
branchMap: {
|
|
@@ -1895,55 +1811,22 @@ function cov_1wctd2lw3r() {
|
|
|
1895
1811
|
"18": {
|
|
1896
1812
|
loc: {
|
|
1897
1813
|
start: {
|
|
1898
|
-
line:
|
|
1899
|
-
column: 24
|
|
1900
|
-
},
|
|
1901
|
-
end: {
|
|
1902
|
-
line: 179,
|
|
1903
|
-
column: 102
|
|
1904
|
-
}
|
|
1905
|
-
},
|
|
1906
|
-
type: "if",
|
|
1907
|
-
locations: [{
|
|
1908
|
-
start: {
|
|
1909
|
-
line: 178,
|
|
1910
|
-
column: 24
|
|
1911
|
-
},
|
|
1912
|
-
end: {
|
|
1913
|
-
line: 179,
|
|
1914
|
-
column: 102
|
|
1915
|
-
}
|
|
1916
|
-
}, {
|
|
1917
|
-
start: {
|
|
1918
|
-
line: undefined,
|
|
1919
|
-
column: undefined
|
|
1920
|
-
},
|
|
1921
|
-
end: {
|
|
1922
|
-
line: undefined,
|
|
1923
|
-
column: undefined
|
|
1924
|
-
}
|
|
1925
|
-
}],
|
|
1926
|
-
line: 178
|
|
1927
|
-
},
|
|
1928
|
-
"19": {
|
|
1929
|
-
loc: {
|
|
1930
|
-
start: {
|
|
1931
|
-
line: 186,
|
|
1814
|
+
line: 172,
|
|
1932
1815
|
column: 16
|
|
1933
1816
|
},
|
|
1934
1817
|
end: {
|
|
1935
|
-
line:
|
|
1818
|
+
line: 173,
|
|
1936
1819
|
column: 113
|
|
1937
1820
|
}
|
|
1938
1821
|
},
|
|
1939
1822
|
type: "if",
|
|
1940
1823
|
locations: [{
|
|
1941
1824
|
start: {
|
|
1942
|
-
line:
|
|
1825
|
+
line: 172,
|
|
1943
1826
|
column: 16
|
|
1944
1827
|
},
|
|
1945
1828
|
end: {
|
|
1946
|
-
line:
|
|
1829
|
+
line: 173,
|
|
1947
1830
|
column: 113
|
|
1948
1831
|
}
|
|
1949
1832
|
}, {
|
|
@@ -1956,27 +1839,27 @@ function cov_1wctd2lw3r() {
|
|
|
1956
1839
|
column: undefined
|
|
1957
1840
|
}
|
|
1958
1841
|
}],
|
|
1959
|
-
line:
|
|
1842
|
+
line: 172
|
|
1960
1843
|
},
|
|
1961
|
-
"
|
|
1844
|
+
"19": {
|
|
1962
1845
|
loc: {
|
|
1963
1846
|
start: {
|
|
1964
|
-
line:
|
|
1847
|
+
line: 194,
|
|
1965
1848
|
column: 12
|
|
1966
1849
|
},
|
|
1967
1850
|
end: {
|
|
1968
|
-
line:
|
|
1851
|
+
line: 195,
|
|
1969
1852
|
column: 44
|
|
1970
1853
|
}
|
|
1971
1854
|
},
|
|
1972
1855
|
type: "if",
|
|
1973
1856
|
locations: [{
|
|
1974
1857
|
start: {
|
|
1975
|
-
line:
|
|
1858
|
+
line: 194,
|
|
1976
1859
|
column: 12
|
|
1977
1860
|
},
|
|
1978
1861
|
end: {
|
|
1979
|
-
line:
|
|
1862
|
+
line: 195,
|
|
1980
1863
|
column: 44
|
|
1981
1864
|
}
|
|
1982
1865
|
}, {
|
|
@@ -1989,7 +1872,7 @@ function cov_1wctd2lw3r() {
|
|
|
1989
1872
|
column: undefined
|
|
1990
1873
|
}
|
|
1991
1874
|
}],
|
|
1992
|
-
line:
|
|
1875
|
+
line: 194
|
|
1993
1876
|
}
|
|
1994
1877
|
},
|
|
1995
1878
|
s: {
|
|
@@ -2064,13 +1947,7 @@ function cov_1wctd2lw3r() {
|
|
|
2064
1947
|
"68": 0,
|
|
2065
1948
|
"69": 0,
|
|
2066
1949
|
"70": 0,
|
|
2067
|
-
"71": 0
|
|
2068
|
-
"72": 0,
|
|
2069
|
-
"73": 0,
|
|
2070
|
-
"74": 0,
|
|
2071
|
-
"75": 0,
|
|
2072
|
-
"76": 0,
|
|
2073
|
-
"77": 0
|
|
1950
|
+
"71": 0
|
|
2074
1951
|
},
|
|
2075
1952
|
f: {
|
|
2076
1953
|
"0": 0,
|
|
@@ -2091,8 +1968,7 @@ function cov_1wctd2lw3r() {
|
|
|
2091
1968
|
"15": 0,
|
|
2092
1969
|
"16": 0,
|
|
2093
1970
|
"17": 0,
|
|
2094
|
-
"18": 0
|
|
2095
|
-
"19": 0
|
|
1971
|
+
"18": 0
|
|
2096
1972
|
},
|
|
2097
1973
|
b: {
|
|
2098
1974
|
"0": [0, 0, 0],
|
|
@@ -2114,19 +1990,18 @@ function cov_1wctd2lw3r() {
|
|
|
2114
1990
|
"16": [0, 0],
|
|
2115
1991
|
"17": [0, 0],
|
|
2116
1992
|
"18": [0, 0],
|
|
2117
|
-
"19": [0, 0]
|
|
2118
|
-
"20": [0, 0]
|
|
1993
|
+
"19": [0, 0]
|
|
2119
1994
|
},
|
|
2120
1995
|
inputSourceMap: {
|
|
2121
1996
|
version: 3,
|
|
2122
1997
|
file: "ITwinLocalization.js",
|
|
2123
1998
|
sources: ["C:\\agent\\_work\\2\\s\\core\\i18n\\src\\ITwinLocalization.ts"],
|
|
2124
1999
|
names: [],
|
|
2125
|
-
mappings: ";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;AAEH,sDAA2E;AAC3E,wGAAmG;AACnG,gFAAqF;AACrF,sDAA6C;AAG7C,MAAM,mBAAmB,GAAW,CAAC,CAAC,CAAC,8GAA8G;AAcrJ;;;GAGG;AACH,MAAa,iBAAiB;IACrB,OAAO,CAAO;IACJ,YAAY,CAAc;IAC1B,eAAe,CAAiB;IAChC,iBAAiB,CAAkB;IACnC,WAAW,GAAG,IAAI,GAAG,EAAyB,CAAC;IAEhE,YAAmB,OAA6B;QAC9C,IAAI,CAAC,OAAO,GAAG,iBAAO,CAAC,cAAc,EAAE,CAAC;QAExC,IAAI,CAAC,eAAe,GAAG;YACrB,QAAQ,EAAE,OAAO,EAAE,WAAW,IAAI,6BAA6B;YAC/D,WAAW,EAAE,IAAI;YACjB,GAAG,OAAO,EAAE,kBAAkB;SAC/B,CAAC;QAEF,IAAI,CAAC,iBAAiB,GAAG;YACvB,KAAK,EAAE,CAAC,aAAa,EAAE,WAAW,EAAE,SAAS,CAAC;YAC9C,iBAAiB,EAAE,KAAK;YACxB,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EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC7B,IAAI,OAAO,GAAG,KAAK,QAAQ;YACzB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAElD,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,mBAAmB,CAAC,IAAY;QACrC,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,gBAAgB;IACT,eAAe;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IAChC,CAAC;IAED,qDAAqD;IAC9C,KAAK,CAAC,cAAc,CAAC,QAAgB;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAA6B,CAAC;IAC3E,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,iBAAiB,CAAC,IAAY;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC5C,IAAI,QAAQ,KAAK,SAAS;YACxB,OAAO,QAAQ,CAAC;QAElB,MAAM,cAAc,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YACnD,mEAAmE;YACnE,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE;gBACxC,IAAI,CAAC,GAAG;oBACN,OAAO,OAAO,EAAE,CAAC;gBAEnB,
|
|
2126
|
-
sourcesContent: ["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Localization\r\n */\r\n\r\nimport i18next, { i18n, InitOptions, Module, TOptionsBase } from \"i18next\";\r\nimport i18nextBrowserLanguageDetector, { DetectorOptions } from \"i18next-browser-languagedetector\";\r\nimport Backend, { HttpBackendOptions as BackendOptions } from \"i18next-http-backend\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport type { Localization } from \"@itwin/core-common\";\r\n\r\nconst DEFAULT_MAX_RETRIES: number = 1; // a low number prevents wasted time and potential timeouts when requesting localization files throws an error\r\n\r\n/** Options for ITwinLocalization\r\n * @public\r\n */\r\nexport interface LocalizationOptions {\r\n urlTemplate?: string;\r\n backendPlugin?: Module;\r\n detectorPlugin?: Module;\r\n initOptions?: InitOptions;\r\n backendHttpOptions?: BackendOptions;\r\n detectorOptions?: DetectorOptions;\r\n}\r\n\r\n/** Supplies localizations for iTwin.js\r\n * @note this class uses the [i18next](https://www.i18next.com/) package.\r\n * @public\r\n */\r\nexport class ITwinLocalization implements Localization {\r\n public i18next: i18n;\r\n private readonly _initOptions: InitOptions;\r\n private readonly _backendOptions: BackendOptions;\r\n private readonly _detectionOptions: DetectorOptions;\r\n private readonly _namespaces = new Map<string, Promise<void>>();\r\n\r\n public constructor(options?: LocalizationOptions) {\r\n this.i18next = i18next.createInstance();\r\n\r\n this._backendOptions = {\r\n loadPath: options?.urlTemplate ?? \"locales/{{lng}}/{{ns}}.json\",\r\n crossDomain: true,\r\n ...options?.backendHttpOptions,\r\n };\r\n\r\n this._detectionOptions = {\r\n order: [\"querystring\", \"navigator\", \"htmlTag\"],\r\n lookupQuerystring: \"lng\",\r\n caches: [],\r\n ...options?.detectorOptions,\r\n };\r\n\r\n this._initOptions = {\r\n interpolation: { escapeValue: true },\r\n fallbackLng: \"en\",\r\n maxRetries: DEFAULT_MAX_RETRIES,\r\n backend: this._backendOptions,\r\n detection: this._detectionOptions,\r\n ...options?.initOptions,\r\n };\r\n\r\n this.i18next\r\n .use(options?.detectorPlugin ?? i18nextBrowserLanguageDetector)\r\n .use(options?.backendPlugin ?? Backend)\r\n .use(TranslationLogger);\r\n }\r\n\r\n public async initialize(namespaces: string[]): Promise<void> {\r\n\r\n // Also consider namespaces passed into constructor\r\n const initNamespaces: string[] = [this._initOptions.ns || []].flat();\r\n const combinedNamespaces: Set<string> = new Set([...namespaces, ...initNamespaces]); // without duplicates\r\n\r\n const defaultNamespace: string | false | readonly string[] = this._initOptions.defaultNS ?? namespaces[0];\r\n if (defaultNamespace)\r\n combinedNamespaces.add(defaultNamespace as string); // Make sure default namespace is in namespaces list\r\n\r\n const initOptions: InitOptions = {\r\n ...this._initOptions,\r\n defaultNS: defaultNamespace,\r\n ns: [...combinedNamespaces],\r\n };\r\n\r\n // if in a development environment, set debugging\r\n if (process.env.NODE_ENV === \"development\")\r\n initOptions.debug = true;\r\n\r\n const initPromise = this.i18next.init(initOptions) as unknown as Promise<void>;\r\n\r\n for (const ns of namespaces)\r\n this._namespaces.set(ns, initPromise);\r\n\r\n return initPromise;\r\n }\r\n\r\n /** Replace all instances of `%{key}` within a string with the translations of those keys.\r\n * For example:\r\n * ``` ts\r\n * \"MyKeys\": {\r\n * \"Key1\": \"First value\",\r\n * \"Key2\": \"Second value\"\r\n * }\r\n * ```\r\n *\r\n * ``` ts\r\n * i18.translateKeys(\"string with %{MyKeys.Key1} followed by %{MyKeys.Key2}!\"\") // returns \"string with First Value followed by Second Value!\"\r\n * ```\r\n * @param line The input line, potentially containing %{keys}.\r\n * @returns The line with all %{keys} translated\r\n * @public\r\n */\r\n public getLocalizedKeys(line: string): string {\r\n return line.replace(/\\%\\{(.+?)\\}/g, (_match, tag) => this.getLocalizedString(tag));\r\n }\r\n\r\n /** Return the translated value of a key.\r\n * @param key - the key that matches a property in the JSON localization file.\r\n * @note The key includes the namespace, which identifies the particular localization file that contains the property,\r\n * followed by a colon, followed by the property in the JSON file.\r\n * For example:\r\n * ``` ts\r\n * const dataString: string = IModelApp.localization.getLocalizedString(\"iModelJs:BackgroundMap.BingDataAttribution\");\r\n * ```\r\n * assigns to dataString the string with property BackgroundMap.BingDataAttribution from the iModelJs.json localization file.\r\n * @returns The string corresponding to the first key that resolves.\r\n * @throws Error if no keys resolve to a string.\r\n * @public\r\n */\r\n public getLocalizedString(key: string | string[], options?: TOptionsBase): string {\r\n if (options?.returnDetails || options?.returnObjects) {\r\n throw new Error(\"Translation key must map to a string, but the given options will result in an object\");\r\n }\r\n\r\n const value = this.i18next.t(key, options);\r\n\r\n if (typeof value !== \"string\") {\r\n throw new Error(\"Translation key(s) string not found\");\r\n }\r\n\r\n return value;\r\n }\r\n\r\n /** Gets the English translation.\r\n * @param namespace - the namespace that identifies the particular localization file that contains the property.\r\n * @param key - the key that matches a property in the JSON localization file.\r\n * @returns The string corresponding to the first key that resolves.\r\n * @throws Error if no keys resolve to a string.\r\n * @internal\r\n */\r\n public getEnglishString(namespace: string, key: string | string[], options?: TOptionsBase): string {\r\n if (options?.returnDetails || options?.returnObjects) {\r\n throw new Error(\"Translation key must map to a string, but the given options will result in an object\");\r\n }\r\n\r\n options = {\r\n ...options,\r\n ns: namespace, // ensure namespace argument is used\r\n };\r\n\r\n const en = this.i18next.getFixedT(\"en\", namespace);\r\n const str = en(key, options);\r\n if (typeof str !== \"string\")\r\n throw new Error(\"Translation key(s) not found\");\r\n\r\n return str;\r\n }\r\n\r\n /** Get the promise for an already registered Namespace.\r\n * @param name - the name of the namespace\r\n * @public\r\n */\r\n public getNamespacePromise(name: string): Promise<void> | undefined {\r\n return this._namespaces.get(name);\r\n }\r\n\r\n /** @internal */\r\n public getLanguageList(): readonly string[] {\r\n return this.i18next.languages;\r\n }\r\n\r\n /** override the language detected in the browser */\r\n public async changeLanguage(language: string) {\r\n return this.i18next.changeLanguage(language) as unknown as Promise<void>;\r\n }\r\n\r\n /** Register a new Namespace and return it. If the namespace is already registered, it will be returned.\r\n * @param name - the name of the namespace, which is the base name of the JSON file that contains the localization properties.\r\n * @note - The registerNamespace method starts fetching the appropriate version of the JSON localization file from the server,\r\n * based on the current locale. To make sure that fetch is complete before performing translations from this namespace, await\r\n * fulfillment of the readPromise Promise property of the returned LocalizationNamespace.\r\n * @see [Localization in iTwin.js]($docs/learning/frontend/Localization.md)\r\n * @public\r\n */\r\n public async registerNamespace(name: string): Promise<void> {\r\n const existing = this._namespaces.get(name);\r\n if (existing !== undefined)\r\n return existing;\r\n\r\n const theReadPromise = new Promise<void>((resolve) => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.i18next.loadNamespaces(name, (err) => {\r\n if (!err)\r\n return resolve();\r\n\r\n // Here we got a non-null err object.\r\n // This method is called when the system has attempted to load the resources for the namespaces for each possible locale.\r\n // For example 'fr-ca' might be the most specific locale, in which case 'fr' and 'en' are fallback locales.\r\n // Using Backend from i18next-http-backend, err will be an array of strings of each namespace it tried to read and its locale.\r\n // There might be errs for some other namespaces as well as this one. We resolve the promise unless there's an error for each possible locale.\r\n let locales = this.getLanguageList().map((thisLocale: any) => `/${thisLocale}/`);\r\n\r\n try {\r\n for (const thisError of err) {\r\n if (typeof thisError === \"string\")\r\n locales = locales.filter((thisLocale) => !thisError.includes(thisLocale));\r\n }\r\n } catch {\r\n locales = [];\r\n }\r\n // if we removed every locale from the array, it wasn't loaded.\r\n if (locales.length === 0)\r\n Logger.logError(\"i18n\", `No resources for namespace ${name} could be loaded`);\r\n\r\n resolve();\r\n });\r\n });\r\n this._namespaces.set(name, theReadPromise);\r\n return theReadPromise;\r\n }\r\n\r\n /** @internal */\r\n public unregisterNamespace(name: string): void {\r\n this._namespaces.delete(name);\r\n }\r\n}\r\n\r\nclass TranslationLogger {\r\n public static readonly type = \"logger\";\r\n public log(args: string[]) { Logger.logInfo(\"i18n\", this.createLogMessage(args)); }\r\n public warn(args: string[]) { Logger.logWarning(\"i18n\", this.createLogMessage(args)); }\r\n public error(args: string[]) { Logger.logError(\"i18n\", this.createLogMessage(args)); }\r\n private createLogMessage(args: string[]) {\r\n let message = args[0];\r\n for (let i = 1; i < args.length; ++i) {\r\n if (typeof args[i] === \"string\")\r\n message += `\\n ${args[i]}`;\r\n }\r\n return message;\r\n }\r\n}\r\n"]
|
|
2000
|
+
mappings: ";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;AAEH,sDAA2E;AA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,KAAK,CAAC,IAAc,IAAI,qBAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9E,gBAAgB,CAAC,IAAc;QACrC,IAAI,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;YACrC,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ;gBAC7B,OAAO,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAChC,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC",
|
|
2001
|
+
sourcesContent: ["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Localization\r\n */\r\n\r\nimport i18next, { i18n, InitOptions, Module, TOptionsBase } from \"i18next\";\r\nimport i18nextBrowserLanguageDetector, { DetectorOptions } from \"i18next-browser-languagedetector\";\r\nimport Backend, { HttpBackendOptions as BackendOptions } from \"i18next-http-backend\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport type { Localization } from \"@itwin/core-common\";\r\n\r\nconst DEFAULT_MAX_RETRIES: number = 1; // a low number prevents wasted time and potential timeouts when requesting localization files throws an error\r\n\r\n/** Options for ITwinLocalization\r\n * @public\r\n */\r\nexport interface LocalizationOptions {\r\n urlTemplate?: string;\r\n backendPlugin?: Module;\r\n detectorPlugin?: Module;\r\n initOptions?: InitOptions;\r\n backendHttpOptions?: BackendOptions;\r\n detectorOptions?: DetectorOptions;\r\n}\r\n\r\n/** Supplies localizations for iTwin.js\r\n * @note this class uses the [i18next](https://www.i18next.com/) package.\r\n * @public\r\n */\r\nexport class ITwinLocalization implements Localization {\r\n public i18next: i18n;\r\n private readonly _initOptions: InitOptions;\r\n private readonly _backendOptions: BackendOptions;\r\n private readonly _detectionOptions: DetectorOptions;\r\n private readonly _namespaces = new Map<string, Promise<void>>();\r\n\r\n public constructor(options?: LocalizationOptions) {\r\n this.i18next = i18next.createInstance();\r\n\r\n this._backendOptions = {\r\n loadPath: options?.urlTemplate ?? \"locales/{{lng}}/{{ns}}.json\",\r\n crossDomain: true,\r\n ...options?.backendHttpOptions,\r\n };\r\n\r\n this._detectionOptions = {\r\n order: [\"querystring\", \"navigator\", \"htmlTag\"],\r\n lookupQuerystring: \"lng\",\r\n caches: [],\r\n ...options?.detectorOptions,\r\n };\r\n\r\n this._initOptions = {\r\n interpolation: { escapeValue: true },\r\n fallbackLng: \"en\",\r\n maxRetries: DEFAULT_MAX_RETRIES,\r\n backend: this._backendOptions,\r\n detection: this._detectionOptions,\r\n ...options?.initOptions,\r\n };\r\n\r\n this.i18next\r\n .use(options?.detectorPlugin ?? i18nextBrowserLanguageDetector)\r\n .use(options?.backendPlugin ?? Backend)\r\n .use(TranslationLogger);\r\n }\r\n\r\n public async initialize(namespaces: string[]): Promise<void> {\r\n\r\n // Also consider namespaces passed into constructor\r\n const initNamespaces: string[] = [this._initOptions.ns || []].flat();\r\n const combinedNamespaces: Set<string> = new Set([...namespaces, ...initNamespaces]); // without duplicates\r\n\r\n const defaultNamespace: string | false | readonly string[] = this._initOptions.defaultNS ?? namespaces[0];\r\n if (defaultNamespace)\r\n combinedNamespaces.add(defaultNamespace as string); // Make sure default namespace is in namespaces list\r\n\r\n const initOptions: InitOptions = {\r\n ...this._initOptions,\r\n defaultNS: defaultNamespace,\r\n ns: [...combinedNamespaces],\r\n };\r\n\r\n // if in a development environment, set debugging\r\n if (process.env.NODE_ENV === \"development\")\r\n initOptions.debug = true;\r\n\r\n const initPromise = this.i18next.init(initOptions) as unknown as Promise<void>;\r\n\r\n for (const ns of namespaces)\r\n this._namespaces.set(ns, initPromise);\r\n\r\n return initPromise;\r\n }\r\n\r\n /** Replace all instances of `%{key}` within a string with the translations of those keys.\r\n * For example:\r\n * ``` ts\r\n * \"MyKeys\": {\r\n * \"Key1\": \"First value\",\r\n * \"Key2\": \"Second value\"\r\n * }\r\n * ```\r\n *\r\n * ``` ts\r\n * i18.translateKeys(\"string with %{MyKeys.Key1} followed by %{MyKeys.Key2}!\"\") // returns \"string with First Value followed by Second Value!\"\r\n * ```\r\n * @param line The input line, potentially containing %{keys}.\r\n * @returns The line with all %{keys} translated\r\n * @public\r\n */\r\n public getLocalizedKeys(line: string): string {\r\n return line.replace(/\\%\\{(.+?)\\}/g, (_match, tag) => this.getLocalizedString(tag));\r\n }\r\n\r\n /** Return the translated value of a key.\r\n * @param key - the key that matches a property in the JSON localization file.\r\n * @note The key includes the namespace, which identifies the particular localization file that contains the property,\r\n * followed by a colon, followed by the property in the JSON file.\r\n * For example:\r\n * ``` ts\r\n * const dataString: string = IModelApp.localization.getLocalizedString(\"iModelJs:BackgroundMap.BingDataAttribution\");\r\n * ```\r\n * assigns to dataString the string with property BackgroundMap.BingDataAttribution from the iModelJs.json localization file.\r\n * @returns The string corresponding to the first key that resolves.\r\n * @throws Error if no keys resolve to a string.\r\n * @public\r\n */\r\n public getLocalizedString(key: string | string[], options?: TOptionsBase): string {\r\n if (options?.returnDetails || options?.returnObjects) {\r\n throw new Error(\"Translation key must map to a string, but the given options will result in an object\");\r\n }\r\n\r\n const value = this.i18next.t(key, options);\r\n\r\n if (typeof value !== \"string\") {\r\n throw new Error(\"Translation key(s) string not found\");\r\n }\r\n\r\n return value;\r\n }\r\n\r\n /** Gets the English translation.\r\n * @param namespace - the namespace that identifies the particular localization file that contains the property.\r\n * @param key - the key that matches a property in the JSON localization file.\r\n * @returns The string corresponding to the first key that resolves.\r\n * @throws Error if no keys resolve to a string.\r\n * @internal\r\n */\r\n public getEnglishString(namespace: string, key: string | string[], options?: TOptionsBase): string {\r\n if (options?.returnDetails || options?.returnObjects) {\r\n throw new Error(\"Translation key must map to a string, but the given options will result in an object\");\r\n }\r\n\r\n options = {\r\n ...options,\r\n ns: namespace, // ensure namespace argument is used\r\n };\r\n\r\n const en = this.i18next.getFixedT(\"en\", namespace);\r\n const str = en(key, options);\r\n if (typeof str !== \"string\")\r\n throw new Error(\"Translation key(s) not found\");\r\n\r\n return str;\r\n }\r\n\r\n /** Get the promise for an already registered Namespace.\r\n * @param name - the name of the namespace\r\n * @public\r\n */\r\n public getNamespacePromise(name: string): Promise<void> | undefined {\r\n return this._namespaces.get(name);\r\n }\r\n\r\n /** @internal */\r\n public getLanguageList(): readonly string[] {\r\n return this.i18next.languages;\r\n }\r\n\r\n /** override the language detected in the browser */\r\n public async changeLanguage(language: string) {\r\n return this.i18next.changeLanguage(language) as unknown as Promise<void>;\r\n }\r\n\r\n /** Register a new Namespace and return it. If the namespace is already registered, it will be returned.\r\n * @param name - the name of the namespace, which is the base name of the JSON file that contains the localization properties.\r\n * @note - The registerNamespace method starts fetching the appropriate version of the JSON localization file from the server,\r\n * based on the current locale. To make sure that fetch is complete before performing translations from this namespace, await\r\n * fulfillment of the readPromise Promise property of the returned LocalizationNamespace.\r\n * @see [Localization in iTwin.js]($docs/learning/frontend/Localization.md)\r\n * @public\r\n */\r\n public async registerNamespace(name: string): Promise<void> {\r\n const existing = this._namespaces.get(name);\r\n if (existing !== undefined)\r\n return existing;\r\n\r\n const theReadPromise = new Promise<void>((resolve) => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.i18next.loadNamespaces(name, (err) => {\r\n if (!err)\r\n return resolve();\r\n\r\n // i18next can return errors from other concurrent namespace loads in this callback.\r\n const wasLoaded = this.getLanguageList().some((language) => this.i18next.hasResourceBundle(language, name));\r\n if (!wasLoaded)\r\n Logger.logError(\"i18n\", `No resources for namespace ${name} could be loaded`);\r\n\r\n resolve();\r\n });\r\n });\r\n this._namespaces.set(name, theReadPromise);\r\n return theReadPromise;\r\n }\r\n\r\n /** @internal */\r\n public unregisterNamespace(name: string): void {\r\n this._namespaces.delete(name);\r\n }\r\n}\r\n\r\nclass TranslationLogger {\r\n public static readonly type = \"logger\";\r\n public log(args: string[]) { Logger.logInfo(\"i18n\", this.createLogMessage(args)); }\r\n public warn(args: string[]) { Logger.logWarning(\"i18n\", this.createLogMessage(args)); }\r\n public error(args: string[]) { Logger.logError(\"i18n\", this.createLogMessage(args)); }\r\n private createLogMessage(args: string[]) {\r\n let message = args[0];\r\n for (let i = 1; i < args.length; ++i) {\r\n if (typeof args[i] === \"string\")\r\n message += `\\n ${args[i]}`;\r\n }\r\n return message;\r\n }\r\n}\r\n"]
|
|
2127
2002
|
},
|
|
2128
2003
|
_coverageSchema: "1a1c01bbd47fc00a2c39e90264f33305004495a9",
|
|
2129
|
-
hash: "
|
|
2004
|
+
hash: "11843a9389894bd74427d7137f54e50ca9e52905"
|
|
2130
2005
|
};
|
|
2131
2006
|
var coverage = global[gcv] || (global[gcv] = {});
|
|
2132
2007
|
if (!coverage[path] || coverage[path].hash !== hash) {
|
|
@@ -2384,96 +2259,70 @@ class ITwinLocalization {
|
|
|
2384
2259
|
} else {
|
|
2385
2260
|
cov_1wctd2lw3r().b[17][1]++;
|
|
2386
2261
|
}
|
|
2387
|
-
//
|
|
2388
|
-
|
|
2389
|
-
// For example 'fr-ca' might be the most specific locale, in which case 'fr' and 'en' are fallback locales.
|
|
2390
|
-
// Using Backend from i18next-http-backend, err will be an array of strings of each namespace it tried to read and its locale.
|
|
2391
|
-
// There might be errs for some other namespaces as well as this one. We resolve the promise unless there's an error for each possible locale.
|
|
2392
|
-
let locales = (cov_1wctd2lw3r().s[53]++, this.getLanguageList().map(thisLocale => {
|
|
2262
|
+
// i18next can return errors from other concurrent namespace loads in this callback.
|
|
2263
|
+
const wasLoaded = (cov_1wctd2lw3r().s[53]++, this.getLanguageList().some(language => {
|
|
2393
2264
|
cov_1wctd2lw3r().f[13]++;
|
|
2394
2265
|
cov_1wctd2lw3r().s[54]++;
|
|
2395
|
-
return
|
|
2266
|
+
return this.i18next.hasResourceBundle(language, name);
|
|
2396
2267
|
}));
|
|
2397
2268
|
cov_1wctd2lw3r().s[55]++;
|
|
2398
|
-
|
|
2269
|
+
if (!wasLoaded) {
|
|
2270
|
+
cov_1wctd2lw3r().b[18][0]++;
|
|
2399
2271
|
cov_1wctd2lw3r().s[56]++;
|
|
2400
|
-
for (const thisError of err) {
|
|
2401
|
-
cov_1wctd2lw3r().s[57]++;
|
|
2402
|
-
if (typeof thisError === "string") {
|
|
2403
|
-
cov_1wctd2lw3r().b[18][0]++;
|
|
2404
|
-
cov_1wctd2lw3r().s[58]++;
|
|
2405
|
-
locales = locales.filter(thisLocale => {
|
|
2406
|
-
cov_1wctd2lw3r().f[14]++;
|
|
2407
|
-
cov_1wctd2lw3r().s[59]++;
|
|
2408
|
-
return !thisError.includes(thisLocale);
|
|
2409
|
-
});
|
|
2410
|
-
} else {
|
|
2411
|
-
cov_1wctd2lw3r().b[18][1]++;
|
|
2412
|
-
}
|
|
2413
|
-
}
|
|
2414
|
-
} catch {
|
|
2415
|
-
cov_1wctd2lw3r().s[60]++;
|
|
2416
|
-
locales = [];
|
|
2417
|
-
}
|
|
2418
|
-
// if we removed every locale from the array, it wasn't loaded.
|
|
2419
|
-
cov_1wctd2lw3r().s[61]++;
|
|
2420
|
-
if (locales.length === 0) {
|
|
2421
|
-
cov_1wctd2lw3r().b[19][0]++;
|
|
2422
|
-
cov_1wctd2lw3r().s[62]++;
|
|
2423
2272
|
core_bentley_1.Logger.logError("i18n", `No resources for namespace ${name} could be loaded`);
|
|
2424
2273
|
} else {
|
|
2425
|
-
cov_1wctd2lw3r().b[
|
|
2274
|
+
cov_1wctd2lw3r().b[18][1]++;
|
|
2426
2275
|
}
|
|
2427
|
-
cov_1wctd2lw3r().s[
|
|
2276
|
+
cov_1wctd2lw3r().s[57]++;
|
|
2428
2277
|
resolve();
|
|
2429
2278
|
});
|
|
2430
2279
|
}));
|
|
2431
|
-
cov_1wctd2lw3r().s[
|
|
2280
|
+
cov_1wctd2lw3r().s[58]++;
|
|
2432
2281
|
this._namespaces.set(name, theReadPromise);
|
|
2433
|
-
cov_1wctd2lw3r().s[
|
|
2282
|
+
cov_1wctd2lw3r().s[59]++;
|
|
2434
2283
|
return theReadPromise;
|
|
2435
2284
|
}
|
|
2436
2285
|
/** @internal */
|
|
2437
2286
|
unregisterNamespace(name) {
|
|
2438
|
-
cov_1wctd2lw3r().f[
|
|
2439
|
-
cov_1wctd2lw3r().s[
|
|
2287
|
+
cov_1wctd2lw3r().f[14]++;
|
|
2288
|
+
cov_1wctd2lw3r().s[60]++;
|
|
2440
2289
|
this._namespaces.delete(name);
|
|
2441
2290
|
}
|
|
2442
2291
|
}
|
|
2443
|
-
cov_1wctd2lw3r().s[
|
|
2292
|
+
cov_1wctd2lw3r().s[61]++;
|
|
2444
2293
|
exports.ITwinLocalization = ITwinLocalization;
|
|
2445
2294
|
class TranslationLogger {
|
|
2446
|
-
static type = (cov_1wctd2lw3r().s[
|
|
2295
|
+
static type = (cov_1wctd2lw3r().s[62]++, "logger");
|
|
2447
2296
|
log(args) {
|
|
2448
|
-
cov_1wctd2lw3r().f[
|
|
2449
|
-
cov_1wctd2lw3r().s[
|
|
2297
|
+
cov_1wctd2lw3r().f[15]++;
|
|
2298
|
+
cov_1wctd2lw3r().s[63]++;
|
|
2450
2299
|
core_bentley_1.Logger.logInfo("i18n", this.createLogMessage(args));
|
|
2451
2300
|
}
|
|
2452
2301
|
warn(args) {
|
|
2453
|
-
cov_1wctd2lw3r().f[
|
|
2454
|
-
cov_1wctd2lw3r().s[
|
|
2302
|
+
cov_1wctd2lw3r().f[16]++;
|
|
2303
|
+
cov_1wctd2lw3r().s[64]++;
|
|
2455
2304
|
core_bentley_1.Logger.logWarning("i18n", this.createLogMessage(args));
|
|
2456
2305
|
}
|
|
2457
2306
|
error(args) {
|
|
2458
|
-
cov_1wctd2lw3r().f[
|
|
2459
|
-
cov_1wctd2lw3r().s[
|
|
2307
|
+
cov_1wctd2lw3r().f[17]++;
|
|
2308
|
+
cov_1wctd2lw3r().s[65]++;
|
|
2460
2309
|
core_bentley_1.Logger.logError("i18n", this.createLogMessage(args));
|
|
2461
2310
|
}
|
|
2462
2311
|
createLogMessage(args) {
|
|
2463
|
-
cov_1wctd2lw3r().f[
|
|
2464
|
-
let message = (cov_1wctd2lw3r().s[
|
|
2465
|
-
cov_1wctd2lw3r().s[
|
|
2466
|
-
for (let i = (cov_1wctd2lw3r().s[
|
|
2467
|
-
cov_1wctd2lw3r().s[
|
|
2312
|
+
cov_1wctd2lw3r().f[18]++;
|
|
2313
|
+
let message = (cov_1wctd2lw3r().s[66]++, args[0]);
|
|
2314
|
+
cov_1wctd2lw3r().s[67]++;
|
|
2315
|
+
for (let i = (cov_1wctd2lw3r().s[68]++, 1); i < args.length; ++i) {
|
|
2316
|
+
cov_1wctd2lw3r().s[69]++;
|
|
2468
2317
|
if (typeof args[i] === "string") {
|
|
2469
|
-
cov_1wctd2lw3r().b[
|
|
2470
|
-
cov_1wctd2lw3r().s[
|
|
2318
|
+
cov_1wctd2lw3r().b[19][0]++;
|
|
2319
|
+
cov_1wctd2lw3r().s[70]++;
|
|
2471
2320
|
message += `\n ${args[i]}`;
|
|
2472
2321
|
} else {
|
|
2473
|
-
cov_1wctd2lw3r().b[
|
|
2322
|
+
cov_1wctd2lw3r().b[19][1]++;
|
|
2474
2323
|
}
|
|
2475
2324
|
}
|
|
2476
|
-
cov_1wctd2lw3r().s[
|
|
2325
|
+
cov_1wctd2lw3r().s[71]++;
|
|
2477
2326
|
return message;
|
|
2478
2327
|
}
|
|
2479
2328
|
}
|
|
@@ -25890,6 +25739,7 @@ let exports = __webpack_exports__;
|
|
|
25890
25739
|
*--------------------------------------------------------------------------------------------*/
|
|
25891
25740
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
25892
25741
|
const chai_1 = __webpack_require__(/*! chai */ "../../common/temp/node_modules/.pnpm/chai@4.5.0/node_modules/chai/index.js");
|
|
25742
|
+
const core_bentley_1 = __webpack_require__(/*! @itwin/core-bentley */ "../bentley/lib/esm/core-bentley.js");
|
|
25893
25743
|
const ITwinLocalization_1 = __webpack_require__(/*! ../ITwinLocalization */ "./lib/cjs/ITwinLocalization.js");
|
|
25894
25744
|
describe("ITwinLocalization", () => {
|
|
25895
25745
|
let localization;
|
|
@@ -26756,6 +26606,65 @@ describe("ITwinLocalization", () => {
|
|
|
26756
26606
|
chai_1.assert.isTrue(itwinLocalization.i18next.hasLoadedNamespace("Test"));
|
|
26757
26607
|
chai_1.assert.equal(itwinLocalization.getLocalizedString("Test:FirstTrivial"), "First level string (test)");
|
|
26758
26608
|
});
|
|
26609
|
+
it("attributes errors from concurrent namespace loads to the namespace that failed", async () => {
|
|
26610
|
+
const pendingLoads = new Map();
|
|
26611
|
+
const backend = {
|
|
26612
|
+
type: "backend",
|
|
26613
|
+
init: () => { },
|
|
26614
|
+
read: (_language, namespace, callback) => pendingLoads.set(namespace, callback),
|
|
26615
|
+
};
|
|
26616
|
+
itwinLocalization = new ITwinLocalization_1.ITwinLocalization({
|
|
26617
|
+
backendPlugin: backend,
|
|
26618
|
+
initOptions: { lng: "en", fallbackLng: false },
|
|
26619
|
+
});
|
|
26620
|
+
await itwinLocalization.initialize([]);
|
|
26621
|
+
const loggedErrors = [];
|
|
26622
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method -- Preserve the exact method reference so the test can restore it.
|
|
26623
|
+
const originalLogError = core_bentley_1.Logger.logError;
|
|
26624
|
+
core_bentley_1.Logger.logError = (_category, message) => loggedErrors.push(String(message));
|
|
26625
|
+
try {
|
|
26626
|
+
const loadedPromise = itwinLocalization.registerNamespace("Loaded");
|
|
26627
|
+
const missingPromise = itwinLocalization.registerNamespace("Missing");
|
|
26628
|
+
chai_1.assert.sameMembers([...pendingLoads.keys()], ["Loaded", "Missing"]);
|
|
26629
|
+
pendingLoads.get("Missing")?.(new Error("Missing namespace"), false);
|
|
26630
|
+
pendingLoads.get("Loaded")?.(null, { key: "value" });
|
|
26631
|
+
await Promise.all([missingPromise, loadedPromise]);
|
|
26632
|
+
chai_1.assert.deepEqual(loggedErrors, ["No resources for namespace Missing could be loaded"]);
|
|
26633
|
+
chai_1.assert.isTrue(itwinLocalization.i18next.hasResourceBundle("en", "Loaded"));
|
|
26634
|
+
}
|
|
26635
|
+
finally {
|
|
26636
|
+
core_bentley_1.Logger.logError = originalLogError;
|
|
26637
|
+
}
|
|
26638
|
+
});
|
|
26639
|
+
it("does not log an error when a namespace loads from a fallback language", async () => {
|
|
26640
|
+
const pendingLoads = new Map();
|
|
26641
|
+
const backend = {
|
|
26642
|
+
type: "backend",
|
|
26643
|
+
init: () => { },
|
|
26644
|
+
read: (language, namespace, callback) => pendingLoads.set(`${language}/${namespace}`, callback),
|
|
26645
|
+
};
|
|
26646
|
+
itwinLocalization = new ITwinLocalization_1.ITwinLocalization({
|
|
26647
|
+
backendPlugin: backend,
|
|
26648
|
+
initOptions: { lng: "fr", fallbackLng: "en" },
|
|
26649
|
+
});
|
|
26650
|
+
await itwinLocalization.initialize([]);
|
|
26651
|
+
const loggedErrors = [];
|
|
26652
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method -- Preserve the exact method reference so the test can restore it.
|
|
26653
|
+
const originalLogError = core_bentley_1.Logger.logError;
|
|
26654
|
+
core_bentley_1.Logger.logError = (_category, message) => loggedErrors.push(String(message));
|
|
26655
|
+
try {
|
|
26656
|
+
const loadPromise = itwinLocalization.registerNamespace("Fallback");
|
|
26657
|
+
chai_1.assert.sameMembers([...pendingLoads.keys()], ["fr/Fallback", "en/Fallback"]);
|
|
26658
|
+
pendingLoads.get("fr/Fallback")?.(new Error("Missing French namespace"), false);
|
|
26659
|
+
pendingLoads.get("en/Fallback")?.(null, { key: "value" });
|
|
26660
|
+
await loadPromise;
|
|
26661
|
+
chai_1.assert.isEmpty(loggedErrors);
|
|
26662
|
+
chai_1.assert.isTrue(itwinLocalization.i18next.hasResourceBundle("en", "Fallback"));
|
|
26663
|
+
}
|
|
26664
|
+
finally {
|
|
26665
|
+
core_bentley_1.Logger.logError = originalLogError;
|
|
26666
|
+
}
|
|
26667
|
+
});
|
|
26759
26668
|
});
|
|
26760
26669
|
// unregisterNamespace() isn't used and basically does nothing
|
|
26761
26670
|
// describe("#unregisterNamespace", () => {
|