Use localized messages

This commit is contained in:
Xujiayao 2026-03-18 12:48:37 +08:00
parent ed61e30a76
commit 31747ed4f4
7 changed files with 15 additions and 6 deletions

View file

@ -247,7 +247,7 @@ public class ConsoleCommand implements Command {
} else {
String[] lines = response.response.split("\n");
for (String line : lines) {
sender.reply("[" + serverName + "] " + line);
sender.reply(I18nManager.getDmccTranslation("commands.remote_result_prefix", serverName, line));
}
}
} catch (Exception e) {

View file

@ -172,11 +172,11 @@ public class ExecuteCommand implements Command {
} else {
// Terminal: send result directly
if (response.fileData != null && response.fileName != null) {
sender.replyWithFile("[" + serverName + "] " + response.response, response.fileData, response.fileName);
sender.replyWithFile(I18nManager.getDmccTranslation("commands.remote_result_prefix", serverName, response.response), response.fileData, response.fileName);
} else {
String[] lines = response.response.split("\n");
for (String line : lines) {
sender.reply("[" + serverName + "] " + line);
sender.reply(I18nManager.getDmccTranslation("commands.remote_result_prefix", serverName, line));
}
}
}

View file

@ -106,7 +106,7 @@ public class ServerHandler extends SimpleChannelInboundHandler<Packet> {
DiscordManager.clientBroadcast(clientName, "player.die", "player.die", false, p.placeholders);
case PLAYER_ADVANCEMENT ->
DiscordManager.clientBroadcast(clientName, "player.advancement", "player.advancement." + p.placeholders.get("type"), false, p.placeholders);
// Unhandled events
// TODO Unhandled events
default ->
LOGGER.warn("Received MinecraftEventPacket from authenticated client {}: type={}, placeholders={}", clientName, p.type, p.placeholders);
}

View file

@ -221,7 +221,7 @@ public class DiscordManager {
try {
doUpdateBotPresence(enableStatus, enableActivity);
} catch (Exception e) {
LOGGER.warn("Failed to update bot presence: " + e.getMessage());
LOGGER.warn(I18nManager.getDmccTranslation("discord.manager.presence_update_failed", e.getMessage()));
}
}, 0, 30, TimeUnit.SECONDS);
}

View file

@ -9,6 +9,7 @@ import com.xujiayao.discord_mc_chat.utils.config.ConfigManager;
import com.xujiayao.discord_mc_chat.utils.config.ModeManager;
import com.xujiayao.discord_mc_chat.utils.events.CoreEvents;
import com.xujiayao.discord_mc_chat.utils.events.EventManager;
import com.xujiayao.discord_mc_chat.utils.i18n.I18nManager;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.User;
@ -117,7 +118,7 @@ public class OpSyncManager {
return OpLevelResolver.resolve(member, user);
}
} catch (Exception e) {
LOGGER.warn("Failed to resolve OP level for Discord user {}: {}", discordId, e.getMessage());
LOGGER.warn(I18nManager.getDmccTranslation("linking.op_sync.resolve_failed", discordId, e.getMessage()));
return -1;
}
}

View file

@ -17,6 +17,7 @@ commands:
execution_failed: "Command execution failed: {}"
invalid_usage: "Invalid usage. Correct usage: \"{}\""
insufficient_permission: "You do not have enough permissions to execute this command."
remote_result_prefix: "[{}] {}"
console:
description: "Execute a Minecraft command"
args_desc:
@ -172,6 +173,7 @@ discord:
registering_commands: "Registering Discord DMCC commands. This may take a while... (should be within 1 minute)"
commands_success: "Discord DMCC commands registered successfully!"
commands_failed: "Failed to register Discord DMCC commands."
presence_update_failed: "Failed to update bot presence: {}"
channel_not_found: "Discord text channel not found: \"{}\""
channel_cannot_talk: "Cannot send messages in Discord text channel: \"{}\""
insufficient_permission: "Discord bot has insufficient permissions in channel {}: \"{}\""
@ -293,6 +295,8 @@ linking:
generated: "Generated account linking verification code for Minecraft player {}."
refreshed: "Refreshed account linking verification code validity for Minecraft player {}."
consumed: "Minecraft player {} completed account linking."
op_sync:
resolve_failed: "Failed to resolve OP level for Discord user {}: {}"
message:
not_linked_1: "You are not linked to a Discord user. Use "
not_linked_2: " command on Discord to complete linking. The code expires in 5 minutes. Run "

View file

@ -17,6 +17,7 @@ commands:
execution_failed: "命令执行失败:{}"
invalid_usage: "用法错误。正确用法:\"{}\""
insufficient_permission: "你没有足够的权限执行此命令。"
remote_result_prefix: "[{}] {}"
console:
description: "执行 Minecraft 命令"
args_desc:
@ -172,6 +173,7 @@ discord:
registering_commands: "正在注册 Discord DMCC 命令。这可能需要一段时间...(理应在 1 分钟以内)"
commands_success: "Discord DMCC 命令注册成功!"
commands_failed: "注册 Discord DMCC 命令失败。"
presence_update_failed: "更新机器人状态失败:{}"
channel_not_found: "未找到 Discord 文字频道:\"{}\""
channel_cannot_talk: "无法在 Discord 文字频道中发送消息:\"{}\""
insufficient_permission: "Discord 机器人在频道 {} 中权限不足:\"{}\""
@ -293,6 +295,8 @@ linking:
generated: "已为 Minecraft 玩家 {} 生成账户绑定验证码。"
refreshed: "已刷新 Minecraft 玩家 {} 的账户绑定验证码有效期。"
consumed: "Minecraft 玩家 {} 完成了账户绑定。"
op_sync:
resolve_failed: "解析 Discord 用户 {} 的 OP 等级失败:{}"
message:
not_linked_1: "你尚未绑定 Discord 用户。在 Discord 上使用 "
not_linked_2: " 命令完成绑定。验证码将在 5 分钟后过期,届时可在游戏内执行 "