i18ntk 3.1.2 → 3.3.0
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/CHANGELOG.md +94 -23
- package/README.md +29 -23
- package/SECURITY.md +19 -5
- package/main/i18ntk-complete.js +120 -49
- package/main/i18ntk-translate.js +25 -1
- package/main/manage/index.js +0 -2
- package/main/manage/managers/InteractiveMenu.js +4 -0
- package/main/manage/services/FileManagementService.js +14 -11
- package/package.json +5 -3
- package/runtime/enhanced.d.ts +1 -1
- package/runtime/i18ntk.d.ts +2 -11
- package/ui-locales/de.json +1389 -1359
- package/ui-locales/es.json +1503 -1473
- package/ui-locales/fr.json +1626 -1596
- package/ui-locales/ja.json +1595 -1565
- package/ui-locales/ru.json +1638 -1608
- package/ui-locales/zh.json +1613 -1583
- package/utils/admin-auth.js +6 -6
- package/utils/config-manager.js +6 -3
- package/utils/translate/api.js +172 -41
- package/utils/translate/safe-network.js +280 -0
- package/utils/translate/traverse.js +14 -25
|
@@ -54,7 +54,7 @@ function collectLeaves(obj, prefix = '') {
|
|
|
54
54
|
return entries;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
function
|
|
57
|
+
function parseKeyPath(keyPath) {
|
|
58
58
|
const parts = [];
|
|
59
59
|
let current = '';
|
|
60
60
|
for (let i = 0; i < keyPath.length; i++) {
|
|
@@ -77,13 +77,18 @@ function setLeaf(obj, keyPath, value) {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
if (current) parts.push(current);
|
|
80
|
+
return parts;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function setLeaf(obj, keyPath, value) {
|
|
84
|
+
const parts = parseKeyPath(keyPath);
|
|
80
85
|
|
|
81
86
|
let target = obj;
|
|
82
87
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
83
88
|
const part = parts[i];
|
|
84
89
|
if (part.startsWith('[') && part.endsWith(']')) {
|
|
85
90
|
const idx = parseInt(part.slice(1, -1), 10);
|
|
86
|
-
if (!(idx in target)) target[idx] =
|
|
91
|
+
if (!(idx in target)) target[idx] = [];
|
|
87
92
|
target = target[idx];
|
|
88
93
|
} else {
|
|
89
94
|
if (!(part in target)) target[part] = {};
|
|
@@ -100,28 +105,7 @@ function setLeaf(obj, keyPath, value) {
|
|
|
100
105
|
}
|
|
101
106
|
|
|
102
107
|
function getLeaf(obj, keyPath) {
|
|
103
|
-
const parts =
|
|
104
|
-
let current = '';
|
|
105
|
-
for (let i = 0; i < keyPath.length; i++) {
|
|
106
|
-
const ch = keyPath[i];
|
|
107
|
-
if (ch === '.' && keyPath[i - 1] !== '\\') {
|
|
108
|
-
if (current) parts.push(current);
|
|
109
|
-
current = '';
|
|
110
|
-
} else if (ch === '[') {
|
|
111
|
-
if (current) parts.push(current);
|
|
112
|
-
current = '';
|
|
113
|
-
i++;
|
|
114
|
-
while (i < keyPath.length && keyPath[i] !== ']') {
|
|
115
|
-
current += keyPath[i];
|
|
116
|
-
i++;
|
|
117
|
-
}
|
|
118
|
-
parts.push(`[${current}]`);
|
|
119
|
-
current = '';
|
|
120
|
-
} else {
|
|
121
|
-
current += ch;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
if (current) parts.push(current);
|
|
108
|
+
const parts = parseKeyPath(keyPath);
|
|
125
109
|
|
|
126
110
|
let target = obj;
|
|
127
111
|
for (const part of parts) {
|
|
@@ -136,7 +120,12 @@ function getLeaf(obj, keyPath) {
|
|
|
136
120
|
}
|
|
137
121
|
|
|
138
122
|
function deepClone(obj) {
|
|
139
|
-
|
|
123
|
+
if (obj === null || obj === undefined) return obj;
|
|
124
|
+
try {
|
|
125
|
+
return JSON.parse(JSON.stringify(obj));
|
|
126
|
+
} catch (e) {
|
|
127
|
+
return obj;
|
|
128
|
+
}
|
|
140
129
|
}
|
|
141
130
|
|
|
142
131
|
module.exports = {
|