|
|
|
@ -99,41 +99,22 @@ public class LoginController { |
|
|
|
str = str.replace("\n", ""); |
|
|
|
|
|
|
|
//翻译目标国家
|
|
|
|
String country = jsonObject.getStr("country"); |
|
|
|
String country = jsonObject.getStr("country","zh"); |
|
|
|
String trans = ""; |
|
|
|
|
|
|
|
//如果代理有配置,则使用代理的配置
|
|
|
|
String translateType = settingService.translateType(); |
|
|
|
switch (translateType) { |
|
|
|
case "0"://默认使用系统自带的百度翻译
|
|
|
|
if (country == null || country.isEmpty()) { |
|
|
|
trans = baiduTranslationUtils.translate(str, "zh"); |
|
|
|
} else { |
|
|
|
trans = baiduTranslationUtils.translate(str, country); |
|
|
|
} |
|
|
|
break; |
|
|
|
case "1": |
|
|
|
if (country == null || country.isEmpty()) { |
|
|
|
trans = baiduTranslationUtils.translateByAgentConfiguration(str, "zh"); |
|
|
|
} else { |
|
|
|
trans = baiduTranslationUtils.translateByAgentConfiguration(str, country); |
|
|
|
} |
|
|
|
break; |
|
|
|
case "2": |
|
|
|
if (country == null || country.isEmpty()) { |
|
|
|
trans = youDaoTranslationUtils.translateByAgentConfiguration(str, "zh"); |
|
|
|
} else { |
|
|
|
trans = youDaoTranslationUtils.translateByAgentConfiguration(str, country); |
|
|
|
} |
|
|
|
break; |
|
|
|
case "3": |
|
|
|
if (country == null || country.isEmpty()) { |
|
|
|
trans = googleTranslationUtils.translateByAgentConfiguration(str, "zh"); |
|
|
|
} else { |
|
|
|
trans = googleTranslationUtils.translateByAgentConfiguration(str, country); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
trans = switch (translateType) { |
|
|
|
case "0" ->//默认使用系统自带的百度翻译
|
|
|
|
baiduTranslationUtils.translate(str, country); |
|
|
|
case "1" ->//使用百度翻译
|
|
|
|
baiduTranslationUtils.translateByAgentConfiguration(str, country); |
|
|
|
case "2" ->//使用有道翻译
|
|
|
|
youDaoTranslationUtils.translateByAgentConfiguration(str, country); |
|
|
|
case "3" ->//使用谷歌翻译
|
|
|
|
googleTranslationUtils.translateByAgentConfiguration(str, country); |
|
|
|
default -> trans; |
|
|
|
}; |
|
|
|
|
|
|
|
return ResultUtils.success(trans,"success"); |
|
|
|
} |
|
|
|
|