@itwin/core-i18n 5.14.0-dev.8 → 5.14.0
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/CHANGELOG.md +43 -1
- 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 +310 -402
- package/lib/cjs/test/webpack/bundled-tests.instrumented.js.map +1 -1
- package/lib/cjs/test/webpack/bundled-tests.js +66 -21
- package/lib/cjs/test/webpack/bundled-tests.js.map +1 -1
- package/lib/cjs/test/webpack/vendors-common_temp_node_modules_pnpm_cross-fetch_4_1_0_node_modules_cross-fetch_dist_browser-44272f.bundled-tests.instrumented.js.map +1 -1
- package/lib/cjs/test/webpack/vendors-common_temp_node_modules_pnpm_cross-fetch_4_1_0_node_modules_cross-fetch_dist_browser-44272f.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
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
/** @packageDocumentation
|
|
18
18
|
* @module Localization
|
|
19
19
|
*/
|
|
20
|
-
function
|
|
21
|
-
var path = "C:\\agent\\_work\\
|
|
22
|
-
var hash = "
|
|
20
|
+
function cov_ogldeftyv() {
|
|
21
|
+
var path = "C:\\agent\\_work\\1\\s\\core\\i18n\\lib\\cjs\\ITwinLocalization.js";
|
|
22
|
+
var hash = "8de28e753813d64322bcaeb99c8c8dfad2c2faad";
|
|
23
23
|
var global = new Function("return this")();
|
|
24
24
|
var gcv = "__coverage__";
|
|
25
25
|
var coverageData = {
|
|
26
|
-
path: "C:\\agent\\_work\\
|
|
26
|
+
path: "C:\\agent\\_work\\1\\s\\core\\i18n\\lib\\cjs\\ITwinLocalization.js",
|
|
27
27
|
statementMap: {
|
|
28
28
|
"0": {
|
|
29
29
|
start: {
|
|
@@ -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
|
-
sources: ["C:\\agent\\_work\\
|
|
1998
|
+
sources: ["C:\\agent\\_work\\1\\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;AAcr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G,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;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,MAAM,EAAE,EAAE;YACV,GAAG,OAAO,EAAE,eAAe;SAC5B,CAAC;QAEF,IAAI,CAAC,YAAY,GAAG;YAClB,aA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E,cAAc,CAAC,CAAC;QAC3C,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,gBAAgB;IACT,mBAAmB,CAAC,IAAY;QACrC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACF;AA/LD,8CA+LC;AAED,MAAM,iBAAiB;IACd,MAAM,CAAU,IAAI,GAAG,QAAQ,CAAC;IAChC,GAAG,CAAC,IAAc,IAAI,qBAAM,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5E,IAAI,CAAC,IAAc,IAAI,qBAAM,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAChF,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: "8de28e753813d64322bcaeb99c8c8dfad2c2faad"
|
|
2130
2005
|
};
|
|
2131
2006
|
var coverage = global[gcv] || (global[gcv] = {});
|
|
2132
2007
|
if (!coverage[path] || coverage[path].hash !== hash) {
|
|
@@ -2135,31 +2010,31 @@ function cov_1wctd2lw3r() {
|
|
|
2135
2010
|
var actualCoverage = coverage[path];
|
|
2136
2011
|
{
|
|
2137
2012
|
// @ts-ignore
|
|
2138
|
-
|
|
2013
|
+
cov_ogldeftyv = function () {
|
|
2139
2014
|
return actualCoverage;
|
|
2140
2015
|
};
|
|
2141
2016
|
}
|
|
2142
2017
|
return actualCoverage;
|
|
2143
2018
|
}
|
|
2144
|
-
|
|
2145
|
-
var __importDefault = (
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
return (
|
|
2019
|
+
cov_ogldeftyv();
|
|
2020
|
+
var __importDefault = (cov_ogldeftyv().s[0]++, (cov_ogldeftyv().b[0][0]++, this) && (cov_ogldeftyv().b[0][1]++, this.__importDefault) || (cov_ogldeftyv().b[0][2]++, function (mod) {
|
|
2021
|
+
cov_ogldeftyv().f[0]++;
|
|
2022
|
+
cov_ogldeftyv().s[1]++;
|
|
2023
|
+
return (cov_ogldeftyv().b[2][0]++, mod) && (cov_ogldeftyv().b[2][1]++, mod.__esModule) ? (cov_ogldeftyv().b[1][0]++, mod) : (cov_ogldeftyv().b[1][1]++, {
|
|
2149
2024
|
"default": mod
|
|
2150
2025
|
});
|
|
2151
2026
|
}));
|
|
2152
|
-
|
|
2027
|
+
cov_ogldeftyv().s[2]++;
|
|
2153
2028
|
Object.defineProperty(exports, "__esModule", ({
|
|
2154
2029
|
value: true
|
|
2155
2030
|
}));
|
|
2156
|
-
|
|
2031
|
+
cov_ogldeftyv().s[3]++;
|
|
2157
2032
|
exports.ITwinLocalization = void 0;
|
|
2158
|
-
const i18next_1 = (
|
|
2159
|
-
const i18next_browser_languagedetector_1 = (
|
|
2160
|
-
const i18next_http_backend_1 = (
|
|
2161
|
-
const core_bentley_1 = (
|
|
2162
|
-
const DEFAULT_MAX_RETRIES = (
|
|
2033
|
+
const i18next_1 = (cov_ogldeftyv().s[4]++, __importDefault(__webpack_require__(/*! i18next */ "../../common/temp/node_modules/.pnpm/i18next@21.10.0/node_modules/i18next/dist/cjs/i18next.js")));
|
|
2034
|
+
const i18next_browser_languagedetector_1 = (cov_ogldeftyv().s[5]++, __importDefault(__webpack_require__(/*! i18next-browser-languagedetector */ "../../common/temp/node_modules/.pnpm/i18next-browser-languagedetector@6.1.8/node_modules/i18next-browser-languagedetector/dist/cjs/i18nextBrowserLanguageDetector.js")));
|
|
2035
|
+
const i18next_http_backend_1 = (cov_ogldeftyv().s[6]++, __importDefault(__webpack_require__(/*! i18next-http-backend */ "../../common/temp/node_modules/.pnpm/i18next-http-backend@3.0.6/node_modules/i18next-http-backend/esm/index.js")));
|
|
2036
|
+
const core_bentley_1 = (cov_ogldeftyv().s[7]++, __webpack_require__(/*! @itwin/core-bentley */ "../bentley/lib/esm/core-bentley.js"));
|
|
2037
|
+
const DEFAULT_MAX_RETRIES = (cov_ogldeftyv().s[8]++, 1); // a low number prevents wasted time and potential timeouts when requesting localization files throws an error
|
|
2163
2038
|
/** Supplies localizations for iTwin.js
|
|
2164
2039
|
* @note this class uses the [i18next](https://www.i18next.com/) package.
|
|
2165
2040
|
* @public
|
|
@@ -2169,25 +2044,25 @@ class ITwinLocalization {
|
|
|
2169
2044
|
_initOptions;
|
|
2170
2045
|
_backendOptions;
|
|
2171
2046
|
_detectionOptions;
|
|
2172
|
-
_namespaces = (
|
|
2047
|
+
_namespaces = (cov_ogldeftyv().s[9]++, new Map());
|
|
2173
2048
|
constructor(options) {
|
|
2174
|
-
|
|
2175
|
-
|
|
2049
|
+
cov_ogldeftyv().f[1]++;
|
|
2050
|
+
cov_ogldeftyv().s[10]++;
|
|
2176
2051
|
this.i18next = i18next_1.default.createInstance();
|
|
2177
|
-
|
|
2052
|
+
cov_ogldeftyv().s[11]++;
|
|
2178
2053
|
this._backendOptions = {
|
|
2179
|
-
loadPath: (
|
|
2054
|
+
loadPath: (cov_ogldeftyv().b[3][0]++, options?.urlTemplate) ?? (cov_ogldeftyv().b[3][1]++, "locales/{{lng}}/{{ns}}.json"),
|
|
2180
2055
|
crossDomain: true,
|
|
2181
2056
|
...options?.backendHttpOptions
|
|
2182
2057
|
};
|
|
2183
|
-
|
|
2058
|
+
cov_ogldeftyv().s[12]++;
|
|
2184
2059
|
this._detectionOptions = {
|
|
2185
2060
|
order: ["querystring", "navigator", "htmlTag"],
|
|
2186
2061
|
lookupQuerystring: "lng",
|
|
2187
2062
|
caches: [],
|
|
2188
2063
|
...options?.detectorOptions
|
|
2189
2064
|
};
|
|
2190
|
-
|
|
2065
|
+
cov_ogldeftyv().s[13]++;
|
|
2191
2066
|
this._initOptions = {
|
|
2192
2067
|
interpolation: {
|
|
2193
2068
|
escapeValue: true
|
|
@@ -2198,41 +2073,41 @@ class ITwinLocalization {
|
|
|
2198
2073
|
detection: this._detectionOptions,
|
|
2199
2074
|
...options?.initOptions
|
|
2200
2075
|
};
|
|
2201
|
-
|
|
2202
|
-
this.i18next.use((
|
|
2076
|
+
cov_ogldeftyv().s[14]++;
|
|
2077
|
+
this.i18next.use((cov_ogldeftyv().b[4][0]++, options?.detectorPlugin) ?? (cov_ogldeftyv().b[4][1]++, i18next_browser_languagedetector_1.default)).use((cov_ogldeftyv().b[5][0]++, options?.backendPlugin) ?? (cov_ogldeftyv().b[5][1]++, i18next_http_backend_1.default)).use(TranslationLogger);
|
|
2203
2078
|
}
|
|
2204
2079
|
async initialize(namespaces) {
|
|
2205
|
-
|
|
2080
|
+
cov_ogldeftyv().f[2]++;
|
|
2206
2081
|
// Also consider namespaces passed into constructor
|
|
2207
|
-
const initNamespaces = (
|
|
2208
|
-
const combinedNamespaces = (
|
|
2209
|
-
const defaultNamespace = (
|
|
2210
|
-
|
|
2082
|
+
const initNamespaces = (cov_ogldeftyv().s[15]++, [(cov_ogldeftyv().b[6][0]++, this._initOptions.ns) || (cov_ogldeftyv().b[6][1]++, [])].flat());
|
|
2083
|
+
const combinedNamespaces = (cov_ogldeftyv().s[16]++, new Set([...namespaces, ...initNamespaces])); // without duplicates
|
|
2084
|
+
const defaultNamespace = (cov_ogldeftyv().s[17]++, (cov_ogldeftyv().b[7][0]++, this._initOptions.defaultNS) ?? (cov_ogldeftyv().b[7][1]++, namespaces[0]));
|
|
2085
|
+
cov_ogldeftyv().s[18]++;
|
|
2211
2086
|
if (defaultNamespace) {
|
|
2212
|
-
|
|
2213
|
-
|
|
2087
|
+
cov_ogldeftyv().b[8][0]++;
|
|
2088
|
+
cov_ogldeftyv().s[19]++;
|
|
2214
2089
|
combinedNamespaces.add(defaultNamespace);
|
|
2215
2090
|
} else {
|
|
2216
|
-
|
|
2091
|
+
cov_ogldeftyv().b[8][1]++;
|
|
2217
2092
|
} // Make sure default namespace is in namespaces list
|
|
2218
|
-
const initOptions = (
|
|
2093
|
+
const initOptions = (cov_ogldeftyv().s[20]++, {
|
|
2219
2094
|
...this._initOptions,
|
|
2220
2095
|
defaultNS: defaultNamespace,
|
|
2221
2096
|
ns: [...combinedNamespaces]
|
|
2222
2097
|
});
|
|
2223
2098
|
// if in a development environment, set debugging
|
|
2224
|
-
|
|
2099
|
+
cov_ogldeftyv().s[21]++;
|
|
2225
2100
|
if (false) // removed by dead control flow
|
|
2226
2101
|
{} else {
|
|
2227
|
-
|
|
2102
|
+
cov_ogldeftyv().b[9][1]++;
|
|
2228
2103
|
}
|
|
2229
|
-
const initPromise = (
|
|
2230
|
-
|
|
2104
|
+
const initPromise = (cov_ogldeftyv().s[23]++, this.i18next.init(initOptions));
|
|
2105
|
+
cov_ogldeftyv().s[24]++;
|
|
2231
2106
|
for (const ns of namespaces) {
|
|
2232
|
-
|
|
2107
|
+
cov_ogldeftyv().s[25]++;
|
|
2233
2108
|
this._namespaces.set(ns, initPromise);
|
|
2234
2109
|
}
|
|
2235
|
-
|
|
2110
|
+
cov_ogldeftyv().s[26]++;
|
|
2236
2111
|
return initPromise;
|
|
2237
2112
|
}
|
|
2238
2113
|
/** Replace all instances of `%{key}` within a string with the translations of those keys.
|
|
@@ -2252,11 +2127,11 @@ class ITwinLocalization {
|
|
|
2252
2127
|
* @public
|
|
2253
2128
|
*/
|
|
2254
2129
|
getLocalizedKeys(line) {
|
|
2255
|
-
|
|
2256
|
-
|
|
2130
|
+
cov_ogldeftyv().f[3]++;
|
|
2131
|
+
cov_ogldeftyv().s[27]++;
|
|
2257
2132
|
return line.replace(/\%\{(.+?)\}/g, (_match, tag) => {
|
|
2258
|
-
|
|
2259
|
-
|
|
2133
|
+
cov_ogldeftyv().f[4]++;
|
|
2134
|
+
cov_ogldeftyv().s[28]++;
|
|
2260
2135
|
return this.getLocalizedString(tag);
|
|
2261
2136
|
});
|
|
2262
2137
|
}
|
|
@@ -2274,25 +2149,25 @@ class ITwinLocalization {
|
|
|
2274
2149
|
* @public
|
|
2275
2150
|
*/
|
|
2276
2151
|
getLocalizedString(key, options) {
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
if ((
|
|
2280
|
-
|
|
2281
|
-
|
|
2152
|
+
cov_ogldeftyv().f[5]++;
|
|
2153
|
+
cov_ogldeftyv().s[29]++;
|
|
2154
|
+
if ((cov_ogldeftyv().b[11][0]++, options?.returnDetails) || (cov_ogldeftyv().b[11][1]++, options?.returnObjects)) {
|
|
2155
|
+
cov_ogldeftyv().b[10][0]++;
|
|
2156
|
+
cov_ogldeftyv().s[30]++;
|
|
2282
2157
|
throw new Error("Translation key must map to a string, but the given options will result in an object");
|
|
2283
2158
|
} else {
|
|
2284
|
-
|
|
2159
|
+
cov_ogldeftyv().b[10][1]++;
|
|
2285
2160
|
}
|
|
2286
|
-
const value = (
|
|
2287
|
-
|
|
2161
|
+
const value = (cov_ogldeftyv().s[31]++, this.i18next.t(key, options));
|
|
2162
|
+
cov_ogldeftyv().s[32]++;
|
|
2288
2163
|
if (typeof value !== "string") {
|
|
2289
|
-
|
|
2290
|
-
|
|
2164
|
+
cov_ogldeftyv().b[12][0]++;
|
|
2165
|
+
cov_ogldeftyv().s[33]++;
|
|
2291
2166
|
throw new Error("Translation key(s) string not found");
|
|
2292
2167
|
} else {
|
|
2293
|
-
|
|
2168
|
+
cov_ogldeftyv().b[12][1]++;
|
|
2294
2169
|
}
|
|
2295
|
-
|
|
2170
|
+
cov_ogldeftyv().s[34]++;
|
|
2296
2171
|
return value;
|
|
2297
2172
|
}
|
|
2298
2173
|
/** Gets the English translation.
|
|
@@ -2303,31 +2178,31 @@ class ITwinLocalization {
|
|
|
2303
2178
|
* @internal
|
|
2304
2179
|
*/
|
|
2305
2180
|
getEnglishString(namespace, key, options) {
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
if ((
|
|
2309
|
-
|
|
2310
|
-
|
|
2181
|
+
cov_ogldeftyv().f[6]++;
|
|
2182
|
+
cov_ogldeftyv().s[35]++;
|
|
2183
|
+
if ((cov_ogldeftyv().b[14][0]++, options?.returnDetails) || (cov_ogldeftyv().b[14][1]++, options?.returnObjects)) {
|
|
2184
|
+
cov_ogldeftyv().b[13][0]++;
|
|
2185
|
+
cov_ogldeftyv().s[36]++;
|
|
2311
2186
|
throw new Error("Translation key must map to a string, but the given options will result in an object");
|
|
2312
2187
|
} else {
|
|
2313
|
-
|
|
2188
|
+
cov_ogldeftyv().b[13][1]++;
|
|
2314
2189
|
}
|
|
2315
|
-
|
|
2190
|
+
cov_ogldeftyv().s[37]++;
|
|
2316
2191
|
options = {
|
|
2317
2192
|
...options,
|
|
2318
2193
|
ns: namespace // ensure namespace argument is used
|
|
2319
2194
|
};
|
|
2320
|
-
const en = (
|
|
2321
|
-
const str = (
|
|
2322
|
-
|
|
2195
|
+
const en = (cov_ogldeftyv().s[38]++, this.i18next.getFixedT("en", namespace));
|
|
2196
|
+
const str = (cov_ogldeftyv().s[39]++, en(key, options));
|
|
2197
|
+
cov_ogldeftyv().s[40]++;
|
|
2323
2198
|
if (typeof str !== "string") {
|
|
2324
|
-
|
|
2325
|
-
|
|
2199
|
+
cov_ogldeftyv().b[15][0]++;
|
|
2200
|
+
cov_ogldeftyv().s[41]++;
|
|
2326
2201
|
throw new Error("Translation key(s) not found");
|
|
2327
2202
|
} else {
|
|
2328
|
-
|
|
2203
|
+
cov_ogldeftyv().b[15][1]++;
|
|
2329
2204
|
}
|
|
2330
|
-
|
|
2205
|
+
cov_ogldeftyv().s[42]++;
|
|
2331
2206
|
return str;
|
|
2332
2207
|
}
|
|
2333
2208
|
/** Get the promise for an already registered Namespace.
|
|
@@ -2335,20 +2210,20 @@ class ITwinLocalization {
|
|
|
2335
2210
|
* @public
|
|
2336
2211
|
*/
|
|
2337
2212
|
getNamespacePromise(name) {
|
|
2338
|
-
|
|
2339
|
-
|
|
2213
|
+
cov_ogldeftyv().f[7]++;
|
|
2214
|
+
cov_ogldeftyv().s[43]++;
|
|
2340
2215
|
return this._namespaces.get(name);
|
|
2341
2216
|
}
|
|
2342
2217
|
/** @internal */
|
|
2343
2218
|
getLanguageList() {
|
|
2344
|
-
|
|
2345
|
-
|
|
2219
|
+
cov_ogldeftyv().f[8]++;
|
|
2220
|
+
cov_ogldeftyv().s[44]++;
|
|
2346
2221
|
return this.i18next.languages;
|
|
2347
2222
|
}
|
|
2348
2223
|
/** override the language detected in the browser */
|
|
2349
2224
|
async changeLanguage(language) {
|
|
2350
|
-
|
|
2351
|
-
|
|
2225
|
+
cov_ogldeftyv().f[9]++;
|
|
2226
|
+
cov_ogldeftyv().s[45]++;
|
|
2352
2227
|
return this.i18next.changeLanguage(language);
|
|
2353
2228
|
}
|
|
2354
2229
|
/** Register a new Namespace and return it. If the namespace is already registered, it will be returned.
|
|
@@ -2360,120 +2235,94 @@ class ITwinLocalization {
|
|
|
2360
2235
|
* @public
|
|
2361
2236
|
*/
|
|
2362
2237
|
async registerNamespace(name) {
|
|
2363
|
-
|
|
2364
|
-
const existing = (
|
|
2365
|
-
|
|
2238
|
+
cov_ogldeftyv().f[10]++;
|
|
2239
|
+
const existing = (cov_ogldeftyv().s[46]++, this._namespaces.get(name));
|
|
2240
|
+
cov_ogldeftyv().s[47]++;
|
|
2366
2241
|
if (existing !== undefined) {
|
|
2367
|
-
|
|
2368
|
-
|
|
2242
|
+
cov_ogldeftyv().b[16][0]++;
|
|
2243
|
+
cov_ogldeftyv().s[48]++;
|
|
2369
2244
|
return existing;
|
|
2370
2245
|
} else {
|
|
2371
|
-
|
|
2246
|
+
cov_ogldeftyv().b[16][1]++;
|
|
2372
2247
|
}
|
|
2373
|
-
const theReadPromise = (
|
|
2374
|
-
|
|
2375
|
-
|
|
2248
|
+
const theReadPromise = (cov_ogldeftyv().s[49]++, new Promise(resolve => {
|
|
2249
|
+
cov_ogldeftyv().f[11]++;
|
|
2250
|
+
cov_ogldeftyv().s[50]++;
|
|
2376
2251
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
2377
2252
|
this.i18next.loadNamespaces(name, err => {
|
|
2378
|
-
|
|
2379
|
-
|
|
2253
|
+
cov_ogldeftyv().f[12]++;
|
|
2254
|
+
cov_ogldeftyv().s[51]++;
|
|
2380
2255
|
if (!err) {
|
|
2381
|
-
|
|
2382
|
-
|
|
2256
|
+
cov_ogldeftyv().b[17][0]++;
|
|
2257
|
+
cov_ogldeftyv().s[52]++;
|
|
2383
2258
|
return resolve();
|
|
2384
2259
|
} else {
|
|
2385
|
-
|
|
2386
|
-
}
|
|
2387
|
-
//
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
let locales = (cov_1wctd2lw3r().s[53]++, this.getLanguageList().map(thisLocale => {
|
|
2393
|
-
cov_1wctd2lw3r().f[13]++;
|
|
2394
|
-
cov_1wctd2lw3r().s[54]++;
|
|
2395
|
-
return `/${thisLocale}/`;
|
|
2260
|
+
cov_ogldeftyv().b[17][1]++;
|
|
2261
|
+
}
|
|
2262
|
+
// i18next can return errors from other concurrent namespace loads in this callback.
|
|
2263
|
+
const wasLoaded = (cov_ogldeftyv().s[53]++, this.getLanguageList().some(language => {
|
|
2264
|
+
cov_ogldeftyv().f[13]++;
|
|
2265
|
+
cov_ogldeftyv().s[54]++;
|
|
2266
|
+
return this.i18next.hasResourceBundle(language, name);
|
|
2396
2267
|
}));
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
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]++;
|
|
2268
|
+
cov_ogldeftyv().s[55]++;
|
|
2269
|
+
if (!wasLoaded) {
|
|
2270
|
+
cov_ogldeftyv().b[18][0]++;
|
|
2271
|
+
cov_ogldeftyv().s[56]++;
|
|
2423
2272
|
core_bentley_1.Logger.logError("i18n", `No resources for namespace ${name} could be loaded`);
|
|
2424
2273
|
} else {
|
|
2425
|
-
|
|
2274
|
+
cov_ogldeftyv().b[18][1]++;
|
|
2426
2275
|
}
|
|
2427
|
-
|
|
2276
|
+
cov_ogldeftyv().s[57]++;
|
|
2428
2277
|
resolve();
|
|
2429
2278
|
});
|
|
2430
2279
|
}));
|
|
2431
|
-
|
|
2280
|
+
cov_ogldeftyv().s[58]++;
|
|
2432
2281
|
this._namespaces.set(name, theReadPromise);
|
|
2433
|
-
|
|
2282
|
+
cov_ogldeftyv().s[59]++;
|
|
2434
2283
|
return theReadPromise;
|
|
2435
2284
|
}
|
|
2436
2285
|
/** @internal */
|
|
2437
2286
|
unregisterNamespace(name) {
|
|
2438
|
-
|
|
2439
|
-
|
|
2287
|
+
cov_ogldeftyv().f[14]++;
|
|
2288
|
+
cov_ogldeftyv().s[60]++;
|
|
2440
2289
|
this._namespaces.delete(name);
|
|
2441
2290
|
}
|
|
2442
2291
|
}
|
|
2443
|
-
|
|
2292
|
+
cov_ogldeftyv().s[61]++;
|
|
2444
2293
|
exports.ITwinLocalization = ITwinLocalization;
|
|
2445
2294
|
class TranslationLogger {
|
|
2446
|
-
static type = (
|
|
2295
|
+
static type = (cov_ogldeftyv().s[62]++, "logger");
|
|
2447
2296
|
log(args) {
|
|
2448
|
-
|
|
2449
|
-
|
|
2297
|
+
cov_ogldeftyv().f[15]++;
|
|
2298
|
+
cov_ogldeftyv().s[63]++;
|
|
2450
2299
|
core_bentley_1.Logger.logInfo("i18n", this.createLogMessage(args));
|
|
2451
2300
|
}
|
|
2452
2301
|
warn(args) {
|
|
2453
|
-
|
|
2454
|
-
|
|
2302
|
+
cov_ogldeftyv().f[16]++;
|
|
2303
|
+
cov_ogldeftyv().s[64]++;
|
|
2455
2304
|
core_bentley_1.Logger.logWarning("i18n", this.createLogMessage(args));
|
|
2456
2305
|
}
|
|
2457
2306
|
error(args) {
|
|
2458
|
-
|
|
2459
|
-
|
|
2307
|
+
cov_ogldeftyv().f[17]++;
|
|
2308
|
+
cov_ogldeftyv().s[65]++;
|
|
2460
2309
|
core_bentley_1.Logger.logError("i18n", this.createLogMessage(args));
|
|
2461
2310
|
}
|
|
2462
2311
|
createLogMessage(args) {
|
|
2463
|
-
|
|
2464
|
-
let message = (
|
|
2465
|
-
|
|
2466
|
-
for (let i = (
|
|
2467
|
-
|
|
2312
|
+
cov_ogldeftyv().f[18]++;
|
|
2313
|
+
let message = (cov_ogldeftyv().s[66]++, args[0]);
|
|
2314
|
+
cov_ogldeftyv().s[67]++;
|
|
2315
|
+
for (let i = (cov_ogldeftyv().s[68]++, 1); i < args.length; ++i) {
|
|
2316
|
+
cov_ogldeftyv().s[69]++;
|
|
2468
2317
|
if (typeof args[i] === "string") {
|
|
2469
|
-
|
|
2470
|
-
|
|
2318
|
+
cov_ogldeftyv().b[19][0]++;
|
|
2319
|
+
cov_ogldeftyv().s[70]++;
|
|
2471
2320
|
message += `\n ${args[i]}`;
|
|
2472
2321
|
} else {
|
|
2473
|
-
|
|
2322
|
+
cov_ogldeftyv().b[19][1]++;
|
|
2474
2323
|
}
|
|
2475
2324
|
}
|
|
2476
|
-
|
|
2325
|
+
cov_ogldeftyv().s[71]++;
|
|
2477
2326
|
return message;
|
|
2478
2327
|
}
|
|
2479
2328
|
}
|
|
@@ -25687,10 +25536,9 @@ function interpolateUrl(str, data) {
|
|
|
25687
25536
|
/******/ // This file contains only the entry chunk.
|
|
25688
25537
|
/******/ // The chunk loading function for additional chunks
|
|
25689
25538
|
/******/ __webpack_require__.e = (chunkId) => {
|
|
25690
|
-
/******/
|
|
25691
|
-
/******/
|
|
25692
|
-
/******/
|
|
25693
|
-
/******/ }, []));
|
|
25539
|
+
/******/ const promises = [];
|
|
25540
|
+
/******/ __webpack_require__.f.j(chunkId, promises);
|
|
25541
|
+
/******/ return Promise.all(promises);
|
|
25694
25542
|
/******/ };
|
|
25695
25543
|
/******/
|
|
25696
25544
|
/******/ /* webpack/runtime/get javascript chunk filename */
|
|
@@ -25890,6 +25738,7 @@ let exports = __webpack_exports__;
|
|
|
25890
25738
|
*--------------------------------------------------------------------------------------------*/
|
|
25891
25739
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
25892
25740
|
const chai_1 = __webpack_require__(/*! chai */ "../../common/temp/node_modules/.pnpm/chai@4.5.0/node_modules/chai/index.js");
|
|
25741
|
+
const core_bentley_1 = __webpack_require__(/*! @itwin/core-bentley */ "../bentley/lib/esm/core-bentley.js");
|
|
25893
25742
|
const ITwinLocalization_1 = __webpack_require__(/*! ../ITwinLocalization */ "./lib/cjs/ITwinLocalization.js");
|
|
25894
25743
|
describe("ITwinLocalization", () => {
|
|
25895
25744
|
let localization;
|
|
@@ -26756,6 +26605,65 @@ describe("ITwinLocalization", () => {
|
|
|
26756
26605
|
chai_1.assert.isTrue(itwinLocalization.i18next.hasLoadedNamespace("Test"));
|
|
26757
26606
|
chai_1.assert.equal(itwinLocalization.getLocalizedString("Test:FirstTrivial"), "First level string (test)");
|
|
26758
26607
|
});
|
|
26608
|
+
it("attributes errors from concurrent namespace loads to the namespace that failed", async () => {
|
|
26609
|
+
const pendingLoads = new Map();
|
|
26610
|
+
const backend = {
|
|
26611
|
+
type: "backend",
|
|
26612
|
+
init: () => { },
|
|
26613
|
+
read: (_language, namespace, callback) => pendingLoads.set(namespace, callback),
|
|
26614
|
+
};
|
|
26615
|
+
itwinLocalization = new ITwinLocalization_1.ITwinLocalization({
|
|
26616
|
+
backendPlugin: backend,
|
|
26617
|
+
initOptions: { lng: "en", fallbackLng: false },
|
|
26618
|
+
});
|
|
26619
|
+
await itwinLocalization.initialize([]);
|
|
26620
|
+
const loggedErrors = [];
|
|
26621
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method -- Preserve the exact method reference so the test can restore it.
|
|
26622
|
+
const originalLogError = core_bentley_1.Logger.logError;
|
|
26623
|
+
core_bentley_1.Logger.logError = (_category, message) => loggedErrors.push(String(message));
|
|
26624
|
+
try {
|
|
26625
|
+
const loadedPromise = itwinLocalization.registerNamespace("Loaded");
|
|
26626
|
+
const missingPromise = itwinLocalization.registerNamespace("Missing");
|
|
26627
|
+
chai_1.assert.sameMembers([...pendingLoads.keys()], ["Loaded", "Missing"]);
|
|
26628
|
+
pendingLoads.get("Missing")?.(new Error("Missing namespace"), false);
|
|
26629
|
+
pendingLoads.get("Loaded")?.(null, { key: "value" });
|
|
26630
|
+
await Promise.all([missingPromise, loadedPromise]);
|
|
26631
|
+
chai_1.assert.deepEqual(loggedErrors, ["No resources for namespace Missing could be loaded"]);
|
|
26632
|
+
chai_1.assert.isTrue(itwinLocalization.i18next.hasResourceBundle("en", "Loaded"));
|
|
26633
|
+
}
|
|
26634
|
+
finally {
|
|
26635
|
+
core_bentley_1.Logger.logError = originalLogError;
|
|
26636
|
+
}
|
|
26637
|
+
});
|
|
26638
|
+
it("does not log an error when a namespace loads from a fallback language", async () => {
|
|
26639
|
+
const pendingLoads = new Map();
|
|
26640
|
+
const backend = {
|
|
26641
|
+
type: "backend",
|
|
26642
|
+
init: () => { },
|
|
26643
|
+
read: (language, namespace, callback) => pendingLoads.set(`${language}/${namespace}`, callback),
|
|
26644
|
+
};
|
|
26645
|
+
itwinLocalization = new ITwinLocalization_1.ITwinLocalization({
|
|
26646
|
+
backendPlugin: backend,
|
|
26647
|
+
initOptions: { lng: "fr", fallbackLng: "en" },
|
|
26648
|
+
});
|
|
26649
|
+
await itwinLocalization.initialize([]);
|
|
26650
|
+
const loggedErrors = [];
|
|
26651
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method -- Preserve the exact method reference so the test can restore it.
|
|
26652
|
+
const originalLogError = core_bentley_1.Logger.logError;
|
|
26653
|
+
core_bentley_1.Logger.logError = (_category, message) => loggedErrors.push(String(message));
|
|
26654
|
+
try {
|
|
26655
|
+
const loadPromise = itwinLocalization.registerNamespace("Fallback");
|
|
26656
|
+
chai_1.assert.sameMembers([...pendingLoads.keys()], ["fr/Fallback", "en/Fallback"]);
|
|
26657
|
+
pendingLoads.get("fr/Fallback")?.(new Error("Missing French namespace"), false);
|
|
26658
|
+
pendingLoads.get("en/Fallback")?.(null, { key: "value" });
|
|
26659
|
+
await loadPromise;
|
|
26660
|
+
chai_1.assert.isEmpty(loggedErrors);
|
|
26661
|
+
chai_1.assert.isTrue(itwinLocalization.i18next.hasResourceBundle("en", "Fallback"));
|
|
26662
|
+
}
|
|
26663
|
+
finally {
|
|
26664
|
+
core_bentley_1.Logger.logError = originalLogError;
|
|
26665
|
+
}
|
|
26666
|
+
});
|
|
26759
26667
|
});
|
|
26760
26668
|
// unregisterNamespace() isn't used and basically does nothing
|
|
26761
26669
|
// describe("#unregisterNamespace", () => {
|