@brightspace-ui/core 2.0.4 → 2.1.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.
|
@@ -2,11 +2,17 @@ import { getLocalizeOverrideResources } from '../helpers/getLocalizeResources.js
|
|
|
2
2
|
import { LocalizeMixin } from './localize-mixin.js';
|
|
3
3
|
|
|
4
4
|
const fallbackLang = 'en';
|
|
5
|
+
const supportedLangpacks = ['ar', 'cy', 'da', 'de', 'en', 'es', 'es-es', 'fr', 'fr-fr', 'fr-on', 'hi', 'ja', 'ko', 'nl', 'pt', 'sv', 'tr', 'zh-cn', 'zh-tw'];
|
|
5
6
|
|
|
6
7
|
export const LocalizeDynamicMixin = superclass => class extends LocalizeMixin(superclass) {
|
|
7
8
|
|
|
8
9
|
static async getLocalizeResources(langs, { importFunc, osloCollection }) {
|
|
9
10
|
|
|
11
|
+
// in dev, don't request unsupported langpacks
|
|
12
|
+
if (!importFunc.toString().includes('switch')) {
|
|
13
|
+
langs = langs.filter(lang => supportedLangpacks.includes(lang));
|
|
14
|
+
}
|
|
15
|
+
|
|
10
16
|
for (const lang of [...langs, fallbackLang]) {
|
|
11
17
|
|
|
12
18
|
const resources = await importFunc(lang).catch(() => {});
|
package/mixins/localize-mixin.md
CHANGED
|
@@ -83,7 +83,9 @@ class MyComponent extends LocalizeDynamicMixin(LitElement) {
|
|
|
83
83
|
}
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
|
|
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.
|
|
87
|
+
|
|
88
|
+
If your build system does not support variable dynamic imports, you'll need to manually set up imports for each supported language:
|
|
87
89
|
|
|
88
90
|
```javascript
|
|
89
91
|
static get localizeConfig() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.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",
|