defuss 2.0.11 → 2.0.13
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/index.cjs +29 -53
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.mjs +26 -55
- package/dist/render/client.cjs +0 -1
- package/dist/render/client.d.cts +1 -1
- package/dist/render/client.d.ts +1 -1
- package/dist/render/client.mjs +0 -1
- package/dist/render/server.d.cts +1 -1
- package/dist/render/server.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -26,23 +26,16 @@ const interpolate = (template, replacements) => {
|
|
|
26
26
|
};
|
|
27
27
|
const createI18n = () => {
|
|
28
28
|
const translationsStore = dom.createStore({});
|
|
29
|
-
let
|
|
29
|
+
let language2 = "en";
|
|
30
30
|
const onLanguageChangeCallbacks = [];
|
|
31
31
|
const api = {
|
|
32
32
|
get language() {
|
|
33
|
-
return
|
|
33
|
+
return language2;
|
|
34
34
|
},
|
|
35
35
|
changeLanguage(newLanguage) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
newLanguage,
|
|
39
|
-
"callbacks:",
|
|
40
|
-
onLanguageChangeCallbacks.length
|
|
41
|
-
);
|
|
42
|
-
if (newLanguage !== language) {
|
|
43
|
-
language = newLanguage;
|
|
36
|
+
if (newLanguage !== language2) {
|
|
37
|
+
language2 = newLanguage;
|
|
44
38
|
onLanguageChangeCallbacks.forEach((callback) => {
|
|
45
|
-
console.log("i18n calling callback for language change");
|
|
46
39
|
callback(newLanguage);
|
|
47
40
|
});
|
|
48
41
|
}
|
|
@@ -51,7 +44,7 @@ const createI18n = () => {
|
|
|
51
44
|
// const translatedString = t('greeting', { name: 'John', age: '30' }, 'common');
|
|
52
45
|
// this would replace placeholders {name} and {age} in the translation string with 'John' and '30' respectively.
|
|
53
46
|
t(path, replacements = {}) {
|
|
54
|
-
const languageData = translationsStore.get(
|
|
47
|
+
const languageData = translationsStore.get(language2);
|
|
55
48
|
if (!languageData) {
|
|
56
49
|
return path;
|
|
57
50
|
}
|
|
@@ -75,48 +68,36 @@ const createI18n = () => {
|
|
|
75
68
|
}
|
|
76
69
|
return interpolate(template, replacements);
|
|
77
70
|
},
|
|
78
|
-
|
|
79
|
-
console.log(
|
|
80
|
-
"i18n load called:",
|
|
81
|
-
newLanguage,
|
|
82
|
-
"translations:",
|
|
83
|
-
namespaceTranslations,
|
|
84
|
-
"callbacks:",
|
|
85
|
-
onLanguageChangeCallbacks.length
|
|
86
|
-
);
|
|
71
|
+
loadLanguage(newLanguage, namespaceTranslations) {
|
|
87
72
|
translationsStore.set(newLanguage, {
|
|
88
73
|
...translationsStore.get(newLanguage),
|
|
89
74
|
...namespaceTranslations
|
|
90
75
|
});
|
|
91
|
-
if (newLanguage ===
|
|
76
|
+
if (newLanguage === language2) {
|
|
92
77
|
onLanguageChangeCallbacks.forEach((callback) => {
|
|
93
|
-
|
|
94
|
-
callback(language);
|
|
78
|
+
callback(language2);
|
|
95
79
|
});
|
|
96
80
|
}
|
|
97
81
|
},
|
|
98
82
|
subscribe(onLanguageChange) {
|
|
99
|
-
console.log(
|
|
100
|
-
"i18n subscribe called, total callbacks will be:",
|
|
101
|
-
onLanguageChangeCallbacks.length + 1
|
|
102
|
-
);
|
|
103
83
|
onLanguageChangeCallbacks.push(onLanguageChange);
|
|
104
84
|
return () => api.unsubscribe(onLanguageChange);
|
|
105
85
|
},
|
|
106
86
|
unsubscribe(onLanguageChange) {
|
|
107
87
|
const index = onLanguageChangeCallbacks.indexOf(onLanguageChange);
|
|
108
|
-
console.log(
|
|
109
|
-
"i18n unsubscribe called, index:",
|
|
110
|
-
index,
|
|
111
|
-
"total callbacks before:",
|
|
112
|
-
onLanguageChangeCallbacks.length
|
|
113
|
-
);
|
|
114
88
|
if (index >= 0) onLanguageChangeCallbacks.splice(index, 1);
|
|
115
89
|
}
|
|
116
90
|
};
|
|
117
91
|
return api;
|
|
118
92
|
};
|
|
119
|
-
|
|
93
|
+
if (!globalThis.__defuss_i18n) {
|
|
94
|
+
globalThis.__defuss_i18n = createI18n();
|
|
95
|
+
}
|
|
96
|
+
const i18n = globalThis.__defuss_i18n;
|
|
97
|
+
const t = i18n.t.bind(i18n);
|
|
98
|
+
const changeLanguage = i18n.changeLanguage.bind(i18n);
|
|
99
|
+
const loadLanguage = i18n.loadLanguage.bind(i18n);
|
|
100
|
+
const language = i18n.language;
|
|
120
101
|
|
|
121
102
|
const Trans = ({
|
|
122
103
|
key,
|
|
@@ -127,38 +108,27 @@ const Trans = ({
|
|
|
127
108
|
}) => {
|
|
128
109
|
const _ref = ref || {};
|
|
129
110
|
const updateContent = () => {
|
|
130
|
-
console.log("Trans updateContent called for key:", key);
|
|
131
111
|
const value = i18n.t(key, values);
|
|
132
|
-
console.log("Trans updateContent: computed value:", value);
|
|
133
112
|
if (_ref.current) {
|
|
134
|
-
|
|
135
|
-
"Trans updateContent: updating DOM element",
|
|
136
|
-
_ref.current.innerText
|
|
137
|
-
);
|
|
138
|
-
dom.$(_ref.current).update(value);
|
|
139
|
-
} else {
|
|
140
|
-
console.log("Trans updateContent: _ref.current is null/undefined");
|
|
113
|
+
_ref.current.textContent = value;
|
|
141
114
|
}
|
|
142
115
|
};
|
|
143
116
|
_ref.updateValues = (newValues) => {
|
|
144
|
-
console.log("Trans updateValues called with:", newValues);
|
|
145
117
|
values = newValues;
|
|
146
118
|
updateContent();
|
|
147
119
|
};
|
|
148
120
|
const onMount = () => {
|
|
149
|
-
console.log("Trans onMount called for key:", key);
|
|
150
121
|
i18n.subscribe(updateContent);
|
|
122
|
+
if (attrs.onMount) {
|
|
123
|
+
attrs.onMount(_ref.current);
|
|
124
|
+
}
|
|
151
125
|
};
|
|
152
126
|
const onUnmount = () => {
|
|
153
|
-
console.log("Trans onUnmount called for key:", key);
|
|
154
127
|
i18n.unsubscribe(updateContent);
|
|
128
|
+
if (attrs.onUnmount) {
|
|
129
|
+
attrs.onUnmount(_ref.current);
|
|
130
|
+
}
|
|
155
131
|
};
|
|
156
|
-
console.log(
|
|
157
|
-
"Trans component creating for key:",
|
|
158
|
-
key,
|
|
159
|
-
"with initial value:",
|
|
160
|
-
i18n.t(key, values)
|
|
161
|
-
);
|
|
162
132
|
return {
|
|
163
133
|
type: tag || "span",
|
|
164
134
|
attributes: {
|
|
@@ -171,6 +141,7 @@ const Trans = ({
|
|
|
171
141
|
children: i18n.t(key, values)
|
|
172
142
|
};
|
|
173
143
|
};
|
|
144
|
+
const T = Trans;
|
|
174
145
|
|
|
175
146
|
const tokenizePath = (path) => {
|
|
176
147
|
const paramNameRegexp = /:([^\/\.\\]+)/g;
|
|
@@ -519,10 +490,15 @@ exports.Router = Router;
|
|
|
519
490
|
exports.RouterSlot = RouterSlot;
|
|
520
491
|
exports.RouterSlotId = RouterSlotId;
|
|
521
492
|
exports.Suspense = Suspense;
|
|
493
|
+
exports.T = T;
|
|
522
494
|
exports.Trans = Trans;
|
|
495
|
+
exports.changeLanguage = changeLanguage;
|
|
523
496
|
exports.createI18n = createI18n;
|
|
524
497
|
exports.i18n = i18n;
|
|
525
498
|
exports.inDevMode = inDevMode;
|
|
499
|
+
exports.language = language;
|
|
500
|
+
exports.loadLanguage = loadLanguage;
|
|
526
501
|
exports.matchRouteRegistrations = matchRouteRegistrations;
|
|
527
502
|
exports.setupRouter = setupRouter;
|
|
503
|
+
exports.t = t;
|
|
528
504
|
exports.tokenizePath = tokenizePath;
|
package/dist/index.d.cts
CHANGED
|
@@ -70,12 +70,16 @@ interface I18nStore {
|
|
|
70
70
|
language: string;
|
|
71
71
|
changeLanguage: (language: string) => void;
|
|
72
72
|
t: (path: string, options?: Record<string, string>) => string;
|
|
73
|
-
|
|
73
|
+
loadLanguage: (language: string, translations: TranslationObject) => void;
|
|
74
74
|
subscribe: (onLanguageChange: OnLanguageChangeListener) => () => void;
|
|
75
75
|
unsubscribe: (onLanguageChange: OnLanguageChangeListener) => void;
|
|
76
76
|
}
|
|
77
77
|
declare const createI18n: () => I18nStore;
|
|
78
78
|
declare const i18n: I18nStore;
|
|
79
|
+
declare const t: (path: string, options?: Record<string, string>) => string;
|
|
80
|
+
declare const changeLanguage: (language: string) => void;
|
|
81
|
+
declare const loadLanguage: (language: string, translations: TranslationObject) => void;
|
|
82
|
+
declare const language: string;
|
|
79
83
|
|
|
80
84
|
interface TransRef extends Ref<string, HTMLElement> {
|
|
81
85
|
updateValues: (values: Replacements) => void;
|
|
@@ -88,8 +92,10 @@ interface TransProps extends Props {
|
|
|
88
92
|
class?: string;
|
|
89
93
|
className?: string;
|
|
90
94
|
style?: string;
|
|
95
|
+
[propName: string]: any;
|
|
91
96
|
}
|
|
92
97
|
declare const Trans: ({ key, values, tag, ref, ...attrs }: TransProps) => VNodeChild;
|
|
98
|
+
declare const T: ({ key, values, tag, ref, ...attrs }: TransProps) => VNodeChild;
|
|
93
99
|
|
|
94
100
|
type OnHandleRouteChangeFn = (newRoute: string, oldRoute: string) => void;
|
|
95
101
|
type OnRouteChangeFn = (cb: OnHandleRouteChangeFn) => void;
|
|
@@ -215,4 +221,4 @@ declare const Suspense: ({ fallback, ref, children, class: _class, className, id
|
|
|
215
221
|
children: VNode<VNodeAttributes>[];
|
|
216
222
|
};
|
|
217
223
|
|
|
218
|
-
export { Async, type AsyncProps, type AsyncState, type AsyncStateRef, Globals, type I18nStore, NodeType, type OnHandleRouteChangeFn, type OnLanguageChangeListener, type OnRouteChangeFn, PersistenceProviderImpl, PersistenceProviderOptions, PersistenceProviderType, Props, Redirect, type RedirectProps, Ref, RenderInput, type Replacements, Route, type RouteHandler, type RouteParams, type RouteProps, type RouteRegistration, type RouteRequest, Router, type RouterConfig, RouterSlot, RouterSlotId, type RouterSlotProps, type RouterStrategy, Suspense, type TokenizedPath, Trans, type TransProps, type TransRef, type TranslationObject, type Translations, VNode, VNodeAttributes, VNodeChild, type ValidChild, addElementEvent, areDomNodesEqual, checkElementVisibility, clearElementEvents, createI18n, domNodeToVNode, getEventMap, getMimeType, htmlStringToVNodes, i18n, inDevMode, isHTML, isMarkup, isSVG, matchRouteRegistrations, parseDOM, processAllFormElements, removeElementEvent, renderMarkup, replaceDomWithVdom, setupRouter, tokenizePath, updateDomWithVdom, waitForDOM, webstorage };
|
|
224
|
+
export { Async, type AsyncProps, type AsyncState, type AsyncStateRef, Globals, type I18nStore, NodeType, type OnHandleRouteChangeFn, type OnLanguageChangeListener, type OnRouteChangeFn, PersistenceProviderImpl, PersistenceProviderOptions, PersistenceProviderType, Props, Redirect, type RedirectProps, Ref, RenderInput, type Replacements, Route, type RouteHandler, type RouteParams, type RouteProps, type RouteRegistration, type RouteRequest, Router, type RouterConfig, RouterSlot, RouterSlotId, type RouterSlotProps, type RouterStrategy, Suspense, T, type TokenizedPath, Trans, type TransProps, type TransRef, type TranslationObject, type Translations, VNode, VNodeAttributes, VNodeChild, type ValidChild, addElementEvent, areDomNodesEqual, changeLanguage, checkElementVisibility, clearElementEvents, createI18n, domNodeToVNode, getEventMap, getMimeType, htmlStringToVNodes, i18n, inDevMode, isHTML, isMarkup, isSVG, language, loadLanguage, matchRouteRegistrations, parseDOM, processAllFormElements, removeElementEvent, renderMarkup, replaceDomWithVdom, setupRouter, t, tokenizePath, updateDomWithVdom, waitForDOM, webstorage };
|
package/dist/index.d.ts
CHANGED
|
@@ -70,12 +70,16 @@ interface I18nStore {
|
|
|
70
70
|
language: string;
|
|
71
71
|
changeLanguage: (language: string) => void;
|
|
72
72
|
t: (path: string, options?: Record<string, string>) => string;
|
|
73
|
-
|
|
73
|
+
loadLanguage: (language: string, translations: TranslationObject) => void;
|
|
74
74
|
subscribe: (onLanguageChange: OnLanguageChangeListener) => () => void;
|
|
75
75
|
unsubscribe: (onLanguageChange: OnLanguageChangeListener) => void;
|
|
76
76
|
}
|
|
77
77
|
declare const createI18n: () => I18nStore;
|
|
78
78
|
declare const i18n: I18nStore;
|
|
79
|
+
declare const t: (path: string, options?: Record<string, string>) => string;
|
|
80
|
+
declare const changeLanguage: (language: string) => void;
|
|
81
|
+
declare const loadLanguage: (language: string, translations: TranslationObject) => void;
|
|
82
|
+
declare const language: string;
|
|
79
83
|
|
|
80
84
|
interface TransRef extends Ref<string, HTMLElement> {
|
|
81
85
|
updateValues: (values: Replacements) => void;
|
|
@@ -88,8 +92,10 @@ interface TransProps extends Props {
|
|
|
88
92
|
class?: string;
|
|
89
93
|
className?: string;
|
|
90
94
|
style?: string;
|
|
95
|
+
[propName: string]: any;
|
|
91
96
|
}
|
|
92
97
|
declare const Trans: ({ key, values, tag, ref, ...attrs }: TransProps) => VNodeChild;
|
|
98
|
+
declare const T: ({ key, values, tag, ref, ...attrs }: TransProps) => VNodeChild;
|
|
93
99
|
|
|
94
100
|
type OnHandleRouteChangeFn = (newRoute: string, oldRoute: string) => void;
|
|
95
101
|
type OnRouteChangeFn = (cb: OnHandleRouteChangeFn) => void;
|
|
@@ -215,4 +221,4 @@ declare const Suspense: ({ fallback, ref, children, class: _class, className, id
|
|
|
215
221
|
children: VNode<VNodeAttributes>[];
|
|
216
222
|
};
|
|
217
223
|
|
|
218
|
-
export { Async, type AsyncProps, type AsyncState, type AsyncStateRef, Globals, type I18nStore, NodeType, type OnHandleRouteChangeFn, type OnLanguageChangeListener, type OnRouteChangeFn, PersistenceProviderImpl, PersistenceProviderOptions, PersistenceProviderType, Props, Redirect, type RedirectProps, Ref, RenderInput, type Replacements, Route, type RouteHandler, type RouteParams, type RouteProps, type RouteRegistration, type RouteRequest, Router, type RouterConfig, RouterSlot, RouterSlotId, type RouterSlotProps, type RouterStrategy, Suspense, type TokenizedPath, Trans, type TransProps, type TransRef, type TranslationObject, type Translations, VNode, VNodeAttributes, VNodeChild, type ValidChild, addElementEvent, areDomNodesEqual, checkElementVisibility, clearElementEvents, createI18n, domNodeToVNode, getEventMap, getMimeType, htmlStringToVNodes, i18n, inDevMode, isHTML, isMarkup, isSVG, matchRouteRegistrations, parseDOM, processAllFormElements, removeElementEvent, renderMarkup, replaceDomWithVdom, setupRouter, tokenizePath, updateDomWithVdom, waitForDOM, webstorage };
|
|
224
|
+
export { Async, type AsyncProps, type AsyncState, type AsyncStateRef, Globals, type I18nStore, NodeType, type OnHandleRouteChangeFn, type OnLanguageChangeListener, type OnRouteChangeFn, PersistenceProviderImpl, PersistenceProviderOptions, PersistenceProviderType, Props, Redirect, type RedirectProps, Ref, RenderInput, type Replacements, Route, type RouteHandler, type RouteParams, type RouteProps, type RouteRegistration, type RouteRequest, Router, type RouterConfig, RouterSlot, RouterSlotId, type RouterSlotProps, type RouterStrategy, Suspense, T, type TokenizedPath, Trans, type TransProps, type TransRef, type TranslationObject, type Translations, VNode, VNodeAttributes, VNodeChild, type ValidChild, addElementEvent, areDomNodesEqual, changeLanguage, checkElementVisibility, clearElementEvents, createI18n, domNodeToVNode, getEventMap, getMimeType, htmlStringToVNodes, i18n, inDevMode, isHTML, isMarkup, isSVG, language, loadLanguage, matchRouteRegistrations, parseDOM, processAllFormElements, removeElementEvent, renderMarkup, replaceDomWithVdom, setupRouter, t, tokenizePath, updateDomWithVdom, waitForDOM, webstorage };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as createStore,
|
|
1
|
+
import { l as createStore, m as isServer, k as createRef, $, f as isRef } from './dom-BODEuMW4.mjs';
|
|
2
2
|
export { J as Call, O as CallChainImpl, P as CallChainImplThenable, F as Fragment, D as addElementEvent, K as addNonChainedReturnCallNames, n as areDomNodesEqual, B as checkElementVisibility, G as clearElementEvents, Y as createCall, Z as createGetterSetterCall, c as createInPlaceErrorMessageVNode, _ as createSubChain, S as delayedAutoStart, T as dequery, H as domNodeToVNode, N as emptyImpl, R as getAllFormValues, W as getDefaultDequeryOptions, C as getEventMap, z as getMimeType, L as getNonChainedReturnCallNames, g as getRenderer, b as globalScopeDomApis, h as handleLifecycleEventsForOnMount, I as htmlStringToVNodes, U as isDequery, V as isDequeryOptionsObject, v as isHTML, i as isJSX, x as isMarkup, M as isNonChainedReturnCall, t as isSVG, j as jsx, e as jsxDEV, d as jsxs, X as mapArrayIndexAccess, o as observeUnmount, s as parseDOM, A as processAllFormElements, E as removeElementEvent, a as renderIsomorphicAsync, r as renderIsomorphicSync, y as renderMarkup, a2 as renderNode, q as replaceDomWithVdom, a3 as resolveNodes, a1 as runWithTimeGuard, Q as scrollHelper, a0 as subChainForNextAwait, a4 as traverse, u as updateDom, p as updateDomWithVdom, w as waitForDOM, a5 as webstorage } from './dom-BODEuMW4.mjs';
|
|
3
3
|
import 'defuss-runtime';
|
|
4
4
|
|
|
@@ -25,23 +25,16 @@ const interpolate = (template, replacements) => {
|
|
|
25
25
|
};
|
|
26
26
|
const createI18n = () => {
|
|
27
27
|
const translationsStore = createStore({});
|
|
28
|
-
let
|
|
28
|
+
let language2 = "en";
|
|
29
29
|
const onLanguageChangeCallbacks = [];
|
|
30
30
|
const api = {
|
|
31
31
|
get language() {
|
|
32
|
-
return
|
|
32
|
+
return language2;
|
|
33
33
|
},
|
|
34
34
|
changeLanguage(newLanguage) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
newLanguage,
|
|
38
|
-
"callbacks:",
|
|
39
|
-
onLanguageChangeCallbacks.length
|
|
40
|
-
);
|
|
41
|
-
if (newLanguage !== language) {
|
|
42
|
-
language = newLanguage;
|
|
35
|
+
if (newLanguage !== language2) {
|
|
36
|
+
language2 = newLanguage;
|
|
43
37
|
onLanguageChangeCallbacks.forEach((callback) => {
|
|
44
|
-
console.log("i18n calling callback for language change");
|
|
45
38
|
callback(newLanguage);
|
|
46
39
|
});
|
|
47
40
|
}
|
|
@@ -50,7 +43,7 @@ const createI18n = () => {
|
|
|
50
43
|
// const translatedString = t('greeting', { name: 'John', age: '30' }, 'common');
|
|
51
44
|
// this would replace placeholders {name} and {age} in the translation string with 'John' and '30' respectively.
|
|
52
45
|
t(path, replacements = {}) {
|
|
53
|
-
const languageData = translationsStore.get(
|
|
46
|
+
const languageData = translationsStore.get(language2);
|
|
54
47
|
if (!languageData) {
|
|
55
48
|
return path;
|
|
56
49
|
}
|
|
@@ -74,48 +67,36 @@ const createI18n = () => {
|
|
|
74
67
|
}
|
|
75
68
|
return interpolate(template, replacements);
|
|
76
69
|
},
|
|
77
|
-
|
|
78
|
-
console.log(
|
|
79
|
-
"i18n load called:",
|
|
80
|
-
newLanguage,
|
|
81
|
-
"translations:",
|
|
82
|
-
namespaceTranslations,
|
|
83
|
-
"callbacks:",
|
|
84
|
-
onLanguageChangeCallbacks.length
|
|
85
|
-
);
|
|
70
|
+
loadLanguage(newLanguage, namespaceTranslations) {
|
|
86
71
|
translationsStore.set(newLanguage, {
|
|
87
72
|
...translationsStore.get(newLanguage),
|
|
88
73
|
...namespaceTranslations
|
|
89
74
|
});
|
|
90
|
-
if (newLanguage ===
|
|
75
|
+
if (newLanguage === language2) {
|
|
91
76
|
onLanguageChangeCallbacks.forEach((callback) => {
|
|
92
|
-
|
|
93
|
-
callback(language);
|
|
77
|
+
callback(language2);
|
|
94
78
|
});
|
|
95
79
|
}
|
|
96
80
|
},
|
|
97
81
|
subscribe(onLanguageChange) {
|
|
98
|
-
console.log(
|
|
99
|
-
"i18n subscribe called, total callbacks will be:",
|
|
100
|
-
onLanguageChangeCallbacks.length + 1
|
|
101
|
-
);
|
|
102
82
|
onLanguageChangeCallbacks.push(onLanguageChange);
|
|
103
83
|
return () => api.unsubscribe(onLanguageChange);
|
|
104
84
|
},
|
|
105
85
|
unsubscribe(onLanguageChange) {
|
|
106
86
|
const index = onLanguageChangeCallbacks.indexOf(onLanguageChange);
|
|
107
|
-
console.log(
|
|
108
|
-
"i18n unsubscribe called, index:",
|
|
109
|
-
index,
|
|
110
|
-
"total callbacks before:",
|
|
111
|
-
onLanguageChangeCallbacks.length
|
|
112
|
-
);
|
|
113
87
|
if (index >= 0) onLanguageChangeCallbacks.splice(index, 1);
|
|
114
88
|
}
|
|
115
89
|
};
|
|
116
90
|
return api;
|
|
117
91
|
};
|
|
118
|
-
|
|
92
|
+
if (!globalThis.__defuss_i18n) {
|
|
93
|
+
globalThis.__defuss_i18n = createI18n();
|
|
94
|
+
}
|
|
95
|
+
const i18n = globalThis.__defuss_i18n;
|
|
96
|
+
const t = i18n.t.bind(i18n);
|
|
97
|
+
const changeLanguage = i18n.changeLanguage.bind(i18n);
|
|
98
|
+
const loadLanguage = i18n.loadLanguage.bind(i18n);
|
|
99
|
+
const language = i18n.language;
|
|
119
100
|
|
|
120
101
|
const Trans = ({
|
|
121
102
|
key,
|
|
@@ -126,38 +107,27 @@ const Trans = ({
|
|
|
126
107
|
}) => {
|
|
127
108
|
const _ref = ref || {};
|
|
128
109
|
const updateContent = () => {
|
|
129
|
-
console.log("Trans updateContent called for key:", key);
|
|
130
110
|
const value = i18n.t(key, values);
|
|
131
|
-
console.log("Trans updateContent: computed value:", value);
|
|
132
111
|
if (_ref.current) {
|
|
133
|
-
|
|
134
|
-
"Trans updateContent: updating DOM element",
|
|
135
|
-
_ref.current.innerText
|
|
136
|
-
);
|
|
137
|
-
$(_ref.current).update(value);
|
|
138
|
-
} else {
|
|
139
|
-
console.log("Trans updateContent: _ref.current is null/undefined");
|
|
112
|
+
_ref.current.textContent = value;
|
|
140
113
|
}
|
|
141
114
|
};
|
|
142
115
|
_ref.updateValues = (newValues) => {
|
|
143
|
-
console.log("Trans updateValues called with:", newValues);
|
|
144
116
|
values = newValues;
|
|
145
117
|
updateContent();
|
|
146
118
|
};
|
|
147
119
|
const onMount = () => {
|
|
148
|
-
console.log("Trans onMount called for key:", key);
|
|
149
120
|
i18n.subscribe(updateContent);
|
|
121
|
+
if (attrs.onMount) {
|
|
122
|
+
attrs.onMount(_ref.current);
|
|
123
|
+
}
|
|
150
124
|
};
|
|
151
125
|
const onUnmount = () => {
|
|
152
|
-
console.log("Trans onUnmount called for key:", key);
|
|
153
126
|
i18n.unsubscribe(updateContent);
|
|
127
|
+
if (attrs.onUnmount) {
|
|
128
|
+
attrs.onUnmount(_ref.current);
|
|
129
|
+
}
|
|
154
130
|
};
|
|
155
|
-
console.log(
|
|
156
|
-
"Trans component creating for key:",
|
|
157
|
-
key,
|
|
158
|
-
"with initial value:",
|
|
159
|
-
i18n.t(key, values)
|
|
160
|
-
);
|
|
161
131
|
return {
|
|
162
132
|
type: tag || "span",
|
|
163
133
|
attributes: {
|
|
@@ -170,6 +140,7 @@ const Trans = ({
|
|
|
170
140
|
children: i18n.t(key, values)
|
|
171
141
|
};
|
|
172
142
|
};
|
|
143
|
+
const T = Trans;
|
|
173
144
|
|
|
174
145
|
const tokenizePath = (path) => {
|
|
175
146
|
const paramNameRegexp = /:([^\/\.\\]+)/g;
|
|
@@ -452,4 +423,4 @@ const Async = ({
|
|
|
452
423
|
};
|
|
453
424
|
const Suspense = Async;
|
|
454
425
|
|
|
455
|
-
export { $, Async, Redirect, Route, Router, RouterSlot, RouterSlotId, Suspense, Trans, createI18n, createRef, createStore, i18n, inDevMode, isRef, matchRouteRegistrations, setupRouter, tokenizePath };
|
|
426
|
+
export { $, Async, Redirect, Route, Router, RouterSlot, RouterSlotId, Suspense, T, Trans, changeLanguage, createI18n, createRef, createStore, i18n, inDevMode, isRef, language, loadLanguage, matchRouteRegistrations, setupRouter, t, tokenizePath };
|
package/dist/render/client.cjs
CHANGED
package/dist/render/client.d.cts
CHANGED
|
@@ -4,7 +4,7 @@ import * as CSS from 'csstype';
|
|
|
4
4
|
export { CSS };
|
|
5
5
|
|
|
6
6
|
declare const renderSync: <T extends RenderInput>(virtualNode: T, parentDomElement?: ParentElementInput) => RenderResult<T>;
|
|
7
|
-
declare const render: <T extends RenderInput>(virtualNode: T | Promise<T>, parentDomElement?: ParentElementInputAsync) => Promise<RenderResult<T>>;
|
|
7
|
+
declare const render: <T extends RenderInput>(virtualNode: T | Promise<T>, parentDomElement?: ParentElementInputAsync | any) => Promise<RenderResult<T>>;
|
|
8
8
|
declare const renderToString: (el: Node) => string;
|
|
9
9
|
declare const hydrate: (nodes: Array<VNode | string | null>, parentElements: Array<HTMLElement | Text | Node>, debug?: boolean) => void;
|
|
10
10
|
|
package/dist/render/client.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as CSS from 'csstype';
|
|
|
4
4
|
export { CSS };
|
|
5
5
|
|
|
6
6
|
declare const renderSync: <T extends RenderInput>(virtualNode: T, parentDomElement?: ParentElementInput) => RenderResult<T>;
|
|
7
|
-
declare const render: <T extends RenderInput>(virtualNode: T | Promise<T>, parentDomElement?: ParentElementInputAsync) => Promise<RenderResult<T>>;
|
|
7
|
+
declare const render: <T extends RenderInput>(virtualNode: T | Promise<T>, parentDomElement?: ParentElementInputAsync | any) => Promise<RenderResult<T>>;
|
|
8
8
|
declare const renderToString: (el: Node) => string;
|
|
9
9
|
declare const hydrate: (nodes: Array<VNode | string | null>, parentElements: Array<HTMLElement | Text | Node>, debug?: boolean) => void;
|
|
10
10
|
|
package/dist/render/client.mjs
CHANGED
package/dist/render/server.d.cts
CHANGED
|
@@ -10,7 +10,7 @@ interface RenderOptions {
|
|
|
10
10
|
createRoot?: boolean;
|
|
11
11
|
}
|
|
12
12
|
declare const renderSync: <T extends RenderInput>(virtualNode: T, parentDomElement?: ParentElementInput, options?: RenderOptions) => RenderResult<T>;
|
|
13
|
-
declare const render: <T extends RenderInput>(virtualNode: T, parentDomElement?: ParentElementInputAsync, options?: RenderOptions) => Promise<RenderResult<T>>;
|
|
13
|
+
declare const render: <T extends RenderInput>(virtualNode: T, parentDomElement?: ParentElementInputAsync | any, options?: RenderOptions) => Promise<RenderResult<T>>;
|
|
14
14
|
declare const createRoot: (document: Document) => Element;
|
|
15
15
|
declare const getBrowserGlobals: () => Globals;
|
|
16
16
|
declare const getDocument: (shouldCreateRoot?: boolean, browserGlobals?: Globals) => Document;
|
package/dist/render/server.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ interface RenderOptions {
|
|
|
10
10
|
createRoot?: boolean;
|
|
11
11
|
}
|
|
12
12
|
declare const renderSync: <T extends RenderInput>(virtualNode: T, parentDomElement?: ParentElementInput, options?: RenderOptions) => RenderResult<T>;
|
|
13
|
-
declare const render: <T extends RenderInput>(virtualNode: T, parentDomElement?: ParentElementInputAsync, options?: RenderOptions) => Promise<RenderResult<T>>;
|
|
13
|
+
declare const render: <T extends RenderInput>(virtualNode: T, parentDomElement?: ParentElementInputAsync | any, options?: RenderOptions) => Promise<RenderResult<T>>;
|
|
14
14
|
declare const createRoot: (document: Document) => Element;
|
|
15
15
|
declare const getBrowserGlobals: () => Globals;
|
|
16
16
|
declare const getDocument: (shouldCreateRoot?: boolean, browserGlobals?: Globals) => Document;
|