@brightspace-ui/core 2.53.0 → 2.54.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.
@@ -167,6 +167,10 @@
167
167
  "description": "Type of the alert being displayed",
168
168
  "type": "'default'|'critical'|'success'|'warning'",
169
169
  "default": "\"default\""
170
+ },
171
+ {
172
+ "name": "documentLocaleSettings",
173
+ "default": "\"getDocumentLocaleSettings()\""
170
174
  }
171
175
  ],
172
176
  "events": [
@@ -326,6 +330,10 @@
326
330
  "description": "Renders in compact mode, displaying only the last item",
327
331
  "type": "boolean",
328
332
  "default": "false"
333
+ },
334
+ {
335
+ "name": "documentLocaleSettings",
336
+ "default": "\"getDocumentLocaleSettings()\""
329
337
  }
330
338
  ],
331
339
  "slots": [
@@ -691,6 +699,10 @@
691
699
  "attribute": "summary",
692
700
  "description": "Summary of the calendar for accessibility",
693
701
  "type": "string"
702
+ },
703
+ {
704
+ "name": "documentLocaleSettings",
705
+ "default": "\"getDocumentLocaleSettings()\""
694
706
  }
695
707
  ],
696
708
  "events": [
@@ -1198,6 +1210,10 @@
1198
1210
  "type": "'count'|'notification'",
1199
1211
  "default": "\"count\""
1200
1212
  },
1213
+ {
1214
+ "name": "documentLocaleSettings",
1215
+ "default": "\"getDocumentLocaleSettings()\""
1216
+ },
1201
1217
  {
1202
1218
  "name": "skeleton",
1203
1219
  "attribute": "skeleton",
@@ -1345,6 +1361,10 @@
1345
1361
  "type": "'count'|'notification'",
1346
1362
  "default": "\"count\""
1347
1363
  },
1364
+ {
1365
+ "name": "documentLocaleSettings",
1366
+ "default": "\"getDocumentLocaleSettings()\""
1367
+ },
1348
1368
  {
1349
1369
  "name": "skeleton",
1350
1370
  "attribute": "skeleton",
@@ -1628,6 +1648,10 @@
1628
1648
  "type": "boolean",
1629
1649
  "default": "false"
1630
1650
  },
1651
+ {
1652
+ "name": "documentLocaleSettings",
1653
+ "default": "\"getDocumentLocaleSettings()\""
1654
+ },
1631
1655
  {
1632
1656
  "name": "asyncContainerCustom",
1633
1657
  "type": "boolean"
@@ -1733,6 +1757,10 @@
1733
1757
  "type": "number",
1734
1758
  "default": "600"
1735
1759
  },
1760
+ {
1761
+ "name": "documentLocaleSettings",
1762
+ "default": "\"getDocumentLocaleSettings()\""
1763
+ },
1736
1764
  {
1737
1765
  "name": "asyncContainerCustom",
1738
1766
  "type": "boolean"
@@ -2213,6 +2241,10 @@
2213
2241
  "description": "Optionally render a d2l-focus-trap around the dropdown content",
2214
2242
  "type": "boolean",
2215
2243
  "default": "false"
2244
+ },
2245
+ {
2246
+ "name": "documentLocaleSettings",
2247
+ "default": "\"getDocumentLocaleSettings()\""
2216
2248
  }
2217
2249
  ],
2218
2250
  "events": [
@@ -2582,6 +2614,10 @@
2582
2614
  "description": "Optionally render a d2l-focus-trap around the dropdown content",
2583
2615
  "type": "boolean",
2584
2616
  "default": "false"
2617
+ },
2618
+ {
2619
+ "name": "documentLocaleSettings",
2620
+ "default": "\"getDocumentLocaleSettings()\""
2585
2621
  }
2586
2622
  ],
2587
2623
  "events": [
@@ -2951,6 +2987,10 @@
2951
2987
  "description": "Optionally render a d2l-focus-trap around the dropdown content",
2952
2988
  "type": "boolean",
2953
2989
  "default": "false"
2990
+ },
2991
+ {
2992
+ "name": "documentLocaleSettings",
2993
+ "default": "\"getDocumentLocaleSettings()\""
2954
2994
  }
