@brightspace-ui/core 2.18.7 → 2.18.8
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/mixins/demo/localize-test.js +13 -11
- package/mixins/localize-mixin.js +4 -5
- package/mixins/localize-mixin.md +0 -11
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { html, LitElement } from 'lit';
|
|
2
|
-
import {
|
|
2
|
+
import { LocalizeMixin } from '../../mixins/localize-mixin.js';
|
|
3
3
|
|
|
4
|
-
class LocalizeTest extends
|
|
4
|
+
class LocalizeTest extends LocalizeMixin(LitElement) {
|
|
5
5
|
|
|
6
6
|
static get properties() {
|
|
7
7
|
return {
|
|
@@ -11,7 +11,7 @@ class LocalizeTest extends LocalizeDynamicMixin(LitElement) {
|
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
static
|
|
14
|
+
static async getLocalizeResources(langs) {
|
|
15
15
|
const langResources = {
|
|
16
16
|
'ar': { 'hello': 'مرحبا {name}' },
|
|
17
17
|
'de': { 'hello': 'Hallo {name}' },
|
|
@@ -29,15 +29,17 @@ class LocalizeTest extends LocalizeDynamicMixin(LitElement) {
|
|
|
29
29
|
'zh-cn': { 'hello': '你好 {name}' },
|
|
30
30
|
'zh-tw': { 'hello': '你好 {name}' }
|
|
31
31
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
32
|
+
|
|
33
|
+
for (let i = 0; i < langs.length; i++) {
|
|
34
|
+
if (langResources[langs[i]]) {
|
|
35
|
+
return {
|
|
36
|
+
language: langs[i],
|
|
37
|
+
resources: langResources[langs[i]]
|
|
38
|
+
};
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return null;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
render() {
|
package/mixins/localize-mixin.js
CHANGED
|
@@ -163,13 +163,12 @@ export const LocalizeMixin = dedupeMixin(superclass => class extends superclass
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
static _getAllLocalizeResources(possibleLanguages, config = this.localizeConfig) {
|
|
166
|
-
let resourcesLoadedPromises
|
|
166
|
+
let resourcesLoadedPromises;
|
|
167
167
|
const superCtor = Object.getPrototypeOf(this);
|
|
168
|
-
// get imported terms for each config, head up the chain to get them all
|
|
169
168
|
if ('_getAllLocalizeResources' in superCtor) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
resourcesLoadedPromises =
|
|
169
|
+
resourcesLoadedPromises = superCtor._getAllLocalizeResources(possibleLanguages, config);
|
|
170
|
+
} else {
|
|
171
|
+
resourcesLoadedPromises = [];
|
|
173
172
|
}
|
|
174
173
|
// eslint-disable-next-line no-prototype-builtins
|
|
175
174
|
if (this.hasOwnProperty('getLocalizeResources') || this.hasOwnProperty('resources')) {
|
package/mixins/localize-mixin.md
CHANGED
|
@@ -103,17 +103,6 @@ static get localizeConfig() {
|
|
|
103
103
|
}
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
**Note:** If using `LocalizeCoreElement` or a mixin that utilizes `LocalizeCoreElement` as well as `LocalizeDynamicMixin` or a mixin that uses `LocalizeDynamicMixin`, `LocalizeDynamicMixin` **must** appear before `LocalizeCoreElement` in the chain. For example:
|
|
107
|
-
|
|
108
|
-
```javascript
|
|
109
|
-
import { LocalizeCoreElement } from '@brightspace-ui/core/helpers/localize-core-element.js';
|
|
110
|
-
import { LocalizeDynamicMixin } from '@brightspace-ui/core/mixins/localize-dynamic-mixin.js';
|
|
111
|
-
|
|
112
|
-
class MyComponent extends LocalizeDynamicMixin(LocalizeCoreElement(LitElement)) {
|
|
113
|
-
...
|
|
114
|
-
}
|
|
115
|
-
```
|
|
116
|
-
|
|
117
106
|
## `localize()`
|
|
118
107
|
|
|
119
108
|
Once your localization resources are available, the `localize()` method is used to localize a piece of text in your `render()` method.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "2.18.
|
|
3
|
+
"version": "2.18.8",
|
|
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",
|