@agentscope-ai/i18n 1.0.0 → 1.0.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.
|
@@ -154,7 +154,7 @@ const translateAndUpdateFiles = async (
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
// 询问是否生成medusa excel文件
|
|
157
|
-
if (medusa && medusa.appName && medusa.
|
|
157
|
+
if (medusa && medusa.appName && medusa.keyMap) {
|
|
158
158
|
let shouldGenExcel = skipConfirm;
|
|
159
159
|
if (!skipConfirm) {
|
|
160
160
|
const excelAnswer = await askQuestion('是否需要生成medusa excel文件?(y/n): ');
|
|
@@ -297,7 +297,7 @@ const singleTranslateAndUpdateFiles = async (
|
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
// 询问是否生成medusa excel文件
|
|
300
|
-
if (medusa && medusa.appName && medusa.
|
|
300
|
+
if (medusa && medusa.appName && medusa.keyMap) {
|
|
301
301
|
let shouldGenExcel = skipConfirm;
|
|
302
302
|
if (!skipConfirm) {
|
|
303
303
|
const excelAnswer = await askQuestion('是否需要生成medusa excel文件?(y/n): ');
|
package/lib/core/translator.js
CHANGED
|
@@ -1216,7 +1216,7 @@ const translate = async function (sourcePath, params) {
|
|
|
1216
1216
|
);
|
|
1217
1217
|
console.log(` [完成] 翻译状态已保存到 ${statePath}`);
|
|
1218
1218
|
|
|
1219
|
-
if (medusa && medusa.appName && medusa.
|
|
1219
|
+
if (medusa && medusa.appName && medusa.keyMap) {
|
|
1220
1220
|
try {
|
|
1221
1221
|
await generateMedusaExcel({ localesFilePath, medusa, newKeys });
|
|
1222
1222
|
} catch (error) {
|
package/lib/utils/excel-utils.js
CHANGED
|
@@ -8,7 +8,7 @@ const path = require('path');
|
|
|
8
8
|
* @param {string} params.localesFilePath 翻译文件目录
|
|
9
9
|
* @param {Object} params.medusa medusa配置
|
|
10
10
|
* @param {string} params.medusa.appName 应用名称
|
|
11
|
-
* @param {string} params.medusa.group
|
|
11
|
+
* @param {string} [params.medusa.group] 分组名称(可为空字符串)
|
|
12
12
|
* @param {Object} params.medusa.keyMap 语言映射配置
|
|
13
13
|
* @param {Array} params.newKeys 新增的翻译key列表
|
|
14
14
|
* @returns {string} 生成的excel文件路径
|
|
@@ -16,10 +16,13 @@ const path = require('path');
|
|
|
16
16
|
const generateMedusaExcel = async (params) => {
|
|
17
17
|
const { localesFilePath, medusa, newKeys, customData } = params;
|
|
18
18
|
|
|
19
|
-
if (!medusa || !medusa.appName || !medusa.
|
|
20
|
-
throw new Error('medusa配置不完整,需要appName
|
|
19
|
+
if (!medusa || !medusa.appName || !medusa.keyMap) {
|
|
20
|
+
throw new Error('medusa配置不完整,需要 appName 和 keyMap(group 可选,可为空字符串)');
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
// group 允许 '',不能用 !medusa.group 判断
|
|
24
|
+
const group = medusa.group == null ? '' : String(medusa.group);
|
|
25
|
+
|
|
23
26
|
// 读取所有翻译文件
|
|
24
27
|
const translationFiles = {};
|
|
25
28
|
|
|
@@ -59,7 +62,7 @@ const generateMedusaExcel = async (params) => {
|
|
|
59
62
|
for (const key of keysToProcess) {
|
|
60
63
|
const row = {
|
|
61
64
|
AppName: medusa.appName,
|
|
62
|
-
Group:
|
|
65
|
+
Group: group,
|
|
63
66
|
Key: key,
|
|
64
67
|
};
|
|
65
68
|
|