2955
2995
  ],
2956
2996
  "events": [
@@ -3479,6 +3519,10 @@
3479
3519
  "name": "openerType",
3480
3520
  "type": "string",
3481
3521
  "default": "\"DEFAULT\""
3522
+ },
3523
+ {
3524
+ "name": "documentLocaleSettings",
3525
+ "default": "\"getDocumentLocaleSettings()\""
3482
3526
  }
3483
3527
  ],
3484
3528
  "events": [
@@ -3523,6 +3567,10 @@
3523
3567
  "description": "The text displayed in this component's label (hidden when default is used)",
3524
3568
  "type": "string",
3525
3569
  "default": "\"\\\"Active Filters:\\\"\""
3570
+ },
3571
+ {
3572
+ "name": "documentLocaleSettings",
3573
+ "default": "\"getDocumentLocaleSettings()\""
3526
3574
  }
3527
3575
  ]
3528
3576
  },
@@ -3569,6 +3617,10 @@
3569
3617
  "description": "Indicates if the filter is open",
3570
3618
  "type": "boolean",
3571
3619
  "default": "false"
3620
+ },
3621
+ {
3622
+ "name": "documentLocaleSettings",
3623
+ "default": "\"getDocumentLocaleSettings()\""
3572
3624
  }
3573
3625
  ],
3574
3626
  "events": [
@@ -3644,6 +3696,10 @@
3644
3696
  "name": "errors",
3645
3697
  "type": "object",
3646
3698
  "default": "[]"
3699
+ },
3700
+ {
3701
+ "name": "documentLocaleSettings",
3702
+ "default": "\"getDocumentLocaleSettings()\""
3647
3703
  }
3648
3704
  ]
3649
3705
  },
@@ -3718,6 +3774,10 @@
3718
3774
  "description": "Indicates that the form should interrupt and warn on navigation if the user has unsaved changes on native elements.",
3719
3775
  "type": "boolean",
3720
3776
  "default": "false"
3777
+ },
3778
+ {
3779
+ "name": "documentLocaleSettings",
3780
+ "default": "\"getDocumentLocaleSettings()\""
3721
3781
  }
3722
3782
  ],
3723
3783
  "events": [
@@ -3771,6 +3831,10 @@
3771
3831
  "description": "Indicates that the form should interrupt and warn on navigation if the user has unsaved changes on native elements.",
3772
3832
  "type": "boolean",
3773
3833
  "default": "false"
3834
+ },
3835
+ {
3836
+ "name": "documentLocaleSettings",
3837
+ "default": "\"getDocumentLocaleSettings()\""
3774
3838
  }
3775
3839
  ],
3776
3840
  "events": [
@@ -3851,6 +3915,10 @@
3851
3915
  "attribute": "name",
3852
3916
  "description": "Name of the form control. Submitted with the form as part of a name/value pair.",
3853
3917
  "type": "string"
3918
+ },
3919
+ {
3920
+ "name": "documentLocaleSettings",
3921
+ "default": "\"getDocumentLocaleSettings()\""
3854
3922
  }
3855
3923
  ]
3856
3924
  },
@@ -4453,6 +4521,10 @@
4453
4521
  "attribute": "name",
4454
4522
  "description": "Name of the form control. Submitted with the form as part of a name/value pair.",
4455
4523
  "type": "string"
4524
+ },
4525
+ {
4526
+ "name": "documentLocaleSettings",
4527
+ "default": "\"getDocumentLocaleSettings()\""
4456
4528
  }
4457
4529
  ],
4458
4530
  "events": [
@@ -4519,6 +4591,10 @@
4519
4591
  "description": "Renders the input as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton)",
4520
4592
  "type": "boolean",
4521
4593
  "default": "false"
4594
+ },
4595
+ {
4596
+ "name": "documentLocaleSettings",
4597
+ "default": "\"getDocumentLocaleSettings()\""
4522
4598
  }
4523
4599
  ]
4524
4600
  },
@@ -4750,6 +4826,10 @@
4750
4826
  "attribute": "name",
4751
4827
  "description": "Name of the form control. Submitted with the form as part of a name/value pair.",
4752
4828
  "type": "string"
