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
This commit is contained in:
3gf8jv4dv
2025-02-12 17:32:36 +08:00
committed by GitHub
parent ecafc9d6f0
commit 741f65d37c
9 changed files with 4 additions and 9 deletions

View File

@@ -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 { public interface DownloadCallback {
void download(Profile profile, @Nullable String version, RemoteMod.Version file); void download(Profile profile, @Nullable String version, RemoteMod.Version file);

View File

@@ -22,6 +22,7 @@ import org.jackhuang.hmcl.util.i18n.Locales.SupportedLocale;
import java.time.Instant; import java.time.Instant;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.*; import java.util.*;
import static org.jackhuang.hmcl.util.logging.Logger.LOG; import static org.jackhuang.hmcl.util.logging.Logger.LOG;
@@ -77,7 +78,7 @@ public final class I18n {
public static String formatDateTime(Instant instant) { public static String formatDateTime(Instant instant) {
DateTimeFormatter formatter = dateTimeFormatter; DateTimeFormatter formatter = dateTimeFormatter;
if (formatter == null) { 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); return formatter.format(instant);

View File

@@ -37,7 +37,7 @@ public final class Locales {
/** /**
* English * English
*/ */
public static final SupportedLocale EN = new SupportedLocale(Locale.ROOT); public static final SupportedLocale EN = new SupportedLocale(Locale.US);
/** /**
* Spanish * Spanish

View File

@@ -1088,7 +1088,6 @@ world.name=World Name
world.name.enter=Enter the world name world.name.enter=Enter the world name
world.reveal=Reveal in Explorer world.reveal=Reveal in Explorer
world.show_all=Show All world.show_all=Show All
world.time=h\:mm\:ss a, EEE, MMM d yyyy
profile=Game Directories profile=Game Directories
profile.already_exists=This name already exists. Please use a different name. profile.already_exists=This name already exists. Please use a different name.

View File

@@ -1035,7 +1035,6 @@ world.name=Nombre del mundo
world.name.enter=Introducir el nombre del mundo world.name.enter=Introducir el nombre del mundo
world.reveal=Abrir en el Explorador world.reveal=Abrir en el Explorador
world.show_all=Mostrar todo world.show_all=Mostrar todo
world.time=EEE, MMM d, yyyy HH\:mm\:ss
profile=Directorios del juego profile=Directorios del juego
profile.already_exists=Este nombre ya existe, por favor, utilice un nombre diferente. profile.already_exists=Este nombre ya existe, por favor, utilice un nombre diferente.

View File

@@ -717,7 +717,6 @@ world.name=マップ名
world.name.enter=マップ名を入力してください world.name.enter=マップ名を入力してください
world.reveal=フォルダを表示 world.reveal=フォルダを表示
world.show_all=すべて表示 world.show_all=すべて表示
world.time=EEE、MMM d、yyyy HHmmss
profile=ゲームディレクトリ profile=ゲームディレクトリ
profile.already_exists=この名前はすでに存在します。別の名前を使用してください。 profile.already_exists=この名前はすでに存在します。別の名前を使用してください。

View File

@@ -776,7 +776,6 @@ world.name=Название мира
world.name.enter=Введите название мира world.name.enter=Введите название мира
world.reveal=Показать в проводнике world.reveal=Показать в проводнике
world.show_all=Показать все world.show_all=Показать все
world.time=EEE, MMM d, yyyy HH\:mm\:ss
profile=Папки с играми profile=Папки с играми
profile.already_exists=Имя уже существует, используйте другое имя. profile.already_exists=Имя уже существует, используйте другое имя.

View File

@@ -892,7 +892,6 @@ world.name=世界名稱
world.name.enter=輸入世界名稱 world.name.enter=輸入世界名稱
world.reveal=開啟目錄 world.reveal=開啟目錄
world.show_all=全部顯示 world.show_all=全部顯示
world.time=yyyy 年 M 月 d 日, HH:mm:ss
profile=遊戲目錄 profile=遊戲目錄
profile.already_exists=該名稱已存在 profile.already_exists=該名稱已存在

View File

@@ -903,7 +903,6 @@ world.name=世界名称
world.name.enter=输入世界名称 world.name.enter=输入世界名称
world.reveal=打开文件夹 world.reveal=打开文件夹
world.show_all=显示全部 world.show_all=显示全部
world.time=yyyy 年 MM 月 dd 日, HH:mm:ss
profile=游戏文件夹 profile=游戏文件夹
profile.already_exists=该名称已存在 profile.already_exists=该名称已存在