mirror of https://github.com/NekoX-Dev/NekoX.git
Refine translate
This commit is contained in:
parent
de604298a3
commit
907f0032ca
|
@ -53,7 +53,7 @@ public class NekoConfig {
|
|||
|
||||
public static String formatLang(String name) {
|
||||
|
||||
if (name == null) {
|
||||
if (name == null || name.isEmpty()) {
|
||||
|
||||
return LocaleController.getString("Default", R.string.Default);
|
||||
|
||||
|
|
|
@ -86,8 +86,8 @@ fun ChatActivity.translateMessages2(target: Locale) = translateMessages(target)
|
|||
@JvmName("translateMessages")
|
||||
fun ChatActivity.translateMessages3(messages: List<MessageObject>) = translateMessages(messages = messages)
|
||||
|
||||
fun ChatActivity.translateMessages(target: Locale = NekomuraConfig.translateToLang.String()?.code2Locale
|
||||
?: LocaleController.getInstance().currentLocale, messages: List<MessageObject> = messageForTranslate?.let { listOf(it) }
|
||||
fun ChatActivity.translateMessages(target: Locale = NekomuraConfig.translateToLang.String().code2Locale
|
||||
, messages: List<MessageObject> = messageForTranslate?.let { listOf(it) }
|
||||
?: selectedObjectGroup?.messages
|
||||
?: emptyList()) {
|
||||
|
||||
|
|
|
@ -24,11 +24,19 @@ fun <T : HttpRequest> T.applyProxy(): T {
|
|||
}
|
||||
|
||||
val String.code2Locale: Locale by receiveLazy<String, Locale> {
|
||||
var ret: Locale
|
||||
if (this == null || this.isBlank()) {
|
||||
ret = LocaleController.getInstance().currentLocale
|
||||
} else {
|
||||
val args = replace('-', '_').split('_')
|
||||
|
||||
val args = replace('-', '_').split('_')
|
||||
|
||||
if (args.size == 1) Locale(args[0]) else Locale(args[0], args[1])
|
||||
|
||||
if (args.size == 1) {
|
||||
ret = Locale(args[0])
|
||||
} else {
|
||||
ret = Locale(args[0], args[1])
|
||||
}
|
||||
}
|
||||
ret
|
||||
}
|
||||
|
||||
val Locale.locale2code by receiveLazy<Locale, String> {
|
||||
|
|
|
@ -241,7 +241,7 @@ public class NekomuraConfig {
|
|||
public static ConfigItem googleCloudTranslateKey = addConfig("GoogleCloudTransKey", configTypeString, "");
|
||||
public static ConfigItem cachePath = addConfig("cache_path", configTypeString, "");
|
||||
|
||||
public static ConfigItem translateToLang = addConfig("TransToLang", configTypeString, "zh-CN");
|
||||
public static ConfigItem translateToLang = addConfig("TransToLang", configTypeString, ""); // "" -> translate to current language (MessageTrans.kt & Translator.kt)
|
||||
public static ConfigItem translateInputLang = addConfig("TransInputToLang", configTypeString, "en");
|
||||
|
||||
public static ConfigItem ccToLang = addConfig("opencc_to_lang", configTypeString, "");
|
||||
|
@ -295,7 +295,6 @@ public class NekomuraConfig {
|
|||
public static ConfigItem customAudioBitrate = addConfig("customAudioBitrate", configTypeInt, 32);
|
||||
public static ConfigItem disableGroupVoipAudioProcessing = addConfig("disableGroupVoipAudioProcessing", configTypeBool, false);
|
||||
|
||||
|
||||
static {
|
||||
loadConfig(false);
|
||||
|
||||
|
|
Loading…
Reference in New Issue