4829
+ },
4830
+ {
4831
+ "name": "documentLocaleSettings",
4832
+ "default": "\"getDocumentLocaleSettings()\""
4753
4833
  }
4754
4834
  ],
4755
4835
  "events": [
@@ -4937,6 +5017,10 @@
4937
5017
  "attribute": "name",
4938
5018
  "description": "Name of the form control. Submitted with the form as part of a name/value pair.",
4939
5019
  "type": "string"
5020
+ },
5021
+ {
5022
+ "name": "documentLocaleSettings",
5023
+ "default": "\"getDocumentLocaleSettings()\""
4940
5024
  }
4941
5025
  ],
4942
5026
  "events": [
@@ -5103,6 +5187,10 @@
5103
5187
  "attribute": "name",
5104
5188
  "description": "Name of the form control. Submitted with the form as part of a name/value pair.",
5105
5189
  "type": "string"
5190
+ },
5191
+ {
5192
+ "name": "documentLocaleSettings",
5193
+ "default": "\"getDocumentLocaleSettings()\""
5106
5194
  }
5107
5195
  ],
5108
5196
  "events": [
@@ -5443,6 +5531,10 @@
5443
5531
  "attribute": "name",
5444
5532
  "description": "Name of the form control. Submitted with the form as part of a name/value pair.",
5445
5533
  "type": "string"
5534
+ },
5535
+ {
5536
+ "name": "documentLocaleSettings",
5537
+ "default": "\"getDocumentLocaleSettings()\""
5446
5538
  }
5447
5539
  ],
5448
5540
  "events": [
@@ -5641,6 +5733,10 @@
5641
5733
  "attribute": "name",
5642
5734
  "description": "Name of the form control. Submitted with the form as part of a name/value pair.",
5643
5735
  "type": "string"
5736
+ },
5737
+ {
5738
+ "name": "documentLocaleSettings",
5739
+ "default": "\"getDocumentLocaleSettings()\""
5644
5740
  }
5645
5741
  ],
5646
5742
  "events": [
@@ -5749,6 +5845,10 @@
5749
5845
  "description": "Value of the input",
5750
5846
  "type": "string",
5751
5847
  "default": "\"\""
5848
+ },
5849
+ {
5850
+ "name": "documentLocaleSettings",
5851
+ "default": "\"getDocumentLocaleSettings()\""
5752
5852
  }
5753
5853
  ],
5754
5854
  "events": [
@@ -6111,6 +6211,10 @@
6111
6211
  "description": "Name of the form control. Submitted with the form as part of a name/value pair.",
6112
6212
  "type": "string"
6113
6213
  },
6214
+ {
6215
+ "name": "documentLocaleSettings",
6216
+ "default": "\"getDocumentLocaleSettings()\""
6217
+ },
6114
6218
  {
6115
6219
  "name": "skeleton",
6116
6220
  "attribute": "skeleton",
@@ -6350,6 +6454,10 @@
6350
6454
  "description": "Name of the form control. Submitted with the form as part of a name/value pair.",
6351
6455
  "type": "string"
6352
6456
  },
6457
+ {
6458
+ "name": "documentLocaleSettings",
6459
+ "default": "\"getDocumentLocaleSettings()\""
6460
+ },
6353
6461
  {
6354
6462
  "name": "skeleton",
6355
6463
  "attribute": "skeleton",
@@ -6588,6 +6696,10 @@
6588
6696
  "attribute": "name",
6589
6697
  "description": "Name of the form control. Submitted with the form as part of a name/value pair.",
6590
6698
  "type": "string"
6699
+ },
6700
+ {
6701
+ "name": "documentLocaleSettings",
6702
+ "default": "\"getDocumentLocaleSettings()\""
6591
6703
  }
6592
6704
  ],
6593
6705
  "events": [
@@ -6765,6 +6877,10 @@
6765
6877
  "attribute": "name",
6766
6878
  "description": "Name of the form control. Submitted with the form as part of a name/value pair.",
6767
6879
  "type": "string"
6880
+ },
6881
+ {
6882
+ "name": "documentLocaleSettings",
6883
+ "default": "\"getDocumentLocaleSettings()\""
6768
6884
  }
6769
6885
  ],
