From 1a3b4733566cb1828bb0507e258240d3ab69d8fd Mon Sep 17 00:00:00 2001 From: Glavo Date: Fri, 29 Aug 2025 20:31:05 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20#3076:=20=E4=BF=AE=E5=A4=8D=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E8=AF=86=E5=88=AB=E9=83=A8=E5=88=86=E7=AE=80=E4=BD=93?= =?UTF-8?q?=E4=B8=AD=E6=96=87=E7=8E=AF=E5=A2=83=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#4350)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jackhuang/hmcl/util/i18n/Locales.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/util/i18n/Locales.java b/HMCL/src/main/java/org/jackhuang/hmcl/util/i18n/Locales.java index a2f255e8a..e19467c2a 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/util/i18n/Locales.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/util/i18n/Locales.java @@ -122,24 +122,40 @@ public final class Locales { if (resourceBundle == null) { if (this != DEFAULT && this.locale == DEFAULT.locale) { bundle = DEFAULT.getResourceBundle(); - } else if (this == WENYAN) { + } else { bundle = ResourceBundle.getBundle("assets.lang.I18N", locale, new ResourceBundle.Control() { @Override public List getCandidateLocales(String baseName, Locale locale) { + if (locale.getLanguage().equals("zh")) { + boolean simplified; + + String script = locale.getScript(); + String region = locale.getCountry(); + if (script.isEmpty()) + simplified = region.equals("CN") || region.equals("SG"); + else + simplified = script.equals("Hans"); + + if (simplified) { + return List.of( + Locale.SIMPLIFIED_CHINESE, + Locale.CHINESE, + Locale.ROOT + ); + } + } + if (locale.getLanguage().equals("lzh")) { return List.of( locale, - Locale.forLanguageTag("zh"), + Locale.CHINESE, Locale.ROOT ); } return super.getCandidateLocales(baseName, locale); } }); - } else { - bundle = ResourceBundle.getBundle("assets.lang.I18N", locale); } - resourceBundle = bundle; }