diff --git a/.run/Run IDE with Plugin.run.xml b/.run/Run Plugin.run.xml
similarity index 87%
rename from .run/Run IDE with Plugin.run.xml
rename to .run/Run Plugin.run.xml
index fab2976ef..2143fd05a 100644
--- a/.run/Run IDE with Plugin.run.xml
+++ b/.run/Run Plugin.run.xml
@@ -1,5 +1,6 @@
+
@@ -18,6 +19,7 @@
true
true
false
+ false
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2a01fadc7..04c157bdc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,15 @@
## [Unreleased]
+- DeepL Translator now supports languages such as Chinese Traditional.
+- User interaction experience optimization and improvement.
+- Bug fixes.
+- DeepL 翻译现已支持繁体中文等语言
+- 用户交互体验优化与改进
+- Bug 修复
+
+## [3.6.4] (2024/07/23)
+
- The GPT-4o mini is now available in the OpenAI Translator engine.
- Alibaba Translate can now return the detected language.
- Fixed the issue where clicking on the status bar widget had no effect.
@@ -503,7 +512,8 @@
- 支持单词拆分。翻译变量名或方法名时更方便
- Bug修复
-[Unreleased]: https://github.com/YiiGuxing/TranslationPlugin/compare/v3.6.3...HEAD
+[Unreleased]: https://github.com/YiiGuxing/TranslationPlugin/compare/v3.6.4...HEAD
+[3.6.4]: https://github.com/YiiGuxing/TranslationPlugin/compare/v3.6.3...v3.6.4
[3.6.3]: https://github.com/YiiGuxing/TranslationPlugin/compare/v3.6.2...v3.6.3
[3.6.2]: https://github.com/YiiGuxing/TranslationPlugin/compare/v3.6.1...v3.6.2
[3.6.1]: https://github.com/YiiGuxing/TranslationPlugin/compare/v3.6.0...v3.6.1
diff --git a/build.gradle.kts b/build.gradle.kts
index d35d9b9d3..93772309a 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -104,7 +104,6 @@ kover {
tasks {
runIde {
systemProperty("idea.is.internal", true)
- systemProperty("translation.plugin.log.stdout", true)
jbrVariant = "dcevm"
jvmArgs = listOf(
diff --git a/gradle.properties b/gradle.properties
index bcde6eae7..cef33586b 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -6,7 +6,7 @@ pluginGroup = cn.yiiguxing.plugin.translate
pluginRepositoryUrl = https://github.com/YiiGuxing/TranslationPlugin
# SemVer format -> https://semver.org
-pluginMajorVersion = 3.6.4
+pluginMajorVersion = 3.6.5
pluginPreReleaseVersion =
pluginBuildMetadata = 203u212
autoSnapshotVersion = true
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/Contract.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/Contract.kt
index 44c9d00f6..04fb28a68 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/Contract.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/Contract.kt
@@ -4,12 +4,11 @@
package cn.yiiguxing.plugin.translate
import cn.yiiguxing.plugin.translate.trans.Lang
+import cn.yiiguxing.plugin.translate.trans.SupportedLanguagesData
import cn.yiiguxing.plugin.translate.trans.Translation
import cn.yiiguxing.plugin.translate.trans.Translator
import com.intellij.openapi.Disposable
-data class SupportedLanguages(val source: List, val target: List)
-
interface Presenter {
val translator: Translator
@@ -27,7 +26,7 @@ interface Presenter {
/**
* 已支持的语言
*/
- val supportedLanguages: SupportedLanguages
+ val supportedLanguages: SupportedLanguagesData
/**
* 检测指定的源语言是否被支持
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/TranslationPresenter.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/TranslationPresenter.kt
index 9bbf79cad..ee890261e 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/TranslationPresenter.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/TranslationPresenter.kt
@@ -23,9 +23,9 @@ class TranslationPresenter(private val view: View, private val recordHistory: Bo
override val primaryLanguage: Lang get() = translator.primaryLanguage
- override val supportedLanguages: SupportedLanguages
+ override val supportedLanguages: SupportedLanguagesData
get() = with(translator) {
- SupportedLanguages(supportedSourceLanguages, supportedTargetLanguages)
+ SupportedLanguagesData(supportedSourceLanguages, supportedTargetLanguages)
}
override fun isSupportedSourceLanguage(sourceLanguage: Lang): Boolean {
@@ -44,6 +44,7 @@ class TranslationPresenter(private val view: View, private val recordHistory: Bo
return when (settings.targetLanguageSelection) {
DEFAULT -> Lang.AUTO.takeIf { isSupportedTargetLanguage(it) }
?: if (text.isEmpty() || text.any(NON_LATIN_CONDITION)) Lang.ENGLISH else primaryLanguage
+
PRIMARY_LANGUAGE -> primaryLanguage
LAST -> states.lastLanguages.target.takeIf { isSupportedTargetLanguage(it) } ?: primaryLanguage
}
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/service/CacheService.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/service/CacheService.kt
index 7d1369f9d..b98d472d5 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/service/CacheService.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/service/CacheService.kt
@@ -62,7 +62,7 @@ class CacheService : PersistentStateComponent {
try {
TranslationStorages.createCacheDirectoriesIfNotExists()
getCacheFilePath(key).writeSafe { it.write(translation.toByteArray()) }
- println("DEBUG - Puts disk cache: $key")
+ LOG.d("Puts disk cache: $key")
trimDiskCachesIfNeed()
} catch (e: Exception) {
LOG.w(e)
@@ -72,7 +72,7 @@ class CacheService : PersistentStateComponent {
fun getDiskCache(key: String): String? {
return try {
getCacheFilePath(key).takeIf { Files.isRegularFile(it) }?.readText()?.apply {
- println("DEBUG - Disk cache hit: $key")
+ LOG.d("Disk cache hit: $key")
}
} catch (e: Exception) {
LOG.w(e)
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/LanguageAdapter.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/LanguageAdapter.kt
index effb3bbe3..1619d5338 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/LanguageAdapter.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/LanguageAdapter.kt
@@ -5,16 +5,6 @@ package cn.yiiguxing.plugin.translate.trans
*/
interface LanguageAdapter {
- /**
- * List of supported source languages.
- */
- val supportedSourceLanguages: List
-
- /**
- * List of supported target languages.
- */
- val supportedTargetLanguages: List
-
/**
* Returns the [language][Lang] corresponding to the given [code].
*/
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/Languages.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/Languages.kt
index 371f54c88..c81668034 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/Languages.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/Languages.kt
@@ -85,7 +85,7 @@ enum class Lang(
CHICHEWA("chichewa", "ny"),
/** 中文 */
- CHINESE("chinese", "zh-CN"),
+ CHINESE("chinese", "zh"),
/** 粤语 */
CHINESE_CANTONESE("chinese.cantonese", "zh-CANTONESE"),
@@ -93,6 +93,9 @@ enum class Lang(
/** 文言文 */
CHINESE_CLASSICAL("chinese.classical", "zh-CLASSICAL"),
+ /** 中文(简体) */
+ CHINESE_SIMPLIFIED("chinese.simplified", "zh-CN"),
+
/** 中文(繁体) */
CHINESE_TRADITIONAL("chinese.traditional", "zh-TW"),
@@ -459,7 +462,7 @@ enum class Lang(
return when (localeLanguage) {
Locale.CHINESE.language -> when (Locale.getDefault().country) {
"HK", "TW" -> CHINESE_TRADITIONAL
- else -> CHINESE
+ else -> CHINESE_SIMPLIFIED
}
else -> values().find { Locale(it.code).language.equals(localeLanguage, ignoreCase = true) }
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/SupportedLanguages.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/SupportedLanguages.kt
new file mode 100644
index 000000000..b9633de43
--- /dev/null
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/SupportedLanguages.kt
@@ -0,0 +1,21 @@
+package cn.yiiguxing.plugin.translate.trans
+
+/**
+ * Supported languages.
+ */
+interface SupportedLanguages {
+ /**
+ * The supported source languages.
+ */
+ val sourceLanguages: List
+
+ /**
+ * The supported target languages.
+ */
+ val targetLanguages: List
+}
+
+data class SupportedLanguagesData(
+ override val sourceLanguages: List,
+ override val targetLanguages: List
+) : SupportedLanguages
\ No newline at end of file
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/ali/AliLanguageAdapter.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/ali/AliLanguageAdapter.kt
index 530c30664..04d4cbef6 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/ali/AliLanguageAdapter.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/ali/AliLanguageAdapter.kt
@@ -2,15 +2,16 @@ package cn.yiiguxing.plugin.translate.trans.ali
import cn.yiiguxing.plugin.translate.trans.BaseLanguageAdapter
import cn.yiiguxing.plugin.translate.trans.Lang
+import cn.yiiguxing.plugin.translate.trans.SupportedLanguages
/**
* Language adapter for Ali Translator.
*/
-object AliLanguageAdapter : BaseLanguageAdapter() {
+object AliLanguageAdapter : BaseLanguageAdapter(), SupportedLanguages {
- override val supportedSourceLanguages: List = listOf(
+ override val sourceLanguages: List = listOf(
Lang.AUTO,
- Lang.CHINESE,
+ Lang.CHINESE_SIMPLIFIED,
Lang.CHINESE_TRADITIONAL,
Lang.ENGLISH,
Lang.JAPANESE,
@@ -30,8 +31,8 @@ object AliLanguageAdapter : BaseLanguageAdapter() {
Lang.HINDI
)
- override val supportedTargetLanguages: List = listOf(
- Lang.CHINESE,
+ override val targetLanguages: List = listOf(
+ Lang.CHINESE_SIMPLIFIED,
Lang.ENGLISH,
Lang.JAPANESE,
Lang.KOREAN,
@@ -49,7 +50,7 @@ object AliLanguageAdapter : BaseLanguageAdapter() {
)
override fun getAdaptedLanguages(): Map = mapOf(
- "zh" to Lang.CHINESE,
+ "zh" to Lang.CHINESE_SIMPLIFIED,
"zh-tw" to Lang.CHINESE_TRADITIONAL,
"yue" to Lang.CHINESE_CANTONESE,
"fil" to Lang.FILIPINO,
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/ali/AliTranslator.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/ali/AliTranslator.kt
index a72d5d678..8e4e64ab4 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/ali/AliTranslator.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/ali/AliTranslator.kt
@@ -47,9 +47,9 @@ object AliTranslator : AbstractTranslator(), DocumentationTranslator {
override val primaryLanguage: Lang
get() = ALI.primaryLanguage
- override val supportedSourceLanguages: List = AliLanguageAdapter.supportedSourceLanguages
+ override val supportedSourceLanguages: List = AliLanguageAdapter.sourceLanguages
- override val supportedTargetLanguages: List = AliLanguageAdapter.supportedTargetLanguages
+ override val supportedTargetLanguages: List = AliLanguageAdapter.targetLanguages
override fun checkConfiguration(force: Boolean): Boolean {
if (force ||
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/baidu/BaiduLanguageAdapter.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/baidu/BaiduLanguageAdapter.kt
index 92fd00c13..0854a9bcb 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/baidu/BaiduLanguageAdapter.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/baidu/BaiduLanguageAdapter.kt
@@ -2,15 +2,16 @@ package cn.yiiguxing.plugin.translate.trans.baidu
import cn.yiiguxing.plugin.translate.trans.BaseLanguageAdapter
import cn.yiiguxing.plugin.translate.trans.Lang
+import cn.yiiguxing.plugin.translate.trans.SupportedLanguages
/**
* Language adapter for Baidu Translator.
*/
-object BaiduLanguageAdapter : BaseLanguageAdapter() {
+object BaiduLanguageAdapter : BaseLanguageAdapter(), SupportedLanguages {
/** 通用版支持的语言列表 */
private val SUPPORTED_LANGUAGES: List = listOf(
- Lang.CHINESE,
+ Lang.CHINESE_SIMPLIFIED,
Lang.ENGLISH,
Lang.CHINESE_TRADITIONAL,
Lang.CHINESE_CANTONESE,
@@ -43,7 +44,7 @@ object BaiduLanguageAdapter : BaseLanguageAdapter() {
/** 尊享版支持的语言列表 */
@Suppress("unused")
private val SUPPORTED_LANGUAGES_PRO: List = listOf(
- Lang.CHINESE,
+ Lang.CHINESE_SIMPLIFIED,
Lang.ENGLISH,
Lang.CHINESE_TRADITIONAL,
Lang.CHINESE_CANTONESE,
@@ -123,11 +124,11 @@ object BaiduLanguageAdapter : BaseLanguageAdapter() {
Lang.ARMENIAN,
)
- override val supportedSourceLanguages: List = SUPPORTED_LANGUAGES
+ override val sourceLanguages: List = SUPPORTED_LANGUAGES
.toMutableList()
.apply { add(0, Lang.AUTO) }
- override val supportedTargetLanguages: List = SUPPORTED_LANGUAGES
+ override val targetLanguages: List = SUPPORTED_LANGUAGES
override fun getAdaptedLanguages(): Map = mapOf(
"afr" to Lang.AFRIKAANS,
@@ -141,7 +142,7 @@ object BaiduLanguageAdapter : BaseLanguageAdapter() {
"ben" to Lang.BENGALI,
"bos" to Lang.BOSNIAN,
"bul" to Lang.BULGARIAN,
- "zh" to Lang.CHINESE,
+ "zh" to Lang.CHINESE_SIMPLIFIED,
"cht" to Lang.CHINESE_TRADITIONAL,
"wyw" to Lang.CHINESE_CLASSICAL,
"yue" to Lang.CHINESE_CANTONESE,
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/baidu/BaiduTranslator.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/baidu/BaiduTranslator.kt
index 87fd94bd1..f1446f405 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/baidu/BaiduTranslator.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/baidu/BaiduTranslator.kt
@@ -42,9 +42,9 @@ object BaiduTranslator : AbstractTranslator() {
override val primaryLanguage: Lang
get() = BAIDU.primaryLanguage
- override val supportedSourceLanguages: List = BaiduLanguageAdapter.supportedSourceLanguages
+ override val supportedSourceLanguages: List = BaiduLanguageAdapter.sourceLanguages
- override val supportedTargetLanguages: List = BaiduLanguageAdapter.supportedTargetLanguages
+ override val supportedTargetLanguages: List = BaiduLanguageAdapter.targetLanguages
private val errorMessageMap: Map by lazy {
mapOf(
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/deepl/DeeplService.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/deepl/DeeplService.kt
index 414565c6b..cfed28d03 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/deepl/DeeplService.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/deepl/DeeplService.kt
@@ -13,7 +13,7 @@ import com.intellij.util.io.RequestBuilder
class DeeplService(var authKey: String) {
/**
- * Determines if the given [DeepL Authentication Key][authKey] belongs to an API Free account.
+ * Determines if the given [DeepL Authentication Key][authKey] belongs to an API-Free account.
*/
val isFreeAccount: Boolean get() = isFreeAccountAuthKey(authKey)
@@ -27,7 +27,7 @@ class DeeplService(var authKey: String) {
private fun RequestBuilder.auth() {
userAgent(Http.PLUGIN_USER_AGENT)
// Authentication method should be header-based authentication,
- // auth-key will leak into the log file if it is authenticated as a parameter.
+ // the auth-key will leak into the log file if it is authenticated as a parameter.
tuner { it.setRequestProperty("Authorization", "DeepL-Auth-Key $authKey") }
}
@@ -36,11 +36,11 @@ class DeeplService(var authKey: String) {
*/
fun translate(text: String, sourceLang: Lang, targetLang: Lang, isDocument: Boolean): String {
val params: LinkedHashMap = linkedMapOf(
- "target_lang" to targetLang.deeplLanguageCode,
+ "target_lang" to targetLang.deeplLanguageCodeForTarget,
"text" to text
)
if (sourceLang !== Lang.AUTO) {
- params["source_lang"] = sourceLang.deeplLanguageCode
+ params["source_lang"] = sourceLang.deeplLanguageCodeForSource
}
if (isDocument) {
params["tag_handling"] = "html"
@@ -80,10 +80,10 @@ class DeeplService(var authKey: String) {
private const val DEEPL_SERVER_URL_PRO = "https://api.deepl.com"
/**
- * Determines if the given [DeepL Authentication Key][authKey] belongs to an API Free account.
+ * Determines if the given [DeepL Authentication Key][authKey] belongs to an API-Free account.
*
* @param authKey DeepL Authentication Key as found in your [DeepL account](https://www.deepl.com/pro-account/).
- * @return `true` if the Authentication Key belongs to an API Free account, otherwise `false`.
+ * @return `true` if the Authentication Key belongs to an API-Free account, otherwise `false`.
*/
fun isFreeAccountAuthKey(authKey: String): Boolean = authKey.endsWith(":fx")
}
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/deepl/DeeplLanguageAdapter.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/deepl/DeeplSupportedLanguages.kt
similarity index 62%
rename from src/main/kotlin/cn/yiiguxing/plugin/translate/trans/deepl/DeeplLanguageAdapter.kt
rename to src/main/kotlin/cn/yiiguxing/plugin/translate/trans/deepl/DeeplSupportedLanguages.kt
index 360c59260..7ed064984 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/deepl/DeeplLanguageAdapter.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/deepl/DeeplSupportedLanguages.kt
@@ -2,31 +2,38 @@ package cn.yiiguxing.plugin.translate.trans.deepl
import cn.yiiguxing.plugin.translate.trans.BaseLanguageAdapter
import cn.yiiguxing.plugin.translate.trans.Lang
+import cn.yiiguxing.plugin.translate.trans.SupportedLanguages
+
/**
- * Language adapter for DeepL Translator.
+ * Supported languages for DeepL Translator.
*/
-object DeeplLanguageAdapter : BaseLanguageAdapter() {
-
- override val supportedSourceLanguages: List = listOf(
+object DeeplSupportedLanguages : SupportedLanguages {
+ /**
+ * The supported source languages.
+ */
+ override val sourceLanguages: List = listOf(
Lang.AUTO,
+ Lang.ARABIC,
Lang.BULGARIAN,
Lang.CHINESE,
Lang.CZECH,
Lang.DANISH,
Lang.DUTCH,
- Lang.GERMAN,
- Lang.GREEK,
Lang.ENGLISH,
Lang.ESTONIAN,
Lang.FINNISH,
Lang.FRENCH,
+ Lang.GERMAN,
+ Lang.GREEK,
Lang.HUNGARIAN,
+ Lang.INDONESIAN,
Lang.ITALIAN,
Lang.JAPANESE,
Lang.KOREAN,
Lang.LATVIAN,
Lang.LITHUANIAN,
+ Lang.NORWEGIAN,
Lang.POLISH,
Lang.PORTUGUESE,
Lang.ROMANIAN,
@@ -35,86 +42,116 @@ object DeeplLanguageAdapter : BaseLanguageAdapter() {
Lang.SLOVENIAN,
Lang.SPANISH,
Lang.SWEDISH,
+ Lang.TURKISH,
Lang.UKRAINIAN,
)
- override val supportedTargetLanguages: List = listOf(
+ /**
+ * The supported target languages.
+ */
+ override val targetLanguages: List = listOf(
+ Lang.ARABIC,
Lang.BULGARIAN,
- Lang.CHINESE,
+ Lang.CHINESE_SIMPLIFIED,
+ Lang.CHINESE_TRADITIONAL,
Lang.CZECH,
Lang.DANISH,
Lang.DUTCH,
- Lang.GERMAN,
- Lang.GREEK,
- Lang.ENGLISH,
Lang.ENGLISH_AMERICAN,
Lang.ENGLISH_BRITISH,
Lang.ESTONIAN,
Lang.FINNISH,
Lang.FRENCH,
+ Lang.GERMAN,
+ Lang.GREEK,
Lang.HUNGARIAN,
+ Lang.INDONESIAN,
Lang.ITALIAN,
Lang.JAPANESE,
Lang.KOREAN,
Lang.LATVIAN,
Lang.LITHUANIAN,
+ Lang.NORWEGIAN,
Lang.POLISH,
Lang.PORTUGUESE,
Lang.PORTUGUESE_BRAZILIAN,
- Lang.PORTUGUESE_PORTUGUESE,
Lang.ROMANIAN,
Lang.RUSSIAN,
Lang.SLOVAK,
Lang.SLOVENIAN,
Lang.SPANISH,
Lang.SWEDISH,
+ Lang.TURKISH,
Lang.UKRAINIAN,
)
+}
+private val adapter = object : BaseLanguageAdapter() {
override fun getAdaptedLanguages(): Map = mapOf(
+ "AR" to Lang.ARABIC,
"BG" to Lang.BULGARIAN,
"ZH" to Lang.CHINESE,
+ "ZH-HANS" to Lang.CHINESE_SIMPLIFIED,
+ "ZH-HANT" to Lang.CHINESE_TRADITIONAL,
"CS" to Lang.CZECH,
"DA" to Lang.DANISH,
"NL" to Lang.DUTCH,
- "DE" to Lang.GERMAN,
- "EL" to Lang.GREEK,
"EN" to Lang.ENGLISH,
"EN-US" to Lang.ENGLISH_AMERICAN,
"EN-GB" to Lang.ENGLISH_BRITISH,
"ET" to Lang.ESTONIAN,
"FI" to Lang.FINNISH,
"FR" to Lang.FRENCH,
+ "DE" to Lang.GERMAN,
+ "EL" to Lang.GREEK,
"HU" to Lang.HUNGARIAN,
"IT" to Lang.ITALIAN,
+ "ID" to Lang.INDONESIAN,
"JA" to Lang.JAPANESE,
"KO" to Lang.KOREAN,
"LV" to Lang.LATVIAN,
"LT" to Lang.LITHUANIAN,
+ "NB" to Lang.NORWEGIAN,
"PL" to Lang.POLISH,
+
+ // PORTUGUESE is ambiguous, and the regions it
+ // represents differ between the source and target languages.
"PT" to Lang.PORTUGUESE,
+ "PT-PT" to Lang.PORTUGUESE,
+
"PT-BR" to Lang.PORTUGUESE_BRAZILIAN,
- "PT-PT" to Lang.PORTUGUESE_PORTUGUESE,
"RO" to Lang.ROMANIAN,
"RU" to Lang.RUSSIAN,
"SK" to Lang.SLOVAK,
"SL" to Lang.SLOVENIAN,
"ES" to Lang.SPANISH,
"SV" to Lang.SWEDISH,
+ "TR" to Lang.TURKISH,
"UK" to Lang.UKRAINIAN,
)
}
+/**
+ * Source Language Code for DeepL Translator.
+ */
+val Lang.deeplLanguageCodeForSource: String
+ get() = when (this) {
+ Lang.PORTUGUESE -> "PT"
+ else -> adapter.getLanguageCode(this)
+ }
/**
- * Language code for DeepL Translator.
+ * Target Language Code for DeepL Translator.
*/
-val Lang.deeplLanguageCode: String
- get() = DeeplLanguageAdapter.getLanguageCode(this)
+val Lang.deeplLanguageCodeForTarget: String
+ get() = when (this) {
+ Lang.PORTUGUESE -> "PT-PT"
+ else -> adapter.getLanguageCode(this)
+ }
/**
* Returns the [language][Lang] for the specified DeepL Translator language [code].
*/
fun Lang.Companion.fromDeeplLanguageCode(code: String): Lang {
- return DeeplLanguageAdapter.getLanguage(code)
+ return adapter.getLanguage(code)
}
\ No newline at end of file
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/deepl/DeeplTranslator.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/deepl/DeeplTranslator.kt
index 344323c16..84a6c24f3 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/deepl/DeeplTranslator.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/deepl/DeeplTranslator.kt
@@ -33,9 +33,9 @@ object DeeplTranslator : AbstractTranslator(), DocumentationTranslator {
override val primaryLanguage: Lang
get() = DEEPL.primaryLanguage
- override val supportedSourceLanguages: List = DeeplLanguageAdapter.supportedSourceLanguages
+ override val supportedSourceLanguages: List = DeeplSupportedLanguages.sourceLanguages
- override val supportedTargetLanguages: List = DeeplLanguageAdapter.supportedTargetLanguages
+ override val supportedTargetLanguages: List = DeeplSupportedLanguages.targetLanguages
override fun checkConfiguration(force: Boolean): Boolean {
if (force || !DeeplCredential.isAuthKeySet) {
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/google/GoogleLanguageAdapter.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/google/GoogleLanguageAdapter.kt
index d19207320..e73ee08d7 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/google/GoogleLanguageAdapter.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/google/GoogleLanguageAdapter.kt
@@ -2,15 +2,17 @@ package cn.yiiguxing.plugin.translate.trans.google
import cn.yiiguxing.plugin.translate.trans.BaseLanguageAdapter
import cn.yiiguxing.plugin.translate.trans.Lang
+import cn.yiiguxing.plugin.translate.trans.SupportedLanguages
/**
* Language adapter for Google Translator.
*/
-object GoogleLanguageAdapter : BaseLanguageAdapter() {
+object GoogleLanguageAdapter : BaseLanguageAdapter(), SupportedLanguages {
private val UNSUPPORTED_LANGUAGES: Set = setOf(
Lang.ASSAMESE,
Lang.BASHKIR,
+ Lang.CHINESE, // 己俱体分为 `中文(简体)`
Lang.CHINESE_CANTONESE,
Lang.CHINESE_CLASSICAL,
Lang.DARI,
@@ -35,10 +37,9 @@ object GoogleLanguageAdapter : BaseLanguageAdapter() {
override fun getAdaptedLanguages(): Map = mapOf()
- override val supportedSourceLanguages: List = (Lang.sortedLanguages - UNSUPPORTED_LANGUAGES).toList()
+ override val sourceLanguages: List = (Lang.sortedLanguages - UNSUPPORTED_LANGUAGES).toList()
- override val supportedTargetLanguages: List =
- (Lang.sortedLanguages - UNSUPPORTED_LANGUAGES - Lang.AUTO).toList()
+ override val targetLanguages: List = (Lang.sortedLanguages - UNSUPPORTED_LANGUAGES - Lang.AUTO).toList()
}
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/google/GoogleTranslator.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/google/GoogleTranslator.kt
index d928e4f8e..aadd7fdf8 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/google/GoogleTranslator.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/google/GoogleTranslator.kt
@@ -44,9 +44,9 @@ object GoogleTranslator : AbstractTranslator(), DocumentationTranslator {
override val primaryLanguage: Lang
get() = GOOGLE.primaryLanguage
- override val supportedSourceLanguages: List = GoogleLanguageAdapter.supportedSourceLanguages
+ override val supportedSourceLanguages: List = GoogleLanguageAdapter.sourceLanguages
- override val supportedTargetLanguages: List = GoogleLanguageAdapter.supportedTargetLanguages
+ override val supportedTargetLanguages: List = GoogleLanguageAdapter.targetLanguages
override fun doTranslate(text: String, srcLang: Lang, targetLang: Lang): Translation {
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/microsoft/MicrosoftLanguageAdapter.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/microsoft/MicrosoftLanguageAdapter.kt
index 9b9942fa8..c49623579 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/microsoft/MicrosoftLanguageAdapter.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/microsoft/MicrosoftLanguageAdapter.kt
@@ -2,16 +2,18 @@ package cn.yiiguxing.plugin.translate.trans.microsoft
import cn.yiiguxing.plugin.translate.trans.BaseLanguageAdapter
import cn.yiiguxing.plugin.translate.trans.Lang
+import cn.yiiguxing.plugin.translate.trans.SupportedLanguages
/**
* Language adapter for Microsoft Translator.
*/
-internal object MicrosoftLanguageAdapter : BaseLanguageAdapter() {
+internal object MicrosoftLanguageAdapter : BaseLanguageAdapter(), SupportedLanguages {
private val UNSUPPORTED_LANGUAGES: Set = setOf(
Lang.BELARUSIAN,
Lang.CEBUANO,
Lang.CHICHEWA,
+ Lang.CHINESE, // 己俱体分为 `中文(简体)` 和 `中文(繁体)` 等
Lang.CORSICAN,
Lang.ENGLISH_AMERICAN,
Lang.ENGLISH_BRITISH,
@@ -44,7 +46,7 @@ internal object MicrosoftLanguageAdapter : BaseLanguageAdapter() {
override fun getAdaptedLanguages(): Map = mapOf(
"yue" to Lang.CHINESE_CANTONESE,
"lzh" to Lang.CHINESE_CLASSICAL,
- "zh-Hans" to Lang.CHINESE,
+ "zh-Hans" to Lang.CHINESE_SIMPLIFIED,
"zh-Hant" to Lang.CHINESE_TRADITIONAL,
"fil" to Lang.FILIPINO,
"he" to Lang.HEBREW,
@@ -56,10 +58,9 @@ internal object MicrosoftLanguageAdapter : BaseLanguageAdapter() {
"pt" to Lang.PORTUGUESE_BRAZILIAN,
)
- override val supportedSourceLanguages: List = (Lang.sortedLanguages - UNSUPPORTED_LANGUAGES).toList()
+ override val sourceLanguages: List = (Lang.sortedLanguages - UNSUPPORTED_LANGUAGES).toList()
- override val supportedTargetLanguages: List =
- (Lang.sortedLanguages - UNSUPPORTED_LANGUAGES - Lang.AUTO).toList()
+ override val targetLanguages: List = (Lang.sortedLanguages - UNSUPPORTED_LANGUAGES - Lang.AUTO).toList()
}
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/microsoft/MicrosoftTranslator.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/microsoft/MicrosoftTranslator.kt
index 31b69d758..a459759bb 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/microsoft/MicrosoftTranslator.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/microsoft/MicrosoftTranslator.kt
@@ -28,8 +28,8 @@ object MicrosoftTranslator : AbstractTranslator(), DocumentationTranslator {
override val intervalLimit: Int = MICROSOFT.intervalLimit
override val contentLengthLimit: Int = MICROSOFT.contentLengthLimit
override val primaryLanguage: Lang get() = MICROSOFT.primaryLanguage
- override val supportedSourceLanguages: List = MicrosoftLanguageAdapter.supportedSourceLanguages
- override val supportedTargetLanguages: List = MicrosoftLanguageAdapter.supportedTargetLanguages
+ override val supportedSourceLanguages: List = MicrosoftLanguageAdapter.sourceLanguages
+ override val supportedTargetLanguages: List = MicrosoftLanguageAdapter.targetLanguages
override fun doTranslate(text: String, srcLang: Lang, targetLang: Lang): Translation {
if (!targetLang.isExplicit()) {
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/openai/OpenAiLanguages.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/openai/OpenAiLanguages.kt
index a4c3d2f2a..c7529825e 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/openai/OpenAiLanguages.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/openai/OpenAiLanguages.kt
@@ -6,7 +6,7 @@ internal object OpenAiLanguages {
val languageMap = linkedMapOf(
Lang.ENGLISH to "English",
- Lang.CHINESE to "Simplified Chinese",
+ Lang.CHINESE_SIMPLIFIED to "Simplified Chinese",
Lang.CHINESE_TRADITIONAL to "Traditional Chinese",
Lang.JAPANESE to "Japanese",
Lang.KOREAN to "Korean",
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/youdao/YoudaoLanguageAdapter.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/youdao/YoudaoLanguageAdapter.kt
index 49cd46f84..5c6906d97 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/youdao/YoudaoLanguageAdapter.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/youdao/YoudaoLanguageAdapter.kt
@@ -2,15 +2,16 @@ package cn.yiiguxing.plugin.translate.trans.youdao
import cn.yiiguxing.plugin.translate.trans.BaseLanguageAdapter
import cn.yiiguxing.plugin.translate.trans.Lang
+import cn.yiiguxing.plugin.translate.trans.SupportedLanguages
/**
* Language adapter for Youdao Translator.
*/
-object YoudaoLanguageAdapter : BaseLanguageAdapter() {
+object YoudaoLanguageAdapter : BaseLanguageAdapter(), SupportedLanguages {
private val SUPPORTED_LANGUAGES: List = listOf(
Lang.AUTO,
- Lang.CHINESE,
+ Lang.CHINESE_SIMPLIFIED,
Lang.CHINESE_TRADITIONAL,
Lang.ENGLISH,
Lang.JAPANESE,
@@ -28,12 +29,12 @@ object YoudaoLanguageAdapter : BaseLanguageAdapter() {
Lang.ARABIC,
)
- override val supportedSourceLanguages: List = SUPPORTED_LANGUAGES
+ override val sourceLanguages: List = SUPPORTED_LANGUAGES
- override val supportedTargetLanguages: List = SUPPORTED_LANGUAGES
+ override val targetLanguages: List = SUPPORTED_LANGUAGES
override fun getAdaptedLanguages(): Map = mapOf(
- "zh-CHS" to Lang.CHINESE,
+ "zh-CHS" to Lang.CHINESE_SIMPLIFIED,
"zh-CHT" to Lang.CHINESE_TRADITIONAL,
)
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/youdao/YoudaoTranslator.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/youdao/YoudaoTranslator.kt
index 679af8f16..52591c292 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/youdao/YoudaoTranslator.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/trans/youdao/YoudaoTranslator.kt
@@ -44,9 +44,9 @@ object YoudaoTranslator : AbstractTranslator(), DocumentationTranslator {
override val primaryLanguage: Lang
get() = YOUDAO.primaryLanguage
- override val supportedSourceLanguages: List = YoudaoLanguageAdapter.supportedSourceLanguages
+ override val supportedSourceLanguages: List = YoudaoLanguageAdapter.sourceLanguages
- override val supportedTargetLanguages: List = YoudaoLanguageAdapter.supportedTargetLanguages
+ override val supportedTargetLanguages: List = YoudaoLanguageAdapter.targetLanguages
private val errorMessageMap: Map by lazy {
mapOf(
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/tts/GoogleTTSPlayer.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/tts/GoogleTTSPlayer.kt
index 4b38cd5d3..891376f21 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/tts/GoogleTTSPlayer.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/tts/GoogleTTSPlayer.kt
@@ -86,7 +86,7 @@ class GoogleTTSPlayer private constructor(
private const val MAX_TEXT_LENGTH = 200
private val SUPPORTED_LANGUAGES: List = listOf(
- Lang.CHINESE, Lang.ENGLISH, Lang.CHINESE_TRADITIONAL, Lang.ALBANIAN, Lang.ARABIC, Lang.ESTONIAN,
+ Lang.CHINESE_SIMPLIFIED, Lang.ENGLISH, Lang.CHINESE_TRADITIONAL, Lang.ALBANIAN, Lang.ARABIC, Lang.ESTONIAN,
Lang.ICELANDIC, Lang.POLISH, Lang.BOSNIAN, Lang.AFRIKAANS, Lang.DANISH, Lang.GERMAN, Lang.RUSSIAN,
Lang.FRENCH, Lang.FINNISH, Lang.KHMER, Lang.KOREAN, Lang.DUTCH, Lang.CATALAN, Lang.CZECH, Lang.CROATIAN,
Lang.LATIN, Lang.LATVIAN, Lang.ROMANIAN, Lang.MACEDONIAN, Lang.BENGALI, Lang.NEPALI, Lang.NORWEGIAN,
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/tts/microsoft/EdgeTTSVoiceManager.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/tts/microsoft/EdgeTTSVoiceManager.kt
index 5852a5159..76f501a59 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/tts/microsoft/EdgeTTSVoiceManager.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/tts/microsoft/EdgeTTSVoiceManager.kt
@@ -165,7 +165,7 @@ internal object EdgeTTSVoiceManager {
BENGALI to "bn-IN",
BULGARIAN to "bg-BG",
CATALAN to "ca-ES",
- CHINESE to "zh-CN",
+ CHINESE_SIMPLIFIED to "zh-CN",
CHINESE_CANTONESE to "zh-HK",
CHINESE_TRADITIONAL to "zh-CN",
CROATIAN to "hr-HR",
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/ui/TranslationWidget.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/ui/TranslationWidget.kt
index 6723f45c3..441cbbe0c 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/ui/TranslationWidget.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/ui/TranslationWidget.kt
@@ -25,9 +25,11 @@ import com.intellij.openapi.wm.impl.status.TextPanel.WithIconAndArrows
import com.intellij.ui.ClickListener
import com.intellij.ui.GotItTooltip
import com.intellij.ui.awt.RelativePoint
+import com.intellij.util.concurrency.AppExecutorUtil
import org.jetbrains.concurrency.runAsync
import java.awt.Point
import java.awt.event.MouseEvent
+import java.util.concurrent.TimeUnit
import javax.swing.JComponent
/**
@@ -102,13 +104,19 @@ class TranslationWidget(private val project: Project) : WithIconAndArrows(), Ico
project.messageBus
.connect(disposable)
.subscribe(UpdateListener.TOPIC, object : UpdateListener {
- override fun onPostUpdate() {
+ override fun onPostUpdate(hasUpdate: Boolean) {
Disposer.dispose(disposable)
- if (project.isDisposed) {
- return
+ val runnable = {
+ if (!project.isDisposed) {
+ DumbService.getInstance(project).smartInvokeLater {
+ showGotItTooltipIfNeed()
+ }
+ }
}
- DumbService.getInstance(project).smartInvokeLater {
- showGotItTooltipIfNeed()
+ if (hasUpdate) {
+ AppExecutorUtil.getAppScheduledExecutorService().schedule(runnable, 1, TimeUnit.SECONDS)
+ } else {
+ runnable()
}
}
})
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/update/UpdateListener.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/update/UpdateListener.kt
index 512453099..3cda48cb5 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/update/UpdateListener.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/update/UpdateListener.kt
@@ -8,7 +8,7 @@ interface UpdateListener {
* Called after the update check is completed. If the update notification is shown,
* this method will be called after the notification is closed.
*/
- fun onPostUpdate() {}
+ fun onPostUpdate(hasUpdate: Boolean) {}
companion object {
@Topic.AppLevel
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/update/UpdateManager.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/update/UpdateManager.kt
index ac97ef009..65239982f 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/update/UpdateManager.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/update/UpdateManager.kt
@@ -66,14 +66,14 @@ class UpdateManager : BaseStartupActivity(true) {
val properties: PropertiesComponent = PropertiesComponent.getInstance()
val lastVersionString = properties.getValue(VERSION_PROPERTY, Version.INITIAL_VERSION)
if (versionString == lastVersionString) {
- onPostUpdate()
+ onPostUpdate(false)
return
}
val version = Version(versionString)
val lastVersion = Version.getOrElse(lastVersionString) { Version() }
if (version.isSameVersion(lastVersion)) {
- onPostUpdate()
+ onPostUpdate(false)
return
}
@@ -139,7 +139,7 @@ class UpdateManager : BaseStartupActivity(true) {
WhatsNew.browse(project, version)
}
}
- onPostUpdate()
+ onPostUpdate(true)
}
invokeLaterIfNeeded(expired = project.disposed) {
@@ -201,9 +201,9 @@ class UpdateManager : BaseStartupActivity(true) {
return true
}
- private fun onPostUpdate() {
+ private fun onPostUpdate(hasUpdate: Boolean) {
invokeLaterIfNeeded {
- Application.messageBus.syncPublisher(UpdateListener.TOPIC).onPostUpdate()
+ Application.messageBus.syncPublisher(UpdateListener.TOPIC).onPostUpdate(hasUpdate)
}
}
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/util/Logs.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/util/Logs.kt
index 2eaf7909e..2abfe2863 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/util/Logs.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/util/Logs.kt
@@ -3,30 +3,13 @@
package cn.yiiguxing.plugin.translate.util
import com.intellij.openapi.diagnostic.Logger
-import com.intellij.util.SystemProperties
-
-
-private val isStdout: Boolean = SystemProperties.getBooleanProperty("translation.plugin.log.stdout", false)
-
-
-fun Logger.d(message: String) {
- if (isStdout) println("DEBUG - $message")
- debug(message)
-}
-
-fun Logger.i(message: String) {
- if (isStdout) println("INFO - $message")
- info(message)
-}
+fun Logger.v(message: String) = trace(message)
+fun Logger.d(message: String) = debug(message)
+fun Logger.i(message: String) = info(message)
fun Logger.w(tr: Throwable) = warn(tr)
-
fun Logger.w(message: String) = warn(message)
-
fun Logger.w(message: String, tr: Throwable) = warn(message, tr)
-
fun Logger.e(message: String) = error(message)
-
fun Logger.e(message: String, tr: Throwable) = error(message, tr)
-
fun Logger.e(message: String, tr: Throwable? = null, vararg details: String) = error(message, tr, *details)
\ No newline at end of file
diff --git a/src/main/kotlin/cn/yiiguxing/plugin/translate/wordbook/WordBookService.kt b/src/main/kotlin/cn/yiiguxing/plugin/translate/wordbook/WordBookService.kt
index 5320d243e..d46c2654a 100644
--- a/src/main/kotlin/cn/yiiguxing/plugin/translate/wordbook/WordBookService.kt
+++ b/src/main/kotlin/cn/yiiguxing/plugin/translate/wordbook/WordBookService.kt
@@ -636,11 +636,13 @@ class WordBookService : Disposable {
private inline fun lock(block: () -> T): T {
return RandomAccessFile(LOCK_FILE.toFile(), "rw").use { lockFile ->
- val lock = lockFile.channel.lock()
- try {
- block()
- } finally {
- lock.release()
+ synchronized(LOCK_FILE) {
+ val lock = lockFile.channel.lock()
+ try {
+ block()
+ } finally {
+ lock.release()
+ }
}
}
}
diff --git a/src/main/resources/messages/LanguageBundle.properties b/src/main/resources/messages/LanguageBundle.properties
index af146c542..c2959b2d4 100644
--- a/src/main/resources/messages/LanguageBundle.properties
+++ b/src/main/resources/messages/LanguageBundle.properties
@@ -16,9 +16,10 @@ bulgarian=Bulgarian
catalan=Catalan
cebuano=Cebuano
chichewa=Chichewa
-chinese=Chinese (Simplified)
+chinese=Chinese
chinese.cantonese=Chinese (Cantonese)
chinese.classical=Chinese (Classical)
+chinese.simplified=Chinese (Simplified)
chinese.traditional=Chinese (Traditional)
corsican=Corsican
croatian=Croatian
diff --git a/src/main/resources/messages/LanguageBundle_ja.properties b/src/main/resources/messages/LanguageBundle_ja.properties
index 07666463b..5f79d4f71 100644
--- a/src/main/resources/messages/LanguageBundle_ja.properties
+++ b/src/main/resources/messages/LanguageBundle_ja.properties
@@ -16,9 +16,10 @@ bulgarian=ブルガリア語
catalan=カタロニア語
cebuano=セブアノ語
chichewa=チェワ語
-chinese=中国語(簡体字)
+chinese=中国語
chinese.cantonese=中国語(広東語)
chinese.classical=中国語(漢文)
+chinese.simplified=中国語(簡体字)
chinese.traditional=中国語(繁体字)
corsican=コルシカ語
croatian=クロアチア語
diff --git a/src/main/resources/messages/LanguageBundle_ko.properties b/src/main/resources/messages/LanguageBundle_ko.properties
index 3c3c9961b..a58d06e6f 100644
--- a/src/main/resources/messages/LanguageBundle_ko.properties
+++ b/src/main/resources/messages/LanguageBundle_ko.properties
@@ -16,9 +16,10 @@ bulgarian=불가리아어
catalan=카탈로니아어
cebuano=세부아노어
chichewa=체와어
-chinese=중국어(간체)
+chinese=중국어
chinese.cantonese=중국어(광동어)
chinese.classical=중국어(전통)
+chinese.simplified=중국어(간체)
chinese.traditional=중국어(번체)
corsican=코르시카어
croatian=크로아티아어
diff --git a/src/main/resources/messages/LanguageBundle_zh_CN.properties b/src/main/resources/messages/LanguageBundle_zh_CN.properties
index 91fe94618..5b1691768 100644
--- a/src/main/resources/messages/LanguageBundle_zh_CN.properties
+++ b/src/main/resources/messages/LanguageBundle_zh_CN.properties
@@ -16,9 +16,10 @@ bulgarian=保加利亚语
catalan=加泰罗尼亚语
cebuano=宿务语
chichewa=齐切瓦语
-chinese=中文(简体)
+chinese=中文
chinese.cantonese=粤语
chinese.classical=文言文
+chinese.simplified=中文(简体)
chinese.traditional=中文(繁体)
corsican=科西嘉语
croatian=克罗地亚语
diff --git a/src/test/kotlin/cn/yiiguxing/plugin/translate/ui/TranslationUiTest.kt b/src/test/kotlin/cn/yiiguxing/plugin/translate/ui/TranslationUiTest.kt
index 8d060242c..5cd1eff98 100644
--- a/src/test/kotlin/cn/yiiguxing/plugin/translate/ui/TranslationUiTest.kt
+++ b/src/test/kotlin/cn/yiiguxing/plugin/translate/ui/TranslationUiTest.kt
@@ -14,8 +14,8 @@ fun main() = uiTest("Translation UI Test", 500, 300/*, true*/) {
val ui = TranslationDialogUiImpl(null, TranslationDialogUiProvider.testProvider())
val mainPanel = ui.createMainPanel()
- ui.sourceLangComboBox.model = LanguageListModel.simple(listOf(Lang.AUTO, Lang.ENGLISH, Lang.CHINESE))
- ui.targetLangComboBox.model = LanguageListModel.simple(listOf(Lang.CHINESE, Lang.ENGLISH))
+ ui.sourceLangComboBox.model = LanguageListModel.simple(listOf(Lang.AUTO, Lang.ENGLISH, Lang.CHINESE_SIMPLIFIED))
+ ui.targetLangComboBox.model = LanguageListModel.simple(listOf(Lang.CHINESE_SIMPLIFIED, Lang.ENGLISH))
ui.initFonts(UI.FontPair(UI.defaultFont, UI.defaultFont.lessOn(2f)))
@@ -26,7 +26,7 @@ fun main() = uiTest("Translation UI Test", 500, 300/*, true*/) {
ui.targetTransliterationLabel.text = "Fānyì"
val googleTranslation = createGoogleTranslation()
- val translation = googleTranslation.toTranslation().copy(srcLang = Lang.CHINESE)
+ val translation = googleTranslation.toTranslation().copy(srcLang = Lang.CHINESE_SIMPLIFIED)
ui.spellComponent.spell = "translation"
ui.fixLangComponent.updateOnTranslation(translation)
@@ -57,7 +57,7 @@ fun createDummyYoudaoTranslation(): YoudaoTranslation = YoudaoTranslation(
fun createGoogleTranslation(): GoogleTranslation = GoogleTranslation(
"translation",
Lang.ENGLISH,
- Lang.CHINESE,
+ Lang.CHINESE_SIMPLIFIED,
listOf(GTransSentence("translation", "翻译", 2), GTranslitSentence("transˈlāSH(ə)n", "Fānyì")),
listOf(
GDict(