6770
6886
  "events": [
@@ -7063,6 +7179,10 @@
7063
7179
  "type": "'normal'|'none'",
7064
7180
  "default": "\"normal\""
7065
7181
  },
7182
+ {
7183
+ "name": "documentLocaleSettings",
7184
+ "default": "\"getDocumentLocaleSettings()\""
7185
+ },
7066
7186
  {
7067
7187
  "name": "dragHandleText",
7068
7188
  "attribute": "drag-handle-text",
@@ -7200,6 +7320,10 @@
7200
7320
  "description": "Whether all pages can be selected",
7201
7321
  "type": "boolean",
7202
7322
  "default": "false"
7323
+ },
7324
+ {
7325
+ "name": "documentLocaleSettings",
7326
+ "default": "\"getDocumentLocaleSettings()\""
7203
7327
  }
7204
7328
  ],
7205
7329
  "slots": [
@@ -7327,6 +7451,10 @@
7327
7451
  "type": "'normal'|'none'",
7328
7452
  "default": "\"normal\""
7329
7453
  },
7454
+ {
7455
+ "name": "documentLocaleSettings",
7456
+ "default": "\"getDocumentLocaleSettings()\""
7457
+ },
7330
7458
  {
7331
7459
  "name": "dragHandleText",
7332
7460
  "attribute": "drag-handle-text",
@@ -7500,6 +7628,10 @@
7500
7628
  "description": "Disables the handle",
7501
7629
  "type": "boolean",
7502
7630
  "default": "false"
7631
+ },
7632
+ {
7633
+ "name": "documentLocaleSettings",
7634
+ "default": "\"getDocumentLocaleSettings()\""
7503
7635
  }
7504
7636
  ],
7505
7637
  "events": [
@@ -7759,6 +7891,10 @@
7759
7891
  "type": "'normal'|'none'",
7760
7892
  "default": "\"normal\""
7761
7893
  },
7894
+ {
7895
+ "name": "documentLocaleSettings",
7896
+ "default": "\"getDocumentLocaleSettings()\""
7897
+ },
7762
7898
  {
7763
7899
  "name": "dragHandleText",
7764
7900
  "attribute": "drag-handle-text",
@@ -8381,6 +8517,10 @@
8381
8517
  }
8382
8518
  ],
8383
8519
  "properties": [
8520
+ {
8521
+ "name": "documentLocaleSettings",
8522
+ "default": "\"getDocumentLocaleSettings()\""
8523
+ },
8384
8524
  {
8385
8525
  "name": "text",
8386
8526
  "attribute": "text",
@@ -8577,6 +8717,10 @@
8577
8717
  "description": "REQUIRED: Current number of completed units.\nValid values: A number between 0 and max",
8578
8718
  "type": "number",
8579
8719
  "default": "0"
8720
+ },
8721
+ {
8722
+ "name": "documentLocaleSettings",
8723
+ "default": "\"getDocumentLocaleSettings()\""
8580
8724
  }
8581
8725
  ]
8582
8726
  },
@@ -8649,6 +8793,10 @@
8649
8793
  "description": "REQUIRED: Current number of completed units.\nValid values: A number between 0 and max",
8650
8794
  "type": "number",
8651
8795
  "default": "0"
8796
+ },
8797
+ {
8798
+ "name": "documentLocaleSettings",
8799
+ "default": "\"getDocumentLocaleSettings()\""
8652
8800
  }
8653
8801
  ]
8654
8802
  },
@@ -8708,6 +8856,10 @@
8708
8856
  "description": "REQUIRED: Current number of completed units.\nValid values: A number between 0 and max",
8709
8857
  "type": "number",
8710
8858
  "default": "0"
8859
+ },
8860
+ {
8861
+ "name": "documentLocaleSettings",
8862
+ "default": "\"getDocumentLocaleSettings()\""
8711
8863
  }
8712
8864
  ]
8713
8865
  },
@@ -8778,6 +8930,10 @@
8778
8930
  "description": "Whether the component is active or inactive",
8779
8931
  "type": "boolean",
8780
8932
  "default": "false"
8933
+ },
8934
+ {
8935
+ "name": "documentLocaleSettings",
8936
+ "default": "\"getDocumentLocaleSettings()\""
8781
8937
  }
