@nocios/crudify-ui 3.0.40 → 3.0.44
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.js +51 -10
- package/dist/index.mjs +51 -10
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -84,16 +84,30 @@ var import_react2 = require("react");
|
|
|
84
84
|
// src/components/CrudifyLogin/hooks/useTranslationsFromUrl.ts
|
|
85
85
|
var import_react = require("react");
|
|
86
86
|
var useTranslationsFromUrl = (url, providedTranslations) => {
|
|
87
|
-
const [translations, setTranslations] = (0, import_react.useState)(
|
|
88
|
-
const [loading, setLoading] = (0, import_react.useState)(
|
|
87
|
+
const [translations, setTranslations] = (0, import_react.useState)({});
|
|
88
|
+
const [loading, setLoading] = (0, import_react.useState)(false);
|
|
89
89
|
const [error, setError] = (0, import_react.useState)(null);
|
|
90
90
|
(0, import_react.useEffect)(() => {
|
|
91
|
+
console.log("\u{1F527} [I18nProvider] Hybrid translation loading:", {
|
|
92
|
+
hasProvidedTranslations: !!providedTranslations && Object.keys(providedTranslations).length > 0,
|
|
93
|
+
hasUrl: !!url,
|
|
94
|
+
providedKeys: providedTranslations ? Object.keys(providedTranslations).length : 0
|
|
95
|
+
});
|
|
96
|
+
if (providedTranslations && Object.keys(providedTranslations).length > 0) {
|
|
97
|
+
console.log("\u2705 [I18nProvider] Using provided translations (highest priority)");
|
|
98
|
+
setTranslations(providedTranslations);
|
|
99
|
+
setLoading(false);
|
|
100
|
+
setError(null);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
91
103
|
if (!url) {
|
|
92
|
-
|
|
104
|
+
console.log("\u26A0\uFE0F [I18nProvider] No translations provided, using empty object (keys will show as-is)");
|
|
105
|
+
setTranslations({});
|
|
93
106
|
setLoading(false);
|
|
94
107
|
setError(null);
|
|
95
108
|
return;
|
|
96
109
|
}
|
|
110
|
+
console.log("\u{1F310} [I18nProvider] Loading translations from URL:", url);
|
|
97
111
|
let isCancelled = false;
|
|
98
112
|
setLoading(true);
|
|
99
113
|
setError(null);
|
|
@@ -104,14 +118,19 @@ var useTranslationsFromUrl = (url, providedTranslations) => {
|
|
|
104
118
|
return response.json();
|
|
105
119
|
}).then((data) => {
|
|
106
120
|
if (!isCancelled) {
|
|
121
|
+
console.log("\u2705 [I18nProvider] Translations loaded successfully from URL:", {
|
|
122
|
+
url,
|
|
123
|
+
keysLoaded: Object.keys(data).length
|
|
124
|
+
});
|
|
107
125
|
setTranslations(data);
|
|
108
126
|
setLoading(false);
|
|
109
127
|
}
|
|
110
128
|
}).catch((err) => {
|
|
111
129
|
if (!isCancelled) {
|
|
112
|
-
console.error("
|
|
130
|
+
console.error("\u274C [I18nProvider] Failed to load translations from URL:", url, err);
|
|
113
131
|
setError(err.message);
|
|
114
|
-
|
|
132
|
+
console.log("\u{1F504} [I18nProvider] Falling back to empty translations (keys will show as-is)");
|
|
133
|
+
setTranslations({});
|
|
115
134
|
setLoading(false);
|
|
116
135
|
}
|
|
117
136
|
});
|
|
@@ -139,7 +158,11 @@ var I18nProvider = ({ children, translations, translationsUrl, language = "en" }
|
|
|
139
158
|
const { translations: loadedTranslations, loading } = useTranslationsFromUrl(translationsUrl, translations);
|
|
140
159
|
const t = (0, import_react2.useMemo)(() => {
|
|
141
160
|
return (key, variables) => {
|
|
142
|
-
let value = getNestedValue(loadedTranslations, key)
|
|
161
|
+
let value = getNestedValue(loadedTranslations, key);
|
|
162
|
+
if (value === void 0 || value === null) {
|
|
163
|
+
console.log(`\u{1F50D} [I18nProvider] Translation not found for key: "${key}" - showing key as-is`);
|
|
164
|
+
value = key;
|
|
165
|
+
}
|
|
143
166
|
if (variables && typeof value === "string") {
|
|
144
167
|
Object.entries(variables).forEach(([varKey, varValue]) => {
|
|
145
168
|
value = value.replace(new RegExp(`{{${varKey}}}`, "g"), varValue);
|
|
@@ -1829,6 +1852,9 @@ function translateErrorCode(errorCode, config) {
|
|
|
1829
1852
|
}
|
|
1830
1853
|
for (const key of translationKeys) {
|
|
1831
1854
|
const translated = translateFn(key);
|
|
1855
|
+
if (enableDebug) {
|
|
1856
|
+
console.log(`\u{1F50D} [ErrorTranslation] Checking key: "${key}" -> result: "${translated}" (same as key: ${translated === key})`);
|
|
1857
|
+
}
|
|
1832
1858
|
if (translated && translated !== key) {
|
|
1833
1859
|
if (enableDebug) {
|
|
1834
1860
|
console.log(`\u2705 [ErrorTranslation] Found translation at key: ${key} = "${translated}"`);
|
|
@@ -1857,13 +1883,25 @@ function translateError(error, config) {
|
|
|
1857
1883
|
if (enableDebug) {
|
|
1858
1884
|
console.log(`\u{1F50D} [ErrorTranslation] Translating error:`, error);
|
|
1859
1885
|
}
|
|
1860
|
-
|
|
1886
|
+
const translatedCode = translateErrorCode(error.code, config);
|
|
1887
|
+
if (translatedCode !== error.code.toUpperCase() && translatedCode !== error.code) {
|
|
1888
|
+
if (enableDebug) {
|
|
1889
|
+
console.log(`\u2705 [ErrorTranslation] Using hierarchical translation: "${translatedCode}"`);
|
|
1890
|
+
}
|
|
1891
|
+
if (error.field) {
|
|
1892
|
+
return `${error.field}: ${translatedCode}`;
|
|
1893
|
+
}
|
|
1894
|
+
return translatedCode;
|
|
1895
|
+
}
|
|
1896
|
+
if (error.message && !error.message.includes("Error:") && error.message.length > 0 && error.message !== error.code) {
|
|
1861
1897
|
if (enableDebug) {
|
|
1862
|
-
console.log(`\
|
|
1898
|
+
console.log(`\u{1F504} [ErrorTranslation] No hierarchical translation found, using API message: "${error.message}"`);
|
|
1863
1899
|
}
|
|
1864
1900
|
return error.message;
|
|
1865
1901
|
}
|
|
1866
|
-
|
|
1902
|
+
if (enableDebug) {
|
|
1903
|
+
console.log(`\u26A0\uFE0F [ErrorTranslation] Using final fallback: "${translatedCode}"`);
|
|
1904
|
+
}
|
|
1867
1905
|
if (error.field) {
|
|
1868
1906
|
return `${error.field}: ${translatedCode}`;
|
|
1869
1907
|
}
|
|
@@ -1926,11 +1964,14 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
|
|
|
1926
1964
|
return () => clearTimeout(timer);
|
|
1927
1965
|
}, []);
|
|
1928
1966
|
const translateError2 = (parsedError) => {
|
|
1929
|
-
|
|
1967
|
+
console.log("\u{1F50D} [LoginForm] Translating parsed error:", parsedError);
|
|
1968
|
+
const result = errorTranslator.translateError({
|
|
1930
1969
|
code: parsedError.code,
|
|
1931
1970
|
message: parsedError.message,
|
|
1932
1971
|
field: parsedError.field
|
|
1933
1972
|
});
|
|
1973
|
+
console.log("\u{1F50D} [LoginForm] Translation result:", result);
|
|
1974
|
+
return result;
|
|
1934
1975
|
};
|
|
1935
1976
|
const handleLogin = async () => {
|
|
1936
1977
|
if (state.loading) return;
|
package/dist/index.mjs
CHANGED
|
@@ -11,16 +11,30 @@ import { createContext, useContext, useMemo } from "react";
|
|
|
11
11
|
// src/components/CrudifyLogin/hooks/useTranslationsFromUrl.ts
|
|
12
12
|
import { useState, useEffect } from "react";
|
|
13
13
|
var useTranslationsFromUrl = (url, providedTranslations) => {
|
|
14
|
-
const [translations, setTranslations] = useState(
|
|
15
|
-
const [loading, setLoading] = useState(
|
|
14
|
+
const [translations, setTranslations] = useState({});
|
|
15
|
+
const [loading, setLoading] = useState(false);
|
|
16
16
|
const [error, setError] = useState(null);
|
|
17
17
|
useEffect(() => {
|
|
18
|
+
console.log("\u{1F527} [I18nProvider] Hybrid translation loading:", {
|
|
19
|
+
hasProvidedTranslations: !!providedTranslations && Object.keys(providedTranslations).length > 0,
|
|
20
|
+
hasUrl: !!url,
|
|
21
|
+
providedKeys: providedTranslations ? Object.keys(providedTranslations).length : 0
|
|
22
|
+
});
|
|
23
|
+
if (providedTranslations && Object.keys(providedTranslations).length > 0) {
|
|
24
|
+
console.log("\u2705 [I18nProvider] Using provided translations (highest priority)");
|
|
25
|
+
setTranslations(providedTranslations);
|
|
26
|
+
setLoading(false);
|
|
27
|
+
setError(null);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
18
30
|
if (!url) {
|
|
19
|
-
|
|
31
|
+
console.log("\u26A0\uFE0F [I18nProvider] No translations provided, using empty object (keys will show as-is)");
|
|
32
|
+
setTranslations({});
|
|
20
33
|
setLoading(false);
|
|
21
34
|
setError(null);
|
|
22
35
|
return;
|
|
23
36
|
}
|
|
37
|
+
console.log("\u{1F310} [I18nProvider] Loading translations from URL:", url);
|
|
24
38
|
let isCancelled = false;
|
|
25
39
|
setLoading(true);
|
|
26
40
|
setError(null);
|
|
@@ -31,14 +45,19 @@ var useTranslationsFromUrl = (url, providedTranslations) => {
|
|
|
31
45
|
return response.json();
|
|
32
46
|
}).then((data) => {
|
|
33
47
|
if (!isCancelled) {
|
|
48
|
+
console.log("\u2705 [I18nProvider] Translations loaded successfully from URL:", {
|
|
49
|
+
url,
|
|
50
|
+
keysLoaded: Object.keys(data).length
|
|
51
|
+
});
|
|
34
52
|
setTranslations(data);
|
|
35
53
|
setLoading(false);
|
|
36
54
|
}
|
|
37
55
|
}).catch((err) => {
|
|
38
56
|
if (!isCancelled) {
|
|
39
|
-
console.error("
|
|
57
|
+
console.error("\u274C [I18nProvider] Failed to load translations from URL:", url, err);
|
|
40
58
|
setError(err.message);
|
|
41
|
-
|
|
59
|
+
console.log("\u{1F504} [I18nProvider] Falling back to empty translations (keys will show as-is)");
|
|
60
|
+
setTranslations({});
|
|
42
61
|
setLoading(false);
|
|
43
62
|
}
|
|
44
63
|
});
|
|
@@ -66,7 +85,11 @@ var I18nProvider = ({ children, translations, translationsUrl, language = "en" }
|
|
|
66
85
|
const { translations: loadedTranslations, loading } = useTranslationsFromUrl(translationsUrl, translations);
|
|
67
86
|
const t = useMemo(() => {
|
|
68
87
|
return (key, variables) => {
|
|
69
|
-
let value = getNestedValue(loadedTranslations, key)
|
|
88
|
+
let value = getNestedValue(loadedTranslations, key);
|
|
89
|
+
if (value === void 0 || value === null) {
|
|
90
|
+
console.log(`\u{1F50D} [I18nProvider] Translation not found for key: "${key}" - showing key as-is`);
|
|
91
|
+
value = key;
|
|
92
|
+
}
|
|
70
93
|
if (variables && typeof value === "string") {
|
|
71
94
|
Object.entries(variables).forEach(([varKey, varValue]) => {
|
|
72
95
|
value = value.replace(new RegExp(`{{${varKey}}}`, "g"), varValue);
|
|
@@ -1756,6 +1779,9 @@ function translateErrorCode(errorCode, config) {
|
|
|
1756
1779
|
}
|
|
1757
1780
|
for (const key of translationKeys) {
|
|
1758
1781
|
const translated = translateFn(key);
|
|
1782
|
+
if (enableDebug) {
|
|
1783
|
+
console.log(`\u{1F50D} [ErrorTranslation] Checking key: "${key}" -> result: "${translated}" (same as key: ${translated === key})`);
|
|
1784
|
+
}
|
|
1759
1785
|
if (translated && translated !== key) {
|
|
1760
1786
|
if (enableDebug) {
|
|
1761
1787
|
console.log(`\u2705 [ErrorTranslation] Found translation at key: ${key} = "${translated}"`);
|
|
@@ -1784,13 +1810,25 @@ function translateError(error, config) {
|
|
|
1784
1810
|
if (enableDebug) {
|
|
1785
1811
|
console.log(`\u{1F50D} [ErrorTranslation] Translating error:`, error);
|
|
1786
1812
|
}
|
|
1787
|
-
|
|
1813
|
+
const translatedCode = translateErrorCode(error.code, config);
|
|
1814
|
+
if (translatedCode !== error.code.toUpperCase() && translatedCode !== error.code) {
|
|
1815
|
+
if (enableDebug) {
|
|
1816
|
+
console.log(`\u2705 [ErrorTranslation] Using hierarchical translation: "${translatedCode}"`);
|
|
1817
|
+
}
|
|
1818
|
+
if (error.field) {
|
|
1819
|
+
return `${error.field}: ${translatedCode}`;
|
|
1820
|
+
}
|
|
1821
|
+
return translatedCode;
|
|
1822
|
+
}
|
|
1823
|
+
if (error.message && !error.message.includes("Error:") && error.message.length > 0 && error.message !== error.code) {
|
|
1788
1824
|
if (enableDebug) {
|
|
1789
|
-
console.log(`\
|
|
1825
|
+
console.log(`\u{1F504} [ErrorTranslation] No hierarchical translation found, using API message: "${error.message}"`);
|
|
1790
1826
|
}
|
|
1791
1827
|
return error.message;
|
|
1792
1828
|
}
|
|
1793
|
-
|
|
1829
|
+
if (enableDebug) {
|
|
1830
|
+
console.log(`\u26A0\uFE0F [ErrorTranslation] Using final fallback: "${translatedCode}"`);
|
|
1831
|
+
}
|
|
1794
1832
|
if (error.field) {
|
|
1795
1833
|
return `${error.field}: ${translatedCode}`;
|
|
1796
1834
|
}
|
|
@@ -1853,11 +1891,14 @@ var LoginForm = ({ onScreenChange, onExternalNavigate, onLoginSuccess, onError,
|
|
|
1853
1891
|
return () => clearTimeout(timer);
|
|
1854
1892
|
}, []);
|
|
1855
1893
|
const translateError2 = (parsedError) => {
|
|
1856
|
-
|
|
1894
|
+
console.log("\u{1F50D} [LoginForm] Translating parsed error:", parsedError);
|
|
1895
|
+
const result = errorTranslator.translateError({
|
|
1857
1896
|
code: parsedError.code,
|
|
1858
1897
|
message: parsedError.message,
|
|
1859
1898
|
field: parsedError.field
|
|
1860
1899
|
});
|
|
1900
|
+
console.log("\u{1F50D} [LoginForm] Translation result:", result);
|
|
1901
|
+
return result;
|
|
1861
1902
|
};
|
|
1862
1903
|
const handleLogin = async () => {
|
|
1863
1904
|
if (state.loading) return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocios/crudify-ui",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.44",
|
|
4
4
|
"description": "Biblioteca de componentes UI para Crudify",
|
|
5
5
|
"author": "Nocios",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@mui/icons-material": "^7.1.0",
|
|
26
26
|
"@mui/material": "^7.1.0",
|
|
27
27
|
"@mui/x-data-grid": "^8.5.1",
|
|
28
|
-
"@nocios/crudify-browser": "^2.0.
|
|
28
|
+
"@nocios/crudify-browser": "^2.0.2",
|
|
29
29
|
"@types/uuid": "^10.0.0",
|
|
30
30
|
"crypto-js": "^4.2.0",
|
|
31
31
|
"i18next-browser-languagedetector": "^8.1.0",
|