@goenhance/strapi-plugins-translate 1.0.2 → 1.0.3
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/server/index.js +136 -71
- package/dist/server/index.mjs +136 -71
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -78,86 +78,134 @@ async function sendBatchTranslationNotification(contentType, sourceLocale, targe
|
|
|
78
78
|
is_short: true,
|
|
79
79
|
text: {
|
|
80
80
|
tag: "lark_md",
|
|
81
|
-
content:
|
|
81
|
+
content: `**📊 统计概览**
|
|
82
|
+
总条目: ${entriesByDocId.size}`
|
|
82
83
|
}
|
|
83
84
|
},
|
|
84
85
|
{
|
|
85
86
|
is_short: true,
|
|
86
87
|
text: {
|
|
87
88
|
tag: "lark_md",
|
|
88
|
-
content:
|
|
89
|
+
content: `**🎯 翻译结果**
|
|
90
|
+
✅ 成功: <font color='green'>${successResults.length}</font> ❌ 失败: <font color='red'>${failureResults.length}</font>`
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
]
|
|
92
94
|
});
|
|
95
|
+
elements.push({
|
|
96
|
+
tag: "hr"
|
|
97
|
+
});
|
|
93
98
|
elements.push({
|
|
94
99
|
tag: "div",
|
|
95
|
-
|
|
100
|
+
text: {
|
|
101
|
+
tag: "lark_md",
|
|
102
|
+
content: "**📋 详细信息**"
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
elements.push({
|
|
106
|
+
tag: "table",
|
|
107
|
+
page_size: 10,
|
|
108
|
+
header_style: {
|
|
109
|
+
text_align: "left",
|
|
110
|
+
text_size: "normal",
|
|
111
|
+
background_style: "grey",
|
|
112
|
+
bold: true,
|
|
113
|
+
lines: 1
|
|
114
|
+
},
|
|
115
|
+
columns: [
|
|
96
116
|
{
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
content: "**目标语言**\n" + targetLocales.join(", ")
|
|
101
|
-
}
|
|
117
|
+
name: "项目",
|
|
118
|
+
width: "auto",
|
|
119
|
+
data_type: "text"
|
|
102
120
|
},
|
|
103
121
|
{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
content: "**总条目数**\n" + entriesByDocId.size
|
|
108
|
-
}
|
|
122
|
+
name: "值",
|
|
123
|
+
width: "auto",
|
|
124
|
+
data_type: "text"
|
|
109
125
|
}
|
|
110
|
-
]
|
|
111
|
-
|
|
112
|
-
elements.push({
|
|
113
|
-
tag: "div",
|
|
114
|
-
fields: [
|
|
126
|
+
],
|
|
127
|
+
rows: [
|
|
115
128
|
{
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
<font color='green'>${successResults.length}</font>`
|
|
121
|
-
}
|
|
129
|
+
cells: [
|
|
130
|
+
{ text: "内容类型" },
|
|
131
|
+
{ text: contentType }
|
|
132
|
+
]
|
|
122
133
|
},
|
|
123
134
|
{
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
135
|
+
cells: [
|
|
136
|
+
{ text: "源语言" },
|
|
137
|
+
{ text: sourceLocale }
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
cells: [
|
|
142
|
+
{ text: "目标语言" },
|
|
143
|
+
{ text: targetLocales.join(", ") }
|
|
144
|
+
]
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
cells: [
|
|
148
|
+
{ text: "总条目数" },
|
|
149
|
+
{ text: String(entriesByDocId.size) }
|
|
150
|
+
]
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
cells: [
|
|
154
|
+
{ text: "✅ 成功翻译" },
|
|
155
|
+
{ text: String(successResults.length) }
|
|
156
|
+
]
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
cells: [
|
|
160
|
+
{ text: "❌ 失败翻译" },
|
|
161
|
+
{ text: String(failureResults.length) }
|
|
162
|
+
]
|
|
130
163
|
}
|
|
131
164
|
]
|
|
132
165
|
});
|
|
133
|
-
elements.push({
|
|
134
|
-
tag: "hr"
|
|
135
|
-
});
|
|
136
166
|
if (successResults.length > 0) {
|
|
137
167
|
elements.push({
|
|
138
168
|
tag: "div",
|
|
139
169
|
text: {
|
|
140
170
|
tag: "lark_md",
|
|
141
|
-
content: "**✅
|
|
171
|
+
content: "**✅ 成功翻译详情**"
|
|
142
172
|
}
|
|
143
173
|
});
|
|
144
|
-
|
|
174
|
+
const successRows = [];
|
|
175
|
+
entriesByDocId.forEach((entry) => {
|
|
145
176
|
if (entry.successes.length > 0) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
{
|
|
150
|
-
is_short: false,
|
|
151
|
-
text: {
|
|
152
|
-
tag: "lark_md",
|
|
153
|
-
content: `📄 **${entry.title}**
|
|
154
|
-
→ ${entry.successes.join(", ")}`
|
|
155
|
-
}
|
|
156
|
-
}
|
|
177
|
+
successRows.push({
|
|
178
|
+
cells: [
|
|
179
|
+
{ text: entry.title },
|
|
180
|
+
{ text: entry.successes.join(", ") }
|
|
157
181
|
]
|
|
158
182
|
});
|
|
159
183
|
}
|
|
160
184
|
});
|
|
185
|
+
elements.push({
|
|
186
|
+
tag: "table",
|
|
187
|
+
page_size: 10,
|
|
188
|
+
header_style: {
|
|
189
|
+
text_align: "left",
|
|
190
|
+
text_size: "normal",
|
|
191
|
+
background_style: "grey",
|
|
192
|
+
bold: true,
|
|
193
|
+
lines: 1
|
|
194
|
+
},
|
|
195
|
+
columns: [
|
|
196
|
+
{
|
|
197
|
+
name: "条目",
|
|
198
|
+
width: "auto",
|
|
199
|
+
data_type: "text"
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
name: "目标语言",
|
|
203
|
+
width: "auto",
|
|
204
|
+
data_type: "text"
|
|
205
|
+
}
|
|
206
|
+
],
|
|
207
|
+
rows: successRows
|
|
208
|
+
});
|
|
161
209
|
}
|
|
162
210
|
if (failureResults.length > 0) {
|
|
163
211
|
elements.push({
|
|
@@ -167,46 +215,63 @@ async function sendBatchTranslationNotification(contentType, sourceLocale, targe
|
|
|
167
215
|
tag: "div",
|
|
168
216
|
text: {
|
|
169
217
|
tag: "lark_md",
|
|
170
|
-
content: "**❌
|
|
218
|
+
content: "**❌ 失败翻译详情**"
|
|
171
219
|
}
|
|
172
220
|
});
|
|
173
|
-
|
|
221
|
+
const failureRows = [];
|
|
222
|
+
entriesByDocId.forEach((entry) => {
|
|
174
223
|
if (entry.failures.length > 0) {
|
|
175
224
|
entry.failures.forEach((failure) => {
|
|
176
|
-
const errorMsg = failure.message
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
{
|
|
182
|
-
is_short: false,
|
|
183
|
-
text: {
|
|
184
|
-
tag: "lark_md",
|
|
185
|
-
content: `📄 **${entry.title}**
|
|
186
|
-
→ ${failure.locale}${errorMsg}`
|
|
187
|
-
}
|
|
188
|
-
}
|
|
225
|
+
const errorMsg = failure.message || "未知错误";
|
|
226
|
+
failureRows.push({
|
|
227
|
+
cells: [
|
|
228
|
+
{ text: entry.title },
|
|
229
|
+
{ text: failure.locale },
|
|
230
|
+
{ text: errorMsg }
|
|
189
231
|
]
|
|
190
232
|
});
|
|
191
233
|
});
|
|
192
234
|
}
|
|
193
235
|
});
|
|
236
|
+
elements.push({
|
|
237
|
+
tag: "table",
|
|
238
|
+
page_size: 10,
|
|
239
|
+
header_style: {
|
|
240
|
+
text_align: "left",
|
|
241
|
+
text_size: "normal",
|
|
242
|
+
background_style: "grey",
|
|
243
|
+
bold: true,
|
|
244
|
+
lines: 1
|
|
245
|
+
},
|
|
246
|
+
columns: [
|
|
247
|
+
{
|
|
248
|
+
name: "条目",
|
|
249
|
+
width: "auto",
|
|
250
|
+
data_type: "text"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: "目标语言",
|
|
254
|
+
width: "auto",
|
|
255
|
+
data_type: "text"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: "错误信息",
|
|
259
|
+
width: "auto",
|
|
260
|
+
data_type: "text"
|
|
261
|
+
}
|
|
262
|
+
],
|
|
263
|
+
rows: failureRows
|
|
264
|
+
});
|
|
194
265
|
}
|
|
195
266
|
elements.push({
|
|
196
267
|
tag: "hr"
|
|
197
268
|
});
|
|
198
269
|
elements.push({
|
|
199
270
|
tag: "div",
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
tag: "lark_md",
|
|
205
|
-
content: `**⏰ 时间**
|
|
206
|
-
${(/* @__PURE__ */ new Date()).toLocaleString("zh-CN", { timeZone: "Asia/Shanghai" })}`
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
]
|
|
271
|
+
text: {
|
|
272
|
+
tag: "lark_md",
|
|
273
|
+
content: `⏰ **完成时间**: ${(/* @__PURE__ */ new Date()).toLocaleString("zh-CN", { timeZone: "Asia/Shanghai" })}`
|
|
274
|
+
}
|
|
210
275
|
});
|
|
211
276
|
try {
|
|
212
277
|
const message = {
|
package/dist/server/index.mjs
CHANGED
|
@@ -77,86 +77,134 @@ async function sendBatchTranslationNotification(contentType, sourceLocale, targe
|
|
|
77
77
|
is_short: true,
|
|
78
78
|
text: {
|
|
79
79
|
tag: "lark_md",
|
|
80
|
-
content:
|
|
80
|
+
content: `**📊 统计概览**
|
|
81
|
+
总条目: ${entriesByDocId.size}`
|
|
81
82
|
}
|
|
82
83
|
},
|
|
83
84
|
{
|
|
84
85
|
is_short: true,
|
|
85
86
|
text: {
|
|
86
87
|
tag: "lark_md",
|
|
87
|
-
content:
|
|
88
|
+
content: `**🎯 翻译结果**
|
|
89
|
+
✅ 成功: <font color='green'>${successResults.length}</font> ❌ 失败: <font color='red'>${failureResults.length}</font>`
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
92
|
]
|
|
91
93
|
});
|
|
94
|
+
elements.push({
|
|
95
|
+
tag: "hr"
|
|
96
|
+
});
|
|
92
97
|
elements.push({
|
|
93
98
|
tag: "div",
|
|
94
|
-
|
|
99
|
+
text: {
|
|
100
|
+
tag: "lark_md",
|
|
101
|
+
content: "**📋 详细信息**"
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
elements.push({
|
|
105
|
+
tag: "table",
|
|
106
|
+
page_size: 10,
|
|
107
|
+
header_style: {
|
|
108
|
+
text_align: "left",
|
|
109
|
+
text_size: "normal",
|
|
110
|
+
background_style: "grey",
|
|
111
|
+
bold: true,
|
|
112
|
+
lines: 1
|
|
113
|
+
},
|
|
114
|
+
columns: [
|
|
95
115
|
{
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
content: "**目标语言**\n" + targetLocales.join(", ")
|
|
100
|
-
}
|
|
116
|
+
name: "项目",
|
|
117
|
+
width: "auto",
|
|
118
|
+
data_type: "text"
|
|
101
119
|
},
|
|
102
120
|
{
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
content: "**总条目数**\n" + entriesByDocId.size
|
|
107
|
-
}
|
|
121
|
+
name: "值",
|
|
122
|
+
width: "auto",
|
|
123
|
+
data_type: "text"
|
|
108
124
|
}
|
|
109
|
-
]
|
|
110
|
-
|
|
111
|
-
elements.push({
|
|
112
|
-
tag: "div",
|
|
113
|
-
fields: [
|
|
125
|
+
],
|
|
126
|
+
rows: [
|
|
114
127
|
{
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
<font color='green'>${successResults.length}</font>`
|
|
120
|
-
}
|
|
128
|
+
cells: [
|
|
129
|
+
{ text: "内容类型" },
|
|
130
|
+
{ text: contentType }
|
|
131
|
+
]
|
|
121
132
|
},
|
|
122
133
|
{
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
134
|
+
cells: [
|
|
135
|
+
{ text: "源语言" },
|
|
136
|
+
{ text: sourceLocale }
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
cells: [
|
|
141
|
+
{ text: "目标语言" },
|
|
142
|
+
{ text: targetLocales.join(", ") }
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
cells: [
|
|
147
|
+
{ text: "总条目数" },
|
|
148
|
+
{ text: String(entriesByDocId.size) }
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
cells: [
|
|
153
|
+
{ text: "✅ 成功翻译" },
|
|
154
|
+
{ text: String(successResults.length) }
|
|
155
|
+
]
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
cells: [
|
|
159
|
+
{ text: "❌ 失败翻译" },
|
|
160
|
+
{ text: String(failureResults.length) }
|
|
161
|
+
]
|
|
129
162
|
}
|
|
130
163
|
]
|
|
131
164
|
});
|
|
132
|
-
elements.push({
|
|
133
|
-
tag: "hr"
|
|
134
|
-
});
|
|
135
165
|
if (successResults.length > 0) {
|
|
136
166
|
elements.push({
|
|
137
167
|
tag: "div",
|
|
138
168
|
text: {
|
|
139
169
|
tag: "lark_md",
|
|
140
|
-
content: "**✅
|
|
170
|
+
content: "**✅ 成功翻译详情**"
|
|
141
171
|
}
|
|
142
172
|
});
|
|
143
|
-
|
|
173
|
+
const successRows = [];
|
|
174
|
+
entriesByDocId.forEach((entry) => {
|
|
144
175
|
if (entry.successes.length > 0) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
{
|
|
149
|
-
is_short: false,
|
|
150
|
-
text: {
|
|
151
|
-
tag: "lark_md",
|
|
152
|
-
content: `📄 **${entry.title}**
|
|
153
|
-
→ ${entry.successes.join(", ")}`
|
|
154
|
-
}
|
|
155
|
-
}
|
|
176
|
+
successRows.push({
|
|
177
|
+
cells: [
|
|
178
|
+
{ text: entry.title },
|
|
179
|
+
{ text: entry.successes.join(", ") }
|
|
156
180
|
]
|
|
157
181
|
});
|
|
158
182
|
}
|
|
159
183
|
});
|
|
184
|
+
elements.push({
|
|
185
|
+
tag: "table",
|
|
186
|
+
page_size: 10,
|
|
187
|
+
header_style: {
|
|
188
|
+
text_align: "left",
|
|
189
|
+
text_size: "normal",
|
|
190
|
+
background_style: "grey",
|
|
191
|
+
bold: true,
|
|
192
|
+
lines: 1
|
|
193
|
+
},
|
|
194
|
+
columns: [
|
|
195
|
+
{
|
|
196
|
+
name: "条目",
|
|
197
|
+
width: "auto",
|
|
198
|
+
data_type: "text"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: "目标语言",
|
|
202
|
+
width: "auto",
|
|
203
|
+
data_type: "text"
|
|
204
|
+
}
|
|
205
|
+
],
|
|
206
|
+
rows: successRows
|
|
207
|
+
});
|
|
160
208
|
}
|
|
161
209
|
if (failureResults.length > 0) {
|
|
162
210
|
elements.push({
|
|
@@ -166,46 +214,63 @@ async function sendBatchTranslationNotification(contentType, sourceLocale, targe
|
|
|
166
214
|
tag: "div",
|
|
167
215
|
text: {
|
|
168
216
|
tag: "lark_md",
|
|
169
|
-
content: "**❌
|
|
217
|
+
content: "**❌ 失败翻译详情**"
|
|
170
218
|
}
|
|
171
219
|
});
|
|
172
|
-
|
|
220
|
+
const failureRows = [];
|
|
221
|
+
entriesByDocId.forEach((entry) => {
|
|
173
222
|
if (entry.failures.length > 0) {
|
|
174
223
|
entry.failures.forEach((failure) => {
|
|
175
|
-
const errorMsg = failure.message
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
{
|
|
181
|
-
is_short: false,
|
|
182
|
-
text: {
|
|
183
|
-
tag: "lark_md",
|
|
184
|
-
content: `📄 **${entry.title}**
|
|
185
|
-
→ ${failure.locale}${errorMsg}`
|
|
186
|
-
}
|
|
187
|
-
}
|
|
224
|
+
const errorMsg = failure.message || "未知错误";
|
|
225
|
+
failureRows.push({
|
|
226
|
+
cells: [
|
|
227
|
+
{ text: entry.title },
|
|
228
|
+
{ text: failure.locale },
|
|
229
|
+
{ text: errorMsg }
|
|
188
230
|
]
|
|
189
231
|
});
|
|
190
232
|
});
|
|
191
233
|
}
|
|
192
234
|
});
|
|
235
|
+
elements.push({
|
|
236
|
+
tag: "table",
|
|
237
|
+
page_size: 10,
|
|
238
|
+
header_style: {
|
|
239
|
+
text_align: "left",
|
|
240
|
+
text_size: "normal",
|
|
241
|
+
background_style: "grey",
|
|
242
|
+
bold: true,
|
|
243
|
+
lines: 1
|
|
244
|
+
},
|
|
245
|
+
columns: [
|
|
246
|
+
{
|
|
247
|
+
name: "条目",
|
|
248
|
+
width: "auto",
|
|
249
|
+
data_type: "text"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
name: "目标语言",
|
|
253
|
+
width: "auto",
|
|
254
|
+
data_type: "text"
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
name: "错误信息",
|
|
258
|
+
width: "auto",
|
|
259
|
+
data_type: "text"
|
|
260
|
+
}
|
|
261
|
+
],
|
|
262
|
+
rows: failureRows
|
|
263
|
+
});
|
|
193
264
|
}
|
|
194
265
|
elements.push({
|
|
195
266
|
tag: "hr"
|
|
196
267
|
});
|
|
197
268
|
elements.push({
|
|
198
269
|
tag: "div",
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
tag: "lark_md",
|
|
204
|
-
content: `**⏰ 时间**
|
|
205
|
-
${(/* @__PURE__ */ new Date()).toLocaleString("zh-CN", { timeZone: "Asia/Shanghai" })}`
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
]
|
|
270
|
+
text: {
|
|
271
|
+
tag: "lark_md",
|
|
272
|
+
content: `⏰ **完成时间**: ${(/* @__PURE__ */ new Date()).toLocaleString("zh-CN", { timeZone: "Asia/Shanghai" })}`
|
|
273
|
+
}
|
|
209
274
|
});
|
|
210
275
|
try {
|
|
211
276
|
const message = {
|
package/package.json
CHANGED