8782
8938
  ],
8783
8939
  "events": [
@@ -8980,6 +9136,10 @@
8980
9136
  "name": "openerType",
8981
9137
  "type": "string",
8982
9138
  "default": "\"DEFAULT\""
9139
+ },
9140
+ {
9141
+ "name": "documentLocaleSettings",
9142
+ "default": "\"getDocumentLocaleSettings()\""
8983
9143
  }
8984
9144
  ],
8985
9145
  "events": [
@@ -9040,6 +9200,10 @@
9040
9200
  "description": "The number of additional items to load.",
9041
9201
  "type": "number",
9042
9202
  "default": "50"
9203
+ },
9204
+ {
9205
+ "name": "documentLocaleSettings",
9206
+ "default": "\"getDocumentLocaleSettings()\""
9043
9207
  }
9044
9208
  ],
9045
9209
  "events": [
@@ -9214,6 +9378,10 @@
9214
9378
  "description": "REQUIRED: Text for the dropdown opener button",
9215
9379
  "type": "string"
9216
9380
  },
9381
+ {
9382
+ "name": "documentLocaleSettings",
9383
+ "default": "\"getDocumentLocaleSettings()\""
9384
+ },
9217
9385
  {
9218
9386
  "name": "requiresSelection",
9219
9387
  "attribute": "requires-selection",
@@ -9427,6 +9595,10 @@
9427
9595
  "description": "REQUIRED: The text for the action",
9428
9596
  "type": "string"
9429
9597
  },
9598
+ {
9599
+ "name": "documentLocaleSettings",
9600
+ "default": "\"getDocumentLocaleSettings()\""
9601
+ },
9430
9602
  {
9431
9603
  "name": "requiresSelection",
9432
9604
  "attribute": "requires-selection",
@@ -9575,6 +9747,10 @@
9575
9747
  }
9576
9748
  ],
9577
9749
  "properties": [
9750
+ {
9751
+ "name": "documentLocaleSettings",
9752
+ "default": "\"getDocumentLocaleSettings()\""
9753
+ },
9578
9754
  {
9579
9755
  "name": "selectionFor",
9580
9756
  "attribute": "selection-for",
@@ -9617,6 +9793,10 @@
9617
9793
  "type": "boolean",
9618
9794
  "default": "false"
9619
9795
  },
9796
+ {
9797
+ "name": "documentLocaleSettings",
9798
+ "default": "\"getDocumentLocaleSettings()\""
9799
+ },
9620
9800
  {
9621
9801
  "name": "selectionFor",
9622
9802
  "attribute": "selection-for",
@@ -9657,6 +9837,10 @@
9657
9837
  "description": "Text to display if no items are selected",
9658
9838
  "type": "string"
9659
9839
  },
9840
+ {
9841
+ "name": "documentLocaleSettings",
9842
+ "default": "\"getDocumentLocaleSettings()\""
9843
+ },
9660
9844
  {
9661
9845
  "name": "selectionFor",
9662
9846
  "attribute": "selection-for",
@@ -10006,6 +10190,10 @@
10006
10190
  "name": "onIcon",
10007
10191
  "type": "TemplateResult<1>"
10008
10192
  },
10193
+ {
10194
+ "name": "documentLocaleSettings",
10195
+ "default": "\"getDocumentLocaleSettings()\""
10196
+ },
10009
10197
  {
10010
10198
  "name": "disabled",
10011
10199
  "attribute": "disabled",
@@ -10413,6 +10601,10 @@
10413
10601
  "type": "number",
10414
10602
  "default": "-1"
10415
10603
  },
10604
+ {
10605
+ "name": "documentLocaleSettings",
10606
+ "default": "\"getDocumentLocaleSettings()\""
10607
+ },
10416
10608
  {
10417
10609
  "name": "arrowKeysDirection",
10418
10610
  "type": "string",
@@ -10481,6 +10673,10 @@
10481
10673
  "description": "Enables the option to clear a tag list item. The `d2l-tag-list-item-clear` event will be dispatched when the user selects to delete the item. The consumer must handle the actual item deletion.",
10482
10674
  "type": "boolean",
10483
10675
  "default": "false"
10676
+ },
10677
+ {
10678
+ "name": "documentLocaleSettings",
10679
+ "default": "\"getDocumentLocaleSettings()\""
10484
10680
  }
10485
10681
  ],
