From 043c731575f6c01242a8ac9e353db0fd7181e9cf Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Fri, 6 May 2022 21:52:10 -0400 Subject: [PATCH] Fix for translation errors --- src/main/java/emu/grasscutter/Grasscutter.java | 2 +- .../emu/grasscutter/server/dispatch/DispatchServer.java | 2 +- src/main/java/emu/grasscutter/utils/Language.java | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/emu/grasscutter/Grasscutter.java b/src/main/java/emu/grasscutter/Grasscutter.java index d05939c05..8295cc599 100644 --- a/src/main/java/emu/grasscutter/Grasscutter.java +++ b/src/main/java/emu/grasscutter/Grasscutter.java @@ -93,7 +93,7 @@ public final class Grasscutter { ResourceLoader.loadAll(); ScriptLoader.init(); - // Database + // Initialize database. DatabaseManager.initialize(); // Create server instances. diff --git a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java index 1695e0208..7e4b1655e 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java +++ b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java @@ -334,7 +334,7 @@ public final class DispatchServer { return; } LoginResultJson responseData = new LoginResultJson(); - Grasscutter.getLogger().info(translate("messages.dispatch.account.login_token_attempt")); + Grasscutter.getLogger().info(translate("messages.dispatch.account.login_token_attempt", req.ip())); // Login Account account = DatabaseHelper.getAccountById(requestData.uid); diff --git a/src/main/java/emu/grasscutter/utils/Language.java b/src/main/java/emu/grasscutter/utils/Language.java index ec56b41d9..8acb05cd4 100644 --- a/src/main/java/emu/grasscutter/utils/Language.java +++ b/src/main/java/emu/grasscutter/utils/Language.java @@ -29,7 +29,13 @@ public final class Language { * @return A translated value with arguments substituted. */ public static String translate(String key, Object... args) { - return Grasscutter.getLanguage().get(key).formatted(args); + String translated = Grasscutter.getLanguage().get(key); + try { + return translated.formatted(args); + } catch (Exception exception) { + Grasscutter.getLogger().error("Failed to format string: " + key, exception); + return translated; + } } /**