@@ -181,11 +181,28 @@ public async Task GeneratePageI18nFile()
181
181
182
182
var result = await Translation ( "zh" , targetLang , $ "{ gen . Value } ") ;
183
183
184
- if ( result . error_code . Equals ( "0" ) )
184
+
185
+ if ( ! result . error_code . Equals ( "0" ) )
186
+ {
187
+ continue ;
188
+ }
189
+
190
+ var translationValue = result . trans_result [ 0 ] . Dst ;
191
+ LogTranslationProgress ( gen . Key , gen . Value , translationValue , ConsoleColor . DarkMagenta ) ;
192
+
193
+ // 如果翻译结果为空字符串不追加
194
+ if ( string . IsNullOrEmpty ( translationValue ) )
195
+ {
196
+ continue ;
197
+ }
198
+
199
+ // 如果翻译结果包含"'" 法语意大利语常出现 在"'"前加转义符
200
+ if ( translationValue . Contains ( "'" ) )
185
201
{
186
- LogTranslationProgress ( gen . Key , gen . Value , result . trans_result [ 0 ] . Dst , ConsoleColor . DarkMagenta ) ;
187
- str += ( $ " { gen . Key } : '{ result . trans_result [ 0 ] . Dst } ',{ Environment . NewLine } ") ;
202
+ translationValue = translationValue . Replace ( "'" , "\\ '" ) ;
188
203
}
204
+
205
+ str += ( $ " { gen . Key } : '{ translationValue } ',{ Environment . NewLine } ") ;
189
206
}
190
207
catch ( Exception e )
191
208
{
@@ -270,11 +287,28 @@ public async Task GenerateMenuI18nFile()
270
287
271
288
var result = await Translation ( "zh" , targetLang , $ "{ gen . Value } ") ;
272
289
273
- if ( result . error_code . Equals ( "0" ) )
290
+
291
+ if ( ! result . error_code . Equals ( "0" ) )
274
292
{
275
- LogTranslationProgress ( gen . Key , gen . Value , result . trans_result [ 0 ] . Dst , ConsoleColor . DarkMagenta ) ;
276
- str += ( $ " { gen . Key } : '{ result . trans_result [ 0 ] . Dst } ',{ Environment . NewLine } ") ;
293
+ continue ;
294
+ }
295
+
296
+ var translationValue = result . trans_result [ 0 ] . Dst ;
297
+ LogTranslationProgress ( gen . Key , gen . Value , translationValue , ConsoleColor . DarkMagenta ) ;
298
+
299
+ // 如果翻译结果为空字符串不追加
300
+ if ( string . IsNullOrEmpty ( translationValue ) )
301
+ {
302
+ continue ;
277
303
}
304
+
305
+ // 如果翻译结果包含"'" 法语意大利语常出现 在"'"前加转义符
306
+ if ( translationValue . Contains ( "'" ) )
307
+ {
308
+ translationValue = translationValue . Replace ( "'" , "\\ '" ) ;
309
+ }
310
+
311
+ str += ( $ " { gen . Key } : '{ translationValue } ',{ Environment . NewLine } ") ;
278
312
}
279
313
catch ( Exception e )
280
314
{
0 commit comments