10486
10682
  "events": [
@@ -10533,6 +10729,10 @@
10533
10729
  "type": "number",
10534
10730
  "default": "0"
10535
10731
  },
10732
+ {
10733
+ "name": "documentLocaleSettings",
10734
+ "default": "\"getDocumentLocaleSettings()\""
10735
+ },
10536
10736
  {
10537
10737
  "name": "arrowKeysDirection",
10538
10738
  "type": "string",
@@ -10578,6 +10778,10 @@
10578
10778
  "description": "Enables the option to clear a tag list item. The `d2l-tag-list-item-clear` event will be dispatched when the user selects to delete the item. The consumer must handle the actual item deletion.",
10579
10779
  "type": "boolean",
10580
10780
  "default": "false"
10781
+ },
10782
+ {
10783
+ "name": "documentLocaleSettings",
10784
+ "default": "\"getDocumentLocaleSettings()\""
10581
10785
  }
10582
10786
  ],
10583
10787
  "events": [
@@ -10925,6 +11129,10 @@
10925
11129
  "description": "Whether content fills the screen or not",
10926
11130
  "type": "'fullscreen'|'normal'",
10927
11131
  "default": "\"fullscreen\""
11132
+ },
11133
+ {
11134
+ "name": "documentLocaleSettings",
11135
+ "default": "\"getDocumentLocaleSettings()\""
10928
11136
  }
10929
11137
  ],
10930
11138
  "events": [
@@ -11,16 +11,15 @@ export const LocalizeMixin = dedupeMixin(superclass => class extends superclass
11
11
  };
12
12
  }
13
13
 
