@dile/ui 2.2.0 → 2.3.1
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.
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
export const DileI18nMixin = (translationService) => (superclass) => class extends superclass {
|
|
3
|
+
static get properties() {
|
|
4
|
+
return {
|
|
5
|
+
language: { type: String },
|
|
6
|
+
translations: { type: Object },
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
this.language = 'en';
|
|
13
|
+
this.translations = {};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async connectedCallback() {
|
|
17
|
+
super.connectedCallback();
|
|
18
|
+
this.translations = await translationService.loadTranslations(this.language);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export class TranslationService {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.translations = {};
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
async loadTranslations(language) {
|
|
7
|
+
try {
|
|
8
|
+
if (!this.translations[language]) {
|
|
9
|
+
const module = await this.importLanguage(language)
|
|
10
|
+
this.translations[language] = module.translations;
|
|
11
|
+
}
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.warn(`Could not load translations for language: ${language}, falling back to English`);
|
|
14
|
+
|
|
15
|
+
if (!this.translations['en']) {
|
|
16
|
+
const defaultModule = await this.importFallback();
|
|
17
|
+
this.translations['en'] = defaultModule.translations;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return this.translations['en'];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return this.translations[language];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async importLanguage(language) {
|
|
27
|
+
// overwrite to import the language
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async importFallback() {
|
|
31
|
+
// overwrite to import the fallback language
|
|
32
|
+
}
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dile/ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "UI Core components from dile-components.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
},
|
|
21
21
|
"homepage": "https://dile-components.polydile.com/",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@dile/icons": "^2.0
|
|
23
|
+
"@dile/icons": "^2.1.0",
|
|
24
24
|
"lit": "^2.7.0 || ^3.0.0"
|
|
25
25
|
},
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "80e68858b65ac111ffba6ed72eee05df0a0aeb94"
|
|
30
30
|
}
|