@everymatrix/general-styling-wrapper 1.73.2 → 1.74.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.
- package/dist/cjs/general-styling-wrapper.cjs.entry.js +5 -4
- package/dist/collection/utils/locale.utils.js +5 -4
- package/dist/esm/general-styling-wrapper.entry.js +5 -4
- package/dist/general-styling-wrapper/general-styling-wrapper.entry.js +1 -1
- package/dist/types/utils/locale.utils.d.ts +1 -1
- package/package.json +1 -1
|
@@ -10,21 +10,22 @@ const mergeTranslations = (url, target) => {
|
|
|
10
10
|
.then((res) => res.json())
|
|
11
11
|
.then((data) => {
|
|
12
12
|
Object.keys(data).forEach((item) => {
|
|
13
|
-
target[item] = target[item] || target['en'];
|
|
13
|
+
target[item] = target[item] || Object.assign({}, target['en']);
|
|
14
14
|
Object.keys(data[item]).forEach((key) => {
|
|
15
15
|
//if there is not key in target, do nothing
|
|
16
16
|
if (!target['en'][key]) {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
target[item][key] = target[item][key] || target['en'][key];
|
|
19
|
+
const defaultTranslation = target['en'][key];
|
|
21
20
|
if (typeof data[item][key] === 'object') {
|
|
21
|
+
// if the key is not in target, then take from en
|
|
22
|
+
target[item][key] = target[item][key] || Object.assign({}, defaultTranslation);
|
|
22
23
|
Object.keys(data[item][key]).forEach((subKey) => {
|
|
23
24
|
target[item][key][subKey] = data[item][key][subKey];
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
else {
|
|
27
|
-
target[item][key] = data[item][key];
|
|
28
|
+
target[item][key] = data[item][key] || defaultTranslation;
|
|
28
29
|
}
|
|
29
30
|
});
|
|
30
31
|
});
|
|
@@ -4,21 +4,22 @@ export const mergeTranslations = (url, target) => {
|
|
|
4
4
|
.then((res) => res.json())
|
|
5
5
|
.then((data) => {
|
|
6
6
|
Object.keys(data).forEach((item) => {
|
|
7
|
-
target[item] = target[item] || target['en'];
|
|
7
|
+
target[item] = target[item] || Object.assign({}, target['en']);
|
|
8
8
|
Object.keys(data[item]).forEach((key) => {
|
|
9
9
|
//if there is not key in target, do nothing
|
|
10
10
|
if (!target['en'][key]) {
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
target[item][key] = target[item][key] || target['en'][key];
|
|
13
|
+
const defaultTranslation = target['en'][key];
|
|
15
14
|
if (typeof data[item][key] === 'object') {
|
|
15
|
+
// if the key is not in target, then take from en
|
|
16
|
+
target[item][key] = target[item][key] || Object.assign({}, defaultTranslation);
|
|
16
17
|
Object.keys(data[item][key]).forEach((subKey) => {
|
|
17
18
|
target[item][key][subKey] = data[item][key][subKey];
|
|
18
19
|
});
|
|
19
20
|
}
|
|
20
21
|
else {
|
|
21
|
-
target[item][key] = data[item][key];
|
|
22
|
+
target[item][key] = data[item][key] || defaultTranslation;
|
|
22
23
|
}
|
|
23
24
|
});
|
|
24
25
|
});
|
|
@@ -6,21 +6,22 @@ const mergeTranslations = (url, target) => {
|
|
|
6
6
|
.then((res) => res.json())
|
|
7
7
|
.then((data) => {
|
|
8
8
|
Object.keys(data).forEach((item) => {
|
|
9
|
-
target[item] = target[item] || target['en'];
|
|
9
|
+
target[item] = target[item] || Object.assign({}, target['en']);
|
|
10
10
|
Object.keys(data[item]).forEach((key) => {
|
|
11
11
|
//if there is not key in target, do nothing
|
|
12
12
|
if (!target['en'][key]) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
target[item][key] = target[item][key] || target['en'][key];
|
|
15
|
+
const defaultTranslation = target['en'][key];
|
|
17
16
|
if (typeof data[item][key] === 'object') {
|
|
17
|
+
// if the key is not in target, then take from en
|
|
18
|
+
target[item][key] = target[item][key] || Object.assign({}, defaultTranslation);
|
|
18
19
|
Object.keys(data[item][key]).forEach((subKey) => {
|
|
19
20
|
target[item][key][subKey] = data[item][key][subKey];
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
23
|
else {
|
|
23
|
-
target[item][key] = data[item][key];
|
|
24
|
+
target[item][key] = data[item][key] || defaultTranslation;
|
|
24
25
|
}
|
|
25
26
|
});
|
|
26
27
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,h as i,g as
|
|
1
|
+
import{r as t,h as i,g as e}from"./index-7ef90fae.js";function n(t,i){if(t){const e=document.createElement("style");e.innerHTML=i,t.appendChild(e)}}function s(t,i){const e=new URL(i);fetch(e.href).then((t=>t.text())).then((i=>{const e=document.createElement("style");e.innerHTML=i,t&&t.appendChild(e)})).catch((t=>{console.error("There was an error while trying to load client styling from URL",t)}))}const o=class{constructor(i){t(this,i),this.stylingAppends=!1,this.clientStyling="",this.clientStylingUrl="",this.mbSource=void 0,this.translationUrl="",this.targetTranslations=void 0}componentDidLoad(){this.el&&(null!=window.emMessageBus?function(t,i){if(window.emMessageBus){const e=document.createElement("style");window.emMessageBus.subscribe(i,(i=>{e.innerHTML=i,t&&t.appendChild(e)}))}}(this.el,`${this.mbSource}.Style`):(this.clientStyling&&n(this.el,this.clientStyling),this.clientStylingUrl&&s(this.el,this.clientStylingUrl),this.stylingAppends=!0))}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}handleClientStylingChange(t,i){t!=i&&n(this.el,this.clientStyling)}handleClientStylingUrlChange(t,i){t!=i&&this.clientStylingUrl&&s(this.el,this.clientStylingUrl)}componentDidRender(){this.stylingAppends||(this.clientStyling&&n(this.el,this.clientStyling),this.clientStylingUrl&&s(this.el,this.clientStylingUrl),this.stylingAppends=!0)}async componentWillLoad(){const t=[];if(this.translationUrl){const n=(i=this.translationUrl,e=this.targetTranslations,new Promise((t=>{fetch(i).then((t=>t.json())).then((i=>{Object.keys(i).forEach((t=>{e[t]=e[t]||Object.assign({},e.en),Object.keys(i[t]).forEach((n=>{if(!e.en[n])return;const s=e.en[n];"object"==typeof i[t][n]?(e[t][n]=e[t][n]||Object.assign({},s),Object.keys(i[t][n]).forEach((s=>{e[t][n][s]=i[t][n][s]}))):e[t][n]=i[t][n]||s}))})),t(!0)})).catch((i=>{console.error("Failed to load translations:",i),t(!1)}))})));t.push(n)}var i,e;return await Promise.all(t)}render(){return i("div",{key:"09ad83748bbad518743c8671b986c541c52bf3f0",class:"StyleShell"},i("slot",{key:"3b28b776d3944410c717b002b70946d274a4e8e7",name:"mainContent"}))}get el(){return e(this)}static get watchers(){return{clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingUrlChange"]}}};o.style=":host{display:block}";export{o as general_styling_wrapper}
|