14
+ static documentLocaleSettings = getDocumentLocaleSettings();
15
+
14
16
  constructor() {
15
17
  super();
16
-
17
- this.__documentLocaleSettings = getDocumentLocaleSettings();
18
18
  this.__resourcesLoadedPromise = new Promise((resolve) => {
19
19
  let first = true;
20
20
  this.__languageChangeCallback = () => {
21
21
  if (!this._hasResources()) return;
22
- const possibleLanguages = this._generatePossibleLanguages();
23
- const localizeResources = this.constructor._getAllLocalizeResources(possibleLanguages);
22
+ const localizeResources = this.constructor._getAllLocalizeResources();
24
23
  const resourcesLoadedPromise = Promise.all(localizeResources);
25
24
  resourcesLoadedPromise
26
25
  .then((results) => {
@@ -45,18 +44,17 @@ export const LocalizeMixin = dedupeMixin(superclass => class extends superclass
45
44
  });
46
45
 
47
46
  this.__updatedProperties = new Map();
48
-
49
47
  }
50
48
 
51
49
  connectedCallback() {
52
50
  super.connectedCallback();
53
- this.__documentLocaleSettings.addChangeListener(this.__languageChangeCallback);
51
+ this.constructor.documentLocaleSettings.addChangeListener(this.__languageChangeCallback);
54
52
  this.__languageChangeCallback();
55
53
  }
56
54
 
57
55
  disconnectedCallback() {
58
56
  super.disconnectedCallback();
59
- this.__documentLocaleSettings.removeChangeListener(this.__languageChangeCallback);
57
+ this.constructor.documentLocaleSettings.removeChangeListener(this.__languageChangeCallback);
60
58
  this.__updatedProperties.clear();
61
59
  }
62
60
 
@@ -130,49 +128,30 @@ export const LocalizeMixin = dedupeMixin(superclass => class extends superclass
130
128
 
131
129
  }
132
130
 
133
- _generatePossibleLanguages() {
134
- const langs = new Set();
135
-
136
- let docLang = this.__documentLocaleSettings.language;
137
- if (docLang) {
138
- docLang = docLang.toLowerCase();
139
- langs.add(docLang);
140
-
141
- if (docLang.indexOf('-') !== -1) {
142
- const baseDocLang = docLang.split('-')[0];
143
- langs.add(baseDocLang);
144
- }
145
- }
146
-
147
- let docFallbackLang = this.__documentLocaleSettings.fallbackLanguage;
148
- if (docFallbackLang) {
149
- docFallbackLang = docFallbackLang.toLowerCase();
150
- langs.add(docFallbackLang);
131
+ static _generatePossibleLanguages(config) {
151
132
 
152
- if (docFallbackLang.indexOf('-') !== -1) {
153
- const baseDocFallbackLang = docFallbackLang.split('-')[0];
154
- langs.add(baseDocFallbackLang);
155
- }
156
- }
133
+ if (config?.useBrowserLangs) return navigator.languages.map(e => e.toLowerCase()).concat('en');
157
134
 
158
- langs.add('en-us');
159
- langs.add('en');
135
+ const { language, fallbackLanguage } = this.documentLocaleSettings;
136
+ const langs = [ language, fallbackLanguage ]
137
+ .filter(e => e)
138
+ .map(e => [ e.toLowerCase(), e.split('-')[0] ])
139
+ .flat();
160
140
 
161
- return Array.from(langs);
141
+ return Array.from(new Set([ ...langs, 'en-us', 'en' ]));
162
142
  }
163
143
 
164
- static _getAllLocalizeResources(possibleLanguages, config = this.localizeConfig) {
144
+ static _getAllLocalizeResources(config = this.localizeConfig) {
165
145
  let resourcesLoadedPromises = [];
166
146
  const superCtor = Object.getPrototypeOf(this);
167
147
  // get imported terms for each config, head up the chain to get them all
168
148
  if ('_getAllLocalizeResources' in superCtor) {
169
- // eslint-disable-next-line no-prototype-builtins
170
- const superConfig = superCtor.hasOwnProperty('localizeConfig') && superCtor.localizeConfig.importFunc ? superCtor.localizeConfig : config;
171
- resourcesLoadedPromises = superCtor._getAllLocalizeResources(possibleLanguages, superConfig);
149
+ const superConfig = Object.hasOwn(superCtor, 'localizeConfig') && superCtor.localizeConfig.importFunc ? superCtor.localizeConfig : config;
150
+ resourcesLoadedPromises = superCtor._getAllLocalizeResources(superConfig);
172
151
  }
173
- // eslint-disable-next-line no-prototype-builtins
174
- if (this.hasOwnProperty('getLocalizeResources') || this.hasOwnProperty('resources')) {
175
- const res = this.getLocalizeResources([...possibleLanguages], config);
152
+ if (Object.hasOwn(this, 'getLocalizeResources') || Object.hasOwn(this, 'resources')) {
153
+ const possibleLanguages = this._generatePossibleLanguages(config);
154
+ const res = this.getLocalizeResources(possibleLanguages, config);
176
155
  resourcesLoadedPromises.push(res);
177
156
  }
178
157
  return resourcesLoadedPromises;
@@ -77,13 +77,12 @@ class MyComponent extends LocalizeDynamicMixin(LitElement) {
77
77
  // Import path must be relative
78
78
  importFunc: async lang => (await import(`../lang/${lang}.js`)).default,
79
79
  // Optionally enable OSLO
80
- osloCollection: 'my-project\\myComponent',
80
+ osloCollection: '@d2l\\my-project\\myComponent',
81
81
  };
82
82
  }
83
83
  }
84
84
  ```
85
-
86
- When using this method, depending on various user settings, it's possible that a language file that does not exist will be requested, resulting in a network error (404). In production, your build system should prevent this by transpiling the variable dynamic import into a `switch` statement.
85
+ Occasionally, it may be desirable to localize based on the user's browser settings. To do this, add `useBrowserLangs: true` to your `localizeConfig` object. This option should only be used if *all* supported *locales* have corresponding files named with their 4-character locale code, and all supported *languages*, in addition, have 2-character files. (e.g. `en-us.js`, `en-ca.js` and `en.js`)
87
86
 
88
87
  If your build system does not support variable dynamic imports, you'll need to manually set up imports for each supported language:
89
88
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.53.0",
3
+ "version": "2.54.0",
4
4
  "description": "A collection of accessible, free, open-source web components for building Brightspace applications",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/BrightspaceUI/core.git",