From 741f65d37ccbac093fcc49c98e1067b4afe98834 Mon Sep 17 00:00:00 2001 From: 3gf8jv4dv <3gf8jv4dv@gmail.com> Date: Wed, 12 Feb 2025 17:32:36 +0800 Subject: [PATCH] improv(i18n): refine time formats on ui (#3608) - unify time formats using DateTimeFormatter, deprecate `world.time` - change FormatStyle to make the time detail appropriate - fix incorrect time format in English locale --- .../main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java | 2 +- HMCL/src/main/java/org/jackhuang/hmcl/util/i18n/I18n.java | 3 ++- HMCL/src/main/java/org/jackhuang/hmcl/util/i18n/Locales.java | 2 +- HMCL/src/main/resources/assets/lang/I18N.properties | 1 - HMCL/src/main/resources/assets/lang/I18N_es.properties | 1 - HMCL/src/main/resources/assets/lang/I18N_ja.properties | 1 - HMCL/src/main/resources/assets/lang/I18N_ru.properties | 1 - HMCL/src/main/resources/assets/lang/I18N_zh.properties | 1 - HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties | 1 - 9 files changed, 4 insertions(+), 9 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java index b00adb775..849e6a1dc 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java @@ -528,7 +528,7 @@ public class DownloadPage extends Control implements DecoratorPage { } } - private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL).withLocale(Locale.getDefault()).withZone(ZoneId.systemDefault()); + private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(Locale.getDefault()).withZone(ZoneId.systemDefault()); public interface DownloadCallback { void download(Profile profile, @Nullable String version, RemoteMod.Version file); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/util/i18n/I18n.java b/HMCL/src/main/java/org/jackhuang/hmcl/util/i18n/I18n.java index a36c66c26..dd6c9784f 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/util/i18n/I18n.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/util/i18n/I18n.java @@ -22,6 +22,7 @@ import org.jackhuang.hmcl.util.i18n.Locales.SupportedLocale; import java.time.Instant; import java.time.ZoneId; import java.time.format.DateTimeFormatter; +import java.time.format.FormatStyle; import java.util.*; import static org.jackhuang.hmcl.util.logging.Logger.LOG; @@ -77,7 +78,7 @@ public final class I18n { public static String formatDateTime(Instant instant) { DateTimeFormatter formatter = dateTimeFormatter; if (formatter == null) { - formatter = dateTimeFormatter = DateTimeFormatter.ofPattern(getResourceBundle().getString("world.time")).withZone(ZoneId.systemDefault()); + formatter = dateTimeFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(Locale.getDefault()).withZone(ZoneId.systemDefault()); } return formatter.format(instant); 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 868371dce..18ef483a7 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 @@ -37,7 +37,7 @@ public final class Locales { /** * English */ - public static final SupportedLocale EN = new SupportedLocale(Locale.ROOT); + public static final SupportedLocale EN = new SupportedLocale(Locale.US); /** * Spanish diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index d99162ac6..08bfd54bd 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -1088,7 +1088,6 @@ world.name=World Name world.name.enter=Enter the world name world.reveal=Reveal in Explorer world.show_all=Show All -world.time=h\:mm\:ss a, EEE, MMM d yyyy profile=Game Directories profile.already_exists=This name already exists. Please use a different name. diff --git a/HMCL/src/main/resources/assets/lang/I18N_es.properties b/HMCL/src/main/resources/assets/lang/I18N_es.properties index 538ca7efd..3e223dffc 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_es.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_es.properties @@ -1035,7 +1035,6 @@ world.name=Nombre del mundo world.name.enter=Introducir el nombre del mundo world.reveal=Abrir en el Explorador world.show_all=Mostrar todo -world.time=EEE, MMM d, yyyy HH\:mm\:ss profile=Directorios del juego profile.already_exists=Este nombre ya existe, por favor, utilice un nombre diferente. diff --git a/HMCL/src/main/resources/assets/lang/I18N_ja.properties b/HMCL/src/main/resources/assets/lang/I18N_ja.properties index c21d74ee5..5905ad190 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_ja.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_ja.properties @@ -717,7 +717,6 @@ world.name=マップ名 world.name.enter=マップ名を入力してください world.reveal=フォルダを表示 world.show_all=すべて表示 -world.time=EEE、MMM d、yyyy HH:mm:ss profile=ゲームディレクトリ profile.already_exists=この名前はすでに存在します。別の名前を使用してください。 diff --git a/HMCL/src/main/resources/assets/lang/I18N_ru.properties b/HMCL/src/main/resources/assets/lang/I18N_ru.properties index 1937c901a..7dd15d880 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_ru.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_ru.properties @@ -776,7 +776,6 @@ world.name=Название мира world.name.enter=Введите название мира world.reveal=Показать в проводнике world.show_all=Показать все -world.time=EEE, MMM d, yyyy HH\:mm\:ss profile=Папки с играми profile.already_exists=Имя уже существует, используйте другое имя. diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh.properties b/HMCL/src/main/resources/assets/lang/I18N_zh.properties index 59d2b1d0a..3e5d8f4b7 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -892,7 +892,6 @@ world.name=世界名稱 world.name.enter=輸入世界名稱 world.reveal=開啟目錄 world.show_all=全部顯示 -world.time=yyyy 年 M 月 d 日, HH:mm:ss profile=遊戲目錄 profile.already_exists=該名稱已存在 diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties index eb2f68378..d46d89d56 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -903,7 +903,6 @@ world.name=世界名称 world.name.enter=输入世界名称 world.reveal=打开文件夹 world.show_all=显示全部 -world.time=yyyy 年 MM 月 dd 日, HH:mm:ss profile=游戏文件夹 profile.already_exists=该名称已存在