@@ -181,11 +181,28 @@ public async Task GeneratePageI18nFile()
181181
182182 var result = await Translation ( "zh" , targetLang , $ "{ gen . Value } ") ;
183183
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 ( "'" ) )
185201 {
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 ( "'" , "\\ '" ) ;
188203 }
204+
205+ str += ( $ " { gen . Key } : '{ translationValue } ',{ Environment . NewLine } ") ;
189206 }
190207 catch ( Exception e )
191208 {
@@ -270,11 +287,28 @@ public async Task GenerateMenuI18nFile()
270287
271288 var result = await Translation ( "zh" , targetLang , $ "{ gen . Value } ") ;
272289
273- if ( result . error_code . Equals ( "0" ) )
290+
291+ if ( ! result . error_code . Equals ( "0" ) )
274292 {
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 ;
277303 }
304+
305+ // 如果翻译结果包含"'" 法语意大利语常出现 在"'"前加转义符
306+ if ( translationValue . Contains ( "'" ) )
307+ {
308+ translationValue = translationValue . Replace ( "'" , "\\ '" ) ;
309+ }
310+
311+ str += ( $ " { gen . Key } : '{ translationValue } ',{ Environment . NewLine } ") ;
278312 }
279313 catch ( Exception e )
280314 {
0 commit comments