diff --git a/MinecraftClient/CSharpRunner.cs b/MinecraftClient/CSharpRunner.cs index 1c3ee2f2..9f3475d9 100644 --- a/MinecraftClient/CSharpRunner.cs +++ b/MinecraftClient/CSharpRunner.cs @@ -34,7 +34,7 @@ namespace MinecraftClient //Script compatibility check for handling future versions differently if (lines.Length < 1 || lines[0] != "//MCCScript 1.0") throw new CSharpException(CSErrorType.InvalidScript, - new InvalidDataException("The provided script does not have a valid MCCScript header")); + new InvalidDataException(Translations.Get("exception.csrunner.invalid_head"))); //Script hash for determining if it was previously compiled ulong scriptHash = QuickHash(lines); diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index bc769e55..4fcc23db 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -50,9 +50,7 @@ namespace MinecraftClient return master.Handler; if (_handler != null) return _handler; - throw new InvalidOperationException( - "ChatBot methods should NOT be called in the constructor as API handler is not initialized yet." - + " Override Initialize() or AfterGameJoined() instead to perform initialization tasks."); + throw new InvalidOperationException(Translations.Get("exception.chatbot.init")); } } private bool MessageCooldownEnded @@ -762,6 +760,26 @@ namespace MinecraftClient LogToConsole(text); } + /// + /// Write the translated text in the console by giving a translation key. Nothing will be sent to the server. + /// + /// Translation key + /// + protected void LogToConsoleTranslated(string key, params object[] args) + { + LogToConsole(Translations.TryGet(key, args)); + } + + /// + /// Write the translated text in the console by giving a translation key, but only if DebugMessages is enabled in INI file. Nothing will be sent to the server. + /// + /// Translation key + /// + protected void LogDebugToConsoleTranslated(string key, params object[] args) + { + LogDebugToConsole(Translations.TryGet(key, args)); + } + /// /// Disconnect from the server and restart the program /// It will unload and reload all the bots and then reconnect to the server @@ -771,7 +789,7 @@ namespace MinecraftClient protected void ReconnectToTheServer(int ExtraAttempts = 3, int delaySeconds = 0) { if (Settings.DebugMessages) - ConsoleIO.WriteLogLine(String.Format("[{0}] Disconnecting and Reconnecting to the Server", this.GetType().Name)); + ConsoleIO.WriteLogLine(Translations.Get("chatbot.reconnect", this.GetType().Name)); McClient.ReconnectionAttemptsLeft = ExtraAttempts; Program.Restart(delaySeconds); } @@ -1264,9 +1282,9 @@ namespace MinecraftClient /// Description/usage of the command /// Method for handling the command /// True if successfully registered - protected bool RegisterChatBotCommand(string cmdName, string cmdDesc, CommandRunner callback) + protected bool RegisterChatBotCommand(string cmdName, string cmdDesc, string cmdUsage, CommandRunner callback) { - return Handler.RegisterCommand(cmdName, cmdDesc, callback); + return Handler.RegisterCommand(cmdName, cmdDesc, cmdUsage, callback); } /// @@ -1337,9 +1355,11 @@ namespace MinecraftClient private readonly string _cmdName; private readonly string _cmdDesc; + private readonly string _cmdUsage; - public override string CMDName { get { return _cmdName; } } - public override string CMDDesc { get { return _cmdDesc; } } + public override string CmdName { get { return _cmdName; } } + public override string CmdUsage { get { return _cmdUsage; } } + public override string CmdDesc { get { return _cmdDesc; } } public override string Run(McClient handler, string command, Dictionary localVars) { @@ -1349,13 +1369,15 @@ namespace MinecraftClient /// /// ChatBotCommand Constructor /// - /// Name of the command - /// Description/usage of the command - /// Method for handling the command - public ChatBotCommand(string cmdName, string cmdDesc, CommandRunner callback) + /// Name of the command + /// Description of the command. Support tranlation. + /// Usage of the command + /// Method for handling the command + public ChatBotCommand(string cmdName, string cmdDesc, string cmdUsage, CommandRunner callback) { this._cmdName = cmdName; this._cmdDesc = cmdDesc; + this._cmdUsage = cmdUsage; this.Runner = callback; } } diff --git a/MinecraftClient/ChatBots/AutoAttack.cs b/MinecraftClient/ChatBots/AutoAttack.cs index b7e37b2d..6ba10223 100644 --- a/MinecraftClient/ChatBots/AutoAttack.cs +++ b/MinecraftClient/ChatBots/AutoAttack.cs @@ -28,21 +28,21 @@ namespace MinecraftClient.ChatBots singleMode = true; else if (mode == "multi") singleMode = false; - else LogToConsole("Unknown attack mode: " + mode + ". Using single mode as default."); + else LogToConsoleTranslated("bot.autoAttack.mode", mode); if (priority == "distance") priorityDistance = true; else if (priority == "health") priorityDistance = false; - else LogToConsole("Unknown priority: " + priority + ". Using distance priority as default."); + else LogToConsoleTranslated("bot.autoAttack.priority", priority); } public override void Initialize() { if (!GetEntityHandlingEnabled()) { - LogToConsole("Entity Handling is not enabled in the config file!"); - LogToConsole("This bot will be unloaded."); + LogToConsoleTranslated("extra.entity_required"); + LogToConsoleTranslated("general.bot_unload"); UnloadBot(); } } diff --git a/MinecraftClient/ChatBots/AutoCraft.cs b/MinecraftClient/ChatBots/AutoCraft.cs index 1d27af14..de50c61f 100644 --- a/MinecraftClient/ChatBots/AutoCraft.cs +++ b/MinecraftClient/ChatBots/AutoCraft.cs @@ -166,12 +166,13 @@ namespace MinecraftClient.ChatBots { if (!GetInventoryEnabled()) { - LogToConsole("Inventory handling is disabled. AutoCraft will be unloaded"); + LogToConsoleTranslated("extra.inventory_required"); + LogToConsoleTranslated("general.bot_unload"); UnloadBot(); return; } - RegisterChatBotCommand("autocraft", "Auto-crafting ChatBot command", CommandHandler); - RegisterChatBotCommand("ac", "Auto-crafting ChatBot command alias", CommandHandler); + RegisterChatBotCommand("autocraft", Translations.Get("bot.autoCraft.cmd"), GetHelp(), CommandHandler); + RegisterChatBotCommand("ac", Translations.Get("bot.autoCraft.alias"), GetHelp(), CommandHandler); LoadConfig(); } @@ -186,14 +187,14 @@ namespace MinecraftClient.ChatBots return ""; case "list": string names = string.Join(", ", recipes.Keys.ToList()); - return String.Format("Total {0} recipes loaded: {1}", recipes.Count, names); + return Translations.Get("bot.autoCraft.cmd.list", recipes.Count, names); case "reload": recipes.Clear(); LoadConfig(); return ""; case "resetcfg": WriteDefaultConfig(); - return "Resetting your config to default"; + return Translations.Get("bot.autoCraft.cmd.resetcfg"); case "start": if (args.Length >= 2) { @@ -204,12 +205,12 @@ namespace MinecraftClient.ChatBots PrepareCrafting(recipes[name]); return ""; } - else return "Specified recipe name does not exist. Check your config file."; + else return Translations.Get("bot.autoCraft.recipe_not_exist"); } - else return "Please specify the recipe name you want to craft."; + else return Translations.Get("bot.autoCraft.no_recipe_name"); case "stop": StopCrafting(); - return "AutoCraft stopped"; + return Translations.Get("bot.autoCraft.stop"); case "help": return GetCommandHelp(args.Length >= 2 ? args[1] : ""); default: @@ -221,7 +222,7 @@ namespace MinecraftClient.ChatBots private string GetHelp() { - return "Available commands: load, list, reload, resetcfg, start, stop, help. Use /autocraft help for more information. You may use /ac as command alias."; + return Translations.Get("bot.autoCraft.available_cmd", "load, list, reload, resetcfg, start, stop, help"); } private string GetCommandHelp(string cmd) @@ -229,19 +230,19 @@ namespace MinecraftClient.ChatBots switch (cmd.ToLower()) { case "load": - return "Load the config file."; + return Translations.Get("bot.autocraft.help.load"); case "list": - return "List loaded recipes name."; + return Translations.Get("bot.autocraft.help.list"); case "reload": - return "Reload the config file."; + return Translations.Get("bot.autocraft.help.reload"); case "resetcfg": - return "Write the default example config to default location."; + return Translations.Get("bot.autocraft.help.resetcfg"); case "start": - return "Start the crafting. Usage: /autocraft start "; + return Translations.Get("bot.autocraft.help.start"); case "stop": - return "Stop the current running crafting process"; + return Translations.Get("bot.autocraft.help.stop"); case "help": - return "Get the command description. Usage: /autocraft help "; + return Translations.Get("bot.autocraft.help.help"); default: return GetHelp(); } @@ -258,16 +259,16 @@ namespace MinecraftClient.ChatBots Directory.CreateDirectory(@"autocraft"); } WriteDefaultConfig(); - LogDebugToConsole("No config found. Writing a new one."); + LogDebugToConsoleTranslated("bot.autoCraft.debug.no_config"); } try { ParseConfig(); - LogToConsole("Successfully loaded"); + LogToConsoleTranslated("bot.autoCraft.loaded"); } catch (Exception e) { - LogToConsole("Error while parsing config: \n" + e.Message); + LogToConsoleTranslated("bot.autoCraft.error.config", "\n" + e.Message); } } @@ -301,11 +302,11 @@ namespace MinecraftClient.ChatBots string[] content = File.ReadAllLines(configPath); if (content.Length <= 0) { - throw new Exception("Empty onfiguration file: " + configPath); + throw new Exception(Translations.Get("bot.autoCraft.exception.empty", configPath)); } if (content[0].ToLower() != "[autocraft]") { - throw new Exception("Invalid configuration file: " + configPath); + throw new Exception(Translations.Get("bot.autoCraft.exception.invalid", configPath)); } // local variable for use in parsing config @@ -352,7 +353,7 @@ namespace MinecraftClient.ChatBots } else { - throw new Exception("Missing item in recipe: " + pair.Key); + throw new Exception(Translations.Get("bot.autoCraft.exception.item_miss", pair.Key)); } } @@ -373,7 +374,7 @@ namespace MinecraftClient.ChatBots tableLocation.Y = Convert.ToInt32(values[1]); tableLocation.Z = Convert.ToInt32(values[2]); } - else throw new Exception("Invalid tablelocation format: " + key); + else throw new Exception(Translations.Get("bot.autoCraft.exception.invalid_table", key)); break; case "onfailure": abortOnFailure = value.ToLower() == "abort" ? true : false; @@ -411,17 +412,17 @@ namespace MinecraftClient.ChatBots } else { - throw new Exception("Invalid item name in recipe " + lastRecipe + " at " + key); + throw new Exception(Translations.Get("bot.autoCraft.exception.item_name", lastRecipe, key)); } } else { - throw new Exception("Missing recipe name while parsing a recipe"); + throw new Exception(Translations.Get("bot.autoCraft.exception.name_miss")); } } else { - throw new Exception("Invalid slot field in recipe: " + key); + throw new Exception(Translations.Get("bot.autoCraft.exception.slot", key)); } } else @@ -436,7 +437,7 @@ namespace MinecraftClient.ChatBots } else { - throw new Exception("Duplicate recipe name specified: " + value); + throw new Exception(Translations.Get("bot.autoCraft.exception.duplicate", value)); } break; case "type": @@ -555,7 +556,7 @@ namespace MinecraftClient.ChatBots // table required but not found. Try to open one OpenTable(tableLocation); waitingForTable = true; - SetTimeout("table not found"); + SetTimeout(Translations.Get("bot.autoCraft.table_not_found")); return; } } @@ -577,10 +578,10 @@ namespace MinecraftClient.ChatBots // Repeat the whole process again actionSteps.Add(new ActionStep(ActionType.Repeat)); // Start crafting - ConsoleIO.WriteLogLine("Starting AutoCraft: " + recipe.ResultItem); + LogToConsoleTranslated("bot.autoCraft.start", recipe.ResultItem); HandleNextStep(); } - else ConsoleIO.WriteLogLine("AutoCraft cannot be started. Check your available materials for crafting " + recipe.ResultItem); + else LogToConsoleTranslated("bot.autoCraft.start_fail", recipe.ResultItem); } /// @@ -596,7 +597,7 @@ namespace MinecraftClient.ChatBots if (GetInventories().ContainsKey(inventoryInUse)) { CloseInventory(inventoryInUse); - ConsoleIO.WriteLogLine("Inventory #" + inventoryInUse + " was closed by AutoCraft"); + LogToConsoleTranslated("bot.autoCraft.close_inventory", inventoryInUse); } } @@ -679,12 +680,12 @@ namespace MinecraftClient.ChatBots if (actionSteps[index - 1].ActionType == ActionType.LeftClick && actionSteps[index - 1].ItemType != ItemType.Air) { // Inform user the missing meterial name - ConsoleIO.WriteLogLine("Missing material: " + actionSteps[index - 1].ItemType.ToString()); + LogToConsoleTranslated("bot.autoCraft.missing_material", actionSteps[index - 1].ItemType.ToString()); } if (abortOnFailure) { StopCrafting(); - ConsoleIO.WriteLogLine("Crafting aborted! Check your available materials."); + LogToConsoleTranslated("bot.autoCraft.aborted"); } else { @@ -692,14 +693,14 @@ namespace MinecraftClient.ChatBots // Even though crafting failed, action step index will still increase // we want to do that failed step again so decrease index by 1 index--; - ConsoleIO.WriteLogLine("Crafting failed! Waiting for more materials"); + LogToConsoleTranslated("bot.autoCraft.craft_fail"); } } } private void HandleUpdateTimeout() { - ConsoleIO.WriteLogLine("Action timeout! Reason: " + timeoutAction); + LogToConsoleTranslated("bot.autoCraft.timeout", timeoutAction); } /// diff --git a/MinecraftClient/ChatBots/AutoDrop.cs b/MinecraftClient/ChatBots/AutoDrop.cs index b5045e7b..e3250d2d 100644 --- a/MinecraftClient/ChatBots/AutoDrop.cs +++ b/MinecraftClient/ChatBots/AutoDrop.cs @@ -64,10 +64,10 @@ namespace MinecraftClient.ChatBots enable = true; inventoryUpdated = 0; OnUpdateFinish(); - return "AutoDrop enabled"; + return Translations.Get("bot.autoDrop.on"); case "off": enable = false; - return "AutoDrop disabled"; + return Translations.Get("bot.autoDrop.off"); case "add": if (args.Length >= 2) { @@ -75,16 +75,16 @@ namespace MinecraftClient.ChatBots if (Enum.TryParse(args[1], true, out item)) { itemList.Add(item); - return "Added item " + item.ToString(); + return Translations.Get("bot.autoDrop.added", item.ToString()); } else { - return "Incorrect item name " + args[1] + ". Please try again"; + return Translations.Get("bot.autoDrop.incorrect_name", args[1]); } } else { - return "Usage: add "; + return Translations.Get("cmd.inventory.help.usage") + ": add "; } case "remove": if (args.Length >= 2) @@ -95,30 +95,30 @@ namespace MinecraftClient.ChatBots if (itemList.Contains(item)) { itemList.Remove(item); - return "Removed item " + item.ToString(); + return Translations.Get("bot.autoDrop.removed", item.ToString()); } else { - return "Item not in the list"; + return Translations.Get("bot.autoDrop.not_in_list"); } } else { - return "Incorrect item name " + args[1] + ". Please try again"; + return Translations.Get("bot.autoDrop.incorrect_name", args[1]); } } else { - return "Usage: remove "; + return Translations.Get("cmd.inventory.help.usage") + ": remove "; } case "list": if (itemList.Count > 0) { - return "Total " + itemList.Count + " in the list:\n" + string.Join("\n", itemList); + return Translations.Get("bot.autoDrop.list", itemList.Count, string.Join("\n", itemList)); } else { - return "No item in the list"; + return Translations.Get("bot.autoDrop.no_item"); } default: return GetHelp(); @@ -132,19 +132,20 @@ namespace MinecraftClient.ChatBots private string GetHelp() { - return "AutoDrop ChatBot command. Available commands: on, off, add, remove, list"; + return Translations.Get("general.available_cmd", "on, off, add, remove, list"); } public override void Initialize() { if (!GetInventoryEnabled()) { - LogToConsole("Inventory handling is disabled. Unloading..."); + LogToConsoleTranslated("extra.inventory_required"); + LogToConsoleTranslated("general.bot_unload"); UnloadBot(); return; } - RegisterChatBotCommand("autodrop", "AutoDrop ChatBot command", CommandHandler); - RegisterChatBotCommand("ad", "AutoDrop ChatBot command alias", CommandHandler); + RegisterChatBotCommand("autodrop", Translations.Get("bot.autoDrop.cmd"), GetHelp(), CommandHandler); + RegisterChatBotCommand("ad", Translations.Get("bot.autoDrop.alias"), GetHelp(), CommandHandler); } public override void Update() diff --git a/MinecraftClient/ChatBots/AutoFishing.cs b/MinecraftClient/ChatBots/AutoFishing.cs index e5e91adb..fbcc6654 100644 --- a/MinecraftClient/ChatBots/AutoFishing.cs +++ b/MinecraftClient/ChatBots/AutoFishing.cs @@ -25,8 +25,8 @@ namespace MinecraftClient.ChatBots { if (!GetEntityHandlingEnabled()) { - LogToConsole("Entity Handling is not enabled in the config file!"); - LogToConsole("This bot will be unloaded."); + LogToConsoleTranslated("extra.entity_required"); + LogToConsoleTranslated("general.bot_unload"); UnloadBot(); } inventoryEnabled = GetInventoryEnabled(); @@ -50,7 +50,7 @@ namespace MinecraftClient.ChatBots { if (GetCurrentLocation().Distance(entity.Location) < 2 && !isFishing) { - LogToConsole("Threw a fishing rod"); + LogToConsoleTranslated("bot.autoFish.throw"); fishingRod = entity; LastPos = entity.Location; isFishing = true; @@ -108,14 +108,14 @@ namespace MinecraftClient.ChatBots /// public void OnCaughtFish() { - LogToConsole(GetTimestamp() + ": Caught a fish!"); + LogToConsole(GetTimestamp() + ": " + Translations.Get("bot.autoFish.caught")); // retract fishing rod UseItemInHand(); if (inventoryEnabled) { if (!hasFishingRod()) { - LogToConsole(GetTimestamp() + ": No Fishing Rod on hand. Maybe broken?"); + LogToConsole(GetTimestamp() + ": " + Translations.Get("bot.autoFish.no_rod")); return; } } diff --git a/MinecraftClient/ChatBots/AutoRelog.cs b/MinecraftClient/ChatBots/AutoRelog.cs index 74c2dfca..572a496f 100644 --- a/MinecraftClient/ChatBots/AutoRelog.cs +++ b/MinecraftClient/ChatBots/AutoRelog.cs @@ -26,7 +26,7 @@ namespace MinecraftClient.ChatBots McClient.ReconnectionAttemptsLeft = attempts; delay = DelayBeforeRelog; if (delay < 1) { delay = 1; } - LogDebugToConsole("Launching with " + attempts + " reconnection attempts"); + LogDebugToConsoleTranslated("bot.autoRelog.launch", attempts); } public override void Initialize() @@ -34,27 +34,27 @@ namespace MinecraftClient.ChatBots McClient.ReconnectionAttemptsLeft = attempts; if (Settings.AutoRelog_IgnoreKickMessage) { - LogDebugToConsole("Initializing without a kick message file"); + LogDebugToConsoleTranslated("bot.autoRelog.no_kick_msg"); } else { if (System.IO.File.Exists(Settings.AutoRelog_KickMessagesFile)) { - LogDebugToConsole("Loading messages from file: " + System.IO.Path.GetFullPath(Settings.AutoRelog_KickMessagesFile)); + LogDebugToConsoleTranslated("bot.autoRelog.loading", System.IO.Path.GetFullPath(Settings.AutoRelog_KickMessagesFile)); dictionary = System.IO.File.ReadAllLines(Settings.AutoRelog_KickMessagesFile, Encoding.UTF8); for (int i = 0; i < dictionary.Length; i++) { - LogDebugToConsole(" Loaded message: " + dictionary[i]); + LogDebugToConsoleTranslated("bot.autoRelog.loaded", dictionary[i]); dictionary[i] = dictionary[i].ToLower(); } } else { - LogToConsole("File not found: " + System.IO.Path.GetFullPath(Settings.AutoRelog_KickMessagesFile)); + LogToConsoleTranslated("bot.autoRelog.not_found", System.IO.Path.GetFullPath(Settings.AutoRelog_KickMessagesFile)); - LogDebugToConsole(" Current directory was: " + System.IO.Directory.GetCurrentDirectory()); + LogDebugToConsoleTranslated("bot.autoRelog.curr_dir", System.IO.Directory.GetCurrentDirectory()); } } } @@ -63,19 +63,19 @@ namespace MinecraftClient.ChatBots { if (reason == DisconnectReason.UserLogout) { - LogDebugToConsole("Disconnection initiated by User or MCC bot. Ignoring."); + LogDebugToConsoleTranslated("bot.autoRelog.ignore"); } else { message = GetVerbatim(message); string comp = message.ToLower(); - LogDebugToConsole("Got disconnected with message: " + message); + LogDebugToConsoleTranslated("bot.autoRelog.disconnect_msg", message); if (Settings.AutoRelog_IgnoreKickMessage) { - LogDebugToConsole("Ignoring kick message, reconnecting anyway."); - LogToConsole("Waiting " + delay + " seconds before reconnecting..."); + LogDebugToConsoleTranslated("bot.autoRelog.reconnect_always"); + LogToConsoleTranslated("bot.autoRelog.wait", delay); System.Threading.Thread.Sleep(delay * 1000); ReconnectToTheServer(); return true; @@ -85,8 +85,8 @@ namespace MinecraftClient.ChatBots { if (comp.Contains(msg)) { - LogDebugToConsole("Message contains '" + msg + "'. Reconnecting."); - LogToConsole("Waiting " + delay + " seconds before reconnecting..."); + LogDebugToConsoleTranslated("bot.autoRelog.reconnect", msg); + LogToConsoleTranslated("bot.autoRelog.wait", delay); System.Threading.Thread.Sleep(delay * 1000); McClient.ReconnectionAttemptsLeft = attempts; ReconnectToTheServer(); @@ -94,7 +94,7 @@ namespace MinecraftClient.ChatBots } } - LogDebugToConsole("Message not containing any defined keywords. Ignoring."); + LogDebugToConsoleTranslated("bot.autoRelog.reconnect_ignore"); } return false; diff --git a/MinecraftClient/ChatBots/ChatLog.cs b/MinecraftClient/ChatBots/ChatLog.cs index dbd028e3..004e2be6 100644 --- a/MinecraftClient/ChatBots/ChatLog.cs +++ b/MinecraftClient/ChatBots/ChatLog.cs @@ -62,7 +62,7 @@ namespace MinecraftClient.ChatBots } if (String.IsNullOrEmpty(file) || file.IndexOfAny(Path.GetInvalidPathChars()) >= 0) { - LogToConsole("Path '" + file + "' contains invalid characters."); + LogToConsoleTranslated("bot.chatLog.invalid_file", file); UnloadBot(); } } diff --git a/MinecraftClient/ChatBots/Mailer.cs b/MinecraftClient/ChatBots/Mailer.cs index aa51b4f3..f22b82ba 100644 --- a/MinecraftClient/ChatBots/Mailer.cs +++ b/MinecraftClient/ChatBots/Mailer.cs @@ -156,53 +156,53 @@ namespace MinecraftClient.ChatBots /// public override void Initialize() { - LogDebugToConsole("Initializing Mailer with settings:"); - LogDebugToConsole(" - Database File: " + Settings.Mailer_DatabaseFile); - LogDebugToConsole(" - Ignore List: " + Settings.Mailer_IgnoreListFile); - LogDebugToConsole(" - Public Interactions: " + Settings.Mailer_PublicInteractions); - LogDebugToConsole(" - Max Mails per Player: " + Settings.Mailer_MaxMailsPerPlayer); - LogDebugToConsole(" - Max Database Size: " + Settings.Mailer_MaxDatabaseSize); - LogDebugToConsole(" - Mail Retention: " + Settings.Mailer_MailRetentionDays + " days"); + LogDebugToConsoleTranslated("bot.mailer.init"); + LogDebugToConsoleTranslated("bot.mailer.init.db" + Settings.Mailer_DatabaseFile); + LogDebugToConsoleTranslated("bot.mailer.init.ignore" + Settings.Mailer_IgnoreListFile); + LogDebugToConsoleTranslated("bot.mailer.init.public" + Settings.Mailer_PublicInteractions); + LogDebugToConsoleTranslated("bot.mailer.init.max_mails" + Settings.Mailer_MaxMailsPerPlayer); + LogDebugToConsoleTranslated("bot.mailer.init.db_size" + Settings.Mailer_MaxDatabaseSize); + LogDebugToConsoleTranslated("bot.mailer.init.mail_retention" + Settings.Mailer_MailRetentionDays + " days"); if (Settings.Mailer_MaxDatabaseSize <= 0) { - LogToConsole("Cannot enable Mailer: Max Database Size must be greater than zero. Please review the settings."); + LogToConsoleTranslated("bot.mailer.init_fail.db_size"); UnloadBot(); return; } if (Settings.Mailer_MaxMailsPerPlayer <= 0) { - LogToConsole("Cannot enable Mailer: Max Mails per Player must be greater than zero. Please review the settings."); + LogToConsoleTranslated("bot.mailer.init_fail.max_mails"); UnloadBot(); return; } if (Settings.Mailer_MailRetentionDays <= 0) { - LogToConsole("Cannot enable Mailer: Mail Retention must be greater than zero. Please review the settings."); + LogToConsoleTranslated("bot.mailer.init_fail.mail_retention"); UnloadBot(); return; } if (!File.Exists(Settings.Mailer_DatabaseFile)) { - LogToConsole("Creating new database file: " + Path.GetFullPath(Settings.Mailer_DatabaseFile)); + LogToConsoleTranslated("bot.mailer.create.db", Path.GetFullPath(Settings.Mailer_DatabaseFile)); new MailDatabase().SaveToFile(Settings.Mailer_DatabaseFile); } if (!File.Exists(Settings.Mailer_IgnoreListFile)) { - LogToConsole("Creating new ignore list: " + Path.GetFullPath(Settings.Mailer_IgnoreListFile)); + LogToConsoleTranslated("bot.mailer.create.ignore", Path.GetFullPath(Settings.Mailer_IgnoreListFile)); new IgnoreList().SaveToFile(Settings.Mailer_IgnoreListFile); } lock (readWriteLock) { - LogDebugToConsole("Loading database file: " + Path.GetFullPath(Settings.Mailer_DatabaseFile)); + LogDebugToConsoleTranslated("bot.mailer.load.db", Path.GetFullPath(Settings.Mailer_DatabaseFile)); mailDatabase = MailDatabase.FromFile(Settings.Mailer_DatabaseFile); - LogDebugToConsole("Loading ignore list: " + Path.GetFullPath(Settings.Mailer_IgnoreListFile)); + LogDebugToConsoleTranslated("bot.mailer.load.ignore", Path.GetFullPath(Settings.Mailer_IgnoreListFile)); ignoreList = IgnoreList.FromFile(Settings.Mailer_IgnoreListFile); } @@ -210,7 +210,7 @@ namespace MinecraftClient.ChatBots mailDbFileMonitor = new FileMonitor(Path.GetDirectoryName(Settings.Mailer_DatabaseFile), Path.GetFileName(Settings.Mailer_DatabaseFile), FileMonitorCallback); ignoreListFileMonitor = new FileMonitor(Path.GetDirectoryName(Settings.Mailer_IgnoreListFile), Path.GetFileName(Settings.Mailer_IgnoreListFile), FileMonitorCallback); - RegisterChatBotCommand("mailer", "Subcommands: getmails, addignored, getignored, removeignored", ProcessInternalCommand); + RegisterChatBotCommand("mailer", Translations.Get("bot.mailer.cmd"), "mailer ", ProcessInternalCommand); } /// @@ -258,7 +258,7 @@ namespace MinecraftClient.ChatBots if (message.Length <= maxMessageLength) { Mail mail = new Mail(username, recipient, message, anonymous, DateTime.Now); - LogToConsole("Saving message: " + mail.ToString()); + LogToConsoleTranslated("bot.mailer.saving", mail.ToString()); lock (readWriteLock) { mailDatabase.Add(mail); @@ -276,7 +276,7 @@ namespace MinecraftClient.ChatBots break; } } - else LogDebugToConsole(username + " is ignored!"); + else LogDebugToConsoleTranslated("bot.mailer.user_ignored", username); } } @@ -288,7 +288,7 @@ namespace MinecraftClient.ChatBots DateTime dateNow = DateTime.Now; if (nextMailSend < dateNow) { - LogDebugToConsole("Looking for mails to send @ " + DateTime.Now); + LogDebugToConsoleTranslated("bot.mailer.process_mails", DateTime.Now); // Process at most 3 mails at a time to avoid spamming. Other mails will be processed on next mail send HashSet onlinePlayersLowercase = new HashSet(GetOnlinePlayers().Select(name => name.ToLower())); @@ -297,7 +297,7 @@ namespace MinecraftClient.ChatBots string sender = mail.Anonymous ? "Anonymous" : mail.Sender; SendPrivateMessage(mail.Recipient, sender + " mailed: " + mail.Content); mail.setDelivered(); - LogDebugToConsole("Delivered: " + mail.ToString()); + LogDebugToConsoleTranslated("bot.mailer.delivered", mail.ToString()); } lock (readWriteLock) @@ -335,11 +335,11 @@ namespace MinecraftClient.ChatBots string commandName = args[0].ToLower(); switch (commandName) { - case "getmails": - return "== Mails in database ==\n" + string.Join("\n", mailDatabase); + case "getmails": // Sorry, I (ReinforceZwei) replaced "=" to "-" because it would affect the parsing of translation file (key=value) + return Translations.Get("bot.mailer.cmd.getmails", string.Join("\n", mailDatabase)); case "getignored": - return "== Ignore list ==\n" + string.Join("\n", ignoreList); + return Translations.Get("bot.mailer.cmd.getignored", string.Join("\n", ignoreList)); case "addignored": case "removeignored": @@ -356,7 +356,7 @@ namespace MinecraftClient.ChatBots ignoreList.SaveToFile(Settings.Mailer_IgnoreListFile); } } - return "Added " + args[1] + " to the ignore list!"; + return Translations.Get("bot.mailer.cmd.ignore.added", args[1]); } else { @@ -368,13 +368,13 @@ namespace MinecraftClient.ChatBots ignoreList.SaveToFile(Settings.Mailer_IgnoreListFile); } } - return "Removed " + args[1] + " from the ignore list!"; + return Translations.Get("bot.mailer.cmd.ignore.removed", args[1]); } } - else return "Missing or invalid name. Usage: " + commandName + " "; + else return Translations.Get("bot.mailer.cmd.ignore.invalid", commandName); } } - return "See usage: /help mailer"; + return Translations.Get("bot.mailer.cmd.help") + ": /help mailer"; } } } diff --git a/MinecraftClient/ChatBots/ReplayCapture.cs b/MinecraftClient/ChatBots/ReplayCapture.cs index b8014546..0685ba25 100644 --- a/MinecraftClient/ChatBots/ReplayCapture.cs +++ b/MinecraftClient/ChatBots/ReplayCapture.cs @@ -29,7 +29,7 @@ namespace MinecraftClient.ChatBots replay.MetaData.serverName = GetServerHost() + GetServerPort(); backupCounter = backupInterval; - RegisterChatBotCommand("replay", "replay command", Command); + RegisterChatBotCommand("replay", Translations.Get("bot.replayCapture.cmd"), "replay ", Command); } public override void OnNetworkPacket(int packetID, List packetData, bool isLogin, bool isInbound) @@ -69,18 +69,18 @@ namespace MinecraftClient.ChatBots case "save": { replay.CreateBackupReplay(@"replay_recordings\" + replay.GetReplayDefaultName()); - return "Replay file created."; + return Translations.Get("bot.replayCapture.created"); } case "stop": { replay.OnShutDown(); - return "Record stopped."; + return Translations.Get("bot.replayCapture.stopped"); } } } - return "Available commands: save, stop"; + return Translations.Get("general.available_cmd", "save, stop"); } - else return "Record was stopped. Restart the program to start another record."; + else return Translations.Get("bot.replayCapture.restart"); } catch (Exception e) { diff --git a/MinecraftClient/ChatBots/Script.cs b/MinecraftClient/ChatBots/Script.cs index 89eb92a4..a86f49a1 100644 --- a/MinecraftClient/ChatBots/Script.cs +++ b/MinecraftClient/ChatBots/Script.cs @@ -121,7 +121,7 @@ namespace MinecraftClient.ChatBots caller = type.Name; } catch { } - ConsoleIO.WriteLineFormatted(String.Format("§8[MCC] [{0}] Cannot find script file: {1}", caller, filename)); + ConsoleIO.WriteLineFormatted(Translations.Get("bot.script.not_found", caller, filename)); } return false; @@ -137,14 +137,14 @@ namespace MinecraftClient.ChatBots thread = null; if (!String.IsNullOrEmpty(owner)) - SendPrivateMessage(owner, "Script '" + file + "' loaded."); + SendPrivateMessage(owner, Translations.Get("bot.script.pm.loaded", file)); } else { - LogToConsole("File not found: '" + System.IO.Path.GetFullPath(file) + "'"); + LogToConsoleTranslated("bot.script.file_not_found", System.IO.Path.GetFullPath(file)); if (!String.IsNullOrEmpty(owner)) - SendPrivateMessage(owner, "File not found: '" + file + "'"); + SendPrivateMessage(owner, Translations.Get("bot.script.file_not_found", file)); UnloadBot(); //No need to keep the bot active } @@ -166,7 +166,7 @@ namespace MinecraftClient.ChatBots } catch (CSharpException e) { - string errorMessage = "Script '" + file + "' failed to run (" + e.ExceptionType + ")."; + string errorMessage = Translations.Get("bot.script.fail", file, e.ExceptionType); LogToConsole(errorMessage); if (owner != null) SendPrivateMessage(owner, errorMessage); diff --git a/MinecraftClient/ChatBots/ScriptScheduler.cs b/MinecraftClient/ChatBots/ScriptScheduler.cs index f418570d..a82fe48a 100644 --- a/MinecraftClient/ChatBots/ScriptScheduler.cs +++ b/MinecraftClient/ChatBots/ScriptScheduler.cs @@ -44,8 +44,7 @@ namespace MinecraftClient.ChatBots //Load the given file from the startup parameters if (System.IO.File.Exists(tasksfile)) { - if (Settings.DebugMessages) - LogToConsole("Loading tasks from '" + System.IO.Path.GetFullPath(tasksfile) + "'"); + LogDebugToConsoleTranslated("bot.scriptScheduler.loading", System.IO.Path.GetFullPath(tasksfile)); TaskDesc current_task = null; String[] lines = System.IO.File.ReadAllLines(tasksfile, Encoding.UTF8); foreach (string lineRAW in lines) @@ -88,7 +87,7 @@ namespace MinecraftClient.ChatBots } else { - LogToConsole("File not found: '" + System.IO.Path.GetFullPath(tasksfile) + "'"); + LogToConsoleTranslated("bot.scriptScheduler.not_found", System.IO.Path.GetFullPath(tasksfile)); UnloadBot(); //No need to keep the bot active } } @@ -107,19 +106,19 @@ namespace MinecraftClient.ChatBots || (current_task.triggerOnTime && current_task.triggerOnTime_Times.Count > 0) || (current_task.triggerOnInterval && current_task.triggerOnInterval_Interval > 0)) { - if (Settings.DebugMessages) - LogToConsole("Loaded task:\n" + Task2String(current_task)); + + LogDebugToConsoleTranslated("bot.scriptScheduler.loaded_task", Task2String(current_task)); current_task.triggerOnInterval_Interval_Countdown = current_task.triggerOnInterval_Interval; //Init countdown for interval tasks.Add(current_task); } - else if (Settings.DebugMessages) + else { - LogToConsole("This task will never trigger:\n" + Task2String(current_task)); + LogDebugToConsoleTranslated("bot.scriptScheduler.no_trigger", Task2String(current_task)); } } - else if (Settings.DebugMessages) + else { - LogToConsole("No action for task:\n" + Task2String(current_task)); + LogDebugToConsoleTranslated("bot.scriptScheduler.no_action", Task2String(current_task)); } } } @@ -145,8 +144,7 @@ namespace MinecraftClient.ChatBots if (!task.triggerOnTime_alreadyTriggered) { task.triggerOnTime_alreadyTriggered = true; - if (Settings.DebugMessages) - LogToConsole("Time / Running action: " + task.action); + LogDebugToConsoleTranslated("bot.scriptScheduler.running_time", task.action); PerformInternalCommand(task.action); } } @@ -161,8 +159,7 @@ namespace MinecraftClient.ChatBots if (task.triggerOnInterval_Interval_Countdown == 0) { task.triggerOnInterval_Interval_Countdown = task.triggerOnInterval_Interval; - if (Settings.DebugMessages) - LogToConsole("Interval / Running action: " + task.action); + LogDebugToConsoleTranslated("bot.scriptScheduler.running_inverval", task.action); PerformInternalCommand(task.action); } else task.triggerOnInterval_Interval_Countdown--; @@ -175,8 +172,7 @@ namespace MinecraftClient.ChatBots { if (task.triggerOnLogin || (firstlogin_done == false && task.triggerOnFirstLogin)) { - if (Settings.DebugMessages) - LogToConsole("Login / Running action: " + task.action); + LogDebugToConsoleTranslated("bot.scriptScheduler.running_login", task.action); PerformInternalCommand(task.action); } } @@ -196,9 +192,8 @@ namespace MinecraftClient.ChatBots private static string Task2String(TaskDesc task) { - return String.Format( - " triggeronfirstlogin = {0}\n triggeronlogin = {1}\n triggerontime = {2}\n " - + "triggeroninterval = {3}\n timevalue = {4}\n timeinterval = {5}\n action = {6}", + return Translations.Get( + "bot.scriptScheduler.task", task.triggerOnFirstLogin, task.triggerOnLogin, task.triggerOnTime, diff --git a/MinecraftClient/ChatBots/TestBot.cs b/MinecraftClient/ChatBots/TestBot.cs index e8afcaa6..c531e85b 100644 --- a/MinecraftClient/ChatBots/TestBot.cs +++ b/MinecraftClient/ChatBots/TestBot.cs @@ -19,11 +19,11 @@ namespace MinecraftClient.ChatBots if (IsPrivateMessage(text, ref message, ref username)) { - LogToConsole("Bot: " + username + " told me : " + message); + LogToConsoleTranslated("bot.testBot.told", username, message); } else if (IsChatMessage(text, ref message, ref username)) { - LogToConsole("Bot: " + username + " said : " + message); + LogToConsoleTranslated("bot.testBot.said", username, message); } } } diff --git a/MinecraftClient/Command.cs b/MinecraftClient/Command.cs index 0049f602..7f03e748 100644 --- a/MinecraftClient/Command.cs +++ b/MinecraftClient/Command.cs @@ -16,12 +16,27 @@ namespace MinecraftClient /// /// The command name /// - public abstract string CMDName { get; } + public abstract string CmdName { get; } /// - /// Usage message, eg: 'name [args]: do something' + /// Command description with translation support. Please add your message in Translations.cs file and return mapping key in this property /// - public abstract string CMDDesc { get; } + public abstract string CmdDesc { get; } + + /// + /// Get the translated version of command description. + /// + /// Translated command description + public string GetCmdDescTranslated() + { + string s = string.IsNullOrEmpty(CmdUsage) || string.IsNullOrEmpty(CmdDesc) ? "" : ": "; // If either one is empty, no colon : + return CmdUsage + s + Translations.TryGet(CmdDesc); + } + + /// + /// Usage message, eg: 'name [args]' + /// + public abstract string CmdUsage { get; } /// /// Perform the command diff --git a/MinecraftClient/Commands/Animation.cs b/MinecraftClient/Commands/Animation.cs index 50a8286d..463958f1 100644 --- a/MinecraftClient/Commands/Animation.cs +++ b/MinecraftClient/Commands/Animation.cs @@ -7,8 +7,9 @@ namespace MinecraftClient.Commands { public class Animation : Command { - public override string CMDName { get { return "animation"; } } - public override string CMDDesc { get { return "animation "; } } + public override string CmdName { get { return "animation"; } } + public override string CmdUsage { get { return "animation "; } } + public override string CmdDesc { get { return "cmd.animation.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { @@ -20,24 +21,24 @@ namespace MinecraftClient.Commands if (args[0] == "mainhand" || args[0] == "0") { handler.DoAnimation(0); - return "Done"; + return Translations.Get("general.done"); } else if (args[0] == "offhand" || args[0] == "1") { handler.DoAnimation(1); - return "Done"; + return Translations.Get("general.done"); } else { - return CMDDesc; + return GetCmdDescTranslated(); } } else { - return CMDDesc; + return GetCmdDescTranslated(); } } - else return CMDDesc; + else return GetCmdDescTranslated(); } } } diff --git a/MinecraftClient/Commands/ChangeSlot.cs b/MinecraftClient/Commands/ChangeSlot.cs index a1419a4b..814d75e9 100644 --- a/MinecraftClient/Commands/ChangeSlot.cs +++ b/MinecraftClient/Commands/ChangeSlot.cs @@ -7,13 +7,14 @@ namespace MinecraftClient.Commands { class ChangeSlot : Command { - public override string CMDName { get { return "changeslot"; } } - public override string CMDDesc { get { return "changeslot <1-9>: Change hotbar"; } } + public override string CmdName { get { return "changeslot"; } } + public override string CmdUsage { get { return "changeslot <1-9>"; } } + public override string CmdDesc { get { return "cmd.changeSlot.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { if (!handler.GetInventoryEnabled()) - return "Please enable InventoryHandling in the config file first."; + return Translations.Get("extra.inventory_required"); if (hasArg(command)) { @@ -24,21 +25,21 @@ namespace MinecraftClient.Commands } catch (FormatException) { - return "Could not change slot: Not a Number"; + return Translations.Get("cmd.changeSlot.nan"); } if (slot >= 1 && slot <= 9) { if (handler.ChangeSlot(slot-=1)) { - return "Changed to slot " + (slot+=1); + return Translations.Get("cmd.changeSlot.changed", (slot+=1)); } else { - return "Could not change slot"; + return Translations.Get("cmd.changeSlot.fail"); } } } - return CMDDesc; + return GetCmdDescTranslated(); } } } diff --git a/MinecraftClient/Commands/Connect.cs b/MinecraftClient/Commands/Connect.cs index 21fdd045..f8fac928 100644 --- a/MinecraftClient/Commands/Connect.cs +++ b/MinecraftClient/Commands/Connect.cs @@ -7,8 +7,9 @@ namespace MinecraftClient.Commands { public class Connect : Command { - public override string CMDName { get { return "connect"; } } - public override string CMDDesc { get { return "connect [account]: connect to the specified server."; } } + public override string CmdName { get { return "connect"; } } + public override string CmdUsage { get { return "connect [account]"; } } + public override string CmdDesc { get { return "cmd.connect.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { @@ -19,7 +20,7 @@ namespace MinecraftClient.Commands { if (!Settings.SetAccount(args[1])) { - return "Unknown account '" + args[1] + "'."; + return Translations.Get("cmd.connect.unknown", args[1]); } } @@ -28,9 +29,9 @@ namespace MinecraftClient.Commands Program.Restart(); return ""; } - else return "Invalid server IP '" + args[0] + "'."; + else return Translations.Get("cmd.connect.invalid_ip", args[0]); } - else return CMDDesc; + else return GetCmdDescTranslated(); } } } diff --git a/MinecraftClient/Commands/Debug.cs b/MinecraftClient/Commands/Debug.cs index 15086687..11c122fc 100644 --- a/MinecraftClient/Commands/Debug.cs +++ b/MinecraftClient/Commands/Debug.cs @@ -7,8 +7,9 @@ namespace MinecraftClient.Commands { public class Debug : Command { - public override string CMDName { get { return "debug"; } } - public override string CMDDesc { get { return "debug [on|off]: toggle debug messages."; } } + public override string CmdName { get { return "debug"; } } + public override string CmdUsage { get { return "debug [on|off]"; } } + public override string CmdDesc { get { return "cmd.debug.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { @@ -17,7 +18,7 @@ namespace MinecraftClient.Commands Settings.DebugMessages = (getArg(command).ToLower() == "on"); } else Settings.DebugMessages = !Settings.DebugMessages; - return "Debug messages are now " + (Settings.DebugMessages ? "ON" : "OFF"); + return Translations.Get(Settings.DebugMessages ? "cmd.debug.state_on" : "cmd.debug.state_off"); } } } diff --git a/MinecraftClient/Commands/Dig.cs b/MinecraftClient/Commands/Dig.cs index f7d445a6..fc5214fb 100644 --- a/MinecraftClient/Commands/Dig.cs +++ b/MinecraftClient/Commands/Dig.cs @@ -8,13 +8,14 @@ namespace MinecraftClient.Commands { public class Dig : Command { - public override string CMDName { get { return "dig"; } } - public override string CMDDesc { get { return "dig : attempt to break a block"; } } + public override string CmdName { get { return "dig"; } } + public override string CmdUsage { get { return "dig "; } } + public override string CmdDesc { get { return "cmd.dig.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { if (!handler.GetTerrainEnabled()) - return "Please enable Terrain and Movements to use this command."; + return Translations.Get("extra.terrainandmovement_required"); if (hasArg(command)) { @@ -28,18 +29,18 @@ namespace MinecraftClient.Commands int z = int.Parse(args[2]); Location blockToBreak = new Location(x, y, z); if (blockToBreak.DistanceSquared(handler.GetCurrentLocation().EyesLocation()) > 25) - return "You are too far away from this block."; + return Translations.Get("cmd.dig.too_far"); if (handler.GetWorld().GetBlock(blockToBreak).Type == Material.Air) - return "No block at this location (Air)"; + return Translations.Get("cmd.dig.no_block"); if (handler.DigBlock(blockToBreak)) - return String.Format("Attempting to dig block at {0} {1} {2}", x, y, z); - else return "Failed to start digging block."; + return Translations.Get("cmd.dig.dig", x, y, z); + else return "cmd.dig.fail"; } - catch (FormatException) { return CMDDesc; } + catch (FormatException) { return GetCmdDescTranslated(); } } - else return CMDDesc; + else return GetCmdDescTranslated(); } - else return CMDDesc; + else return GetCmdDescTranslated(); } } } diff --git a/MinecraftClient/Commands/Entitycmd.cs b/MinecraftClient/Commands/Entitycmd.cs index a757a15e..304318bb 100644 --- a/MinecraftClient/Commands/Entitycmd.cs +++ b/MinecraftClient/Commands/Entitycmd.cs @@ -8,8 +8,9 @@ namespace MinecraftClient.Commands { class Entitycmd : Command { - public override string CMDName { get { return "entity"; } } - public override string CMDDesc { get { return "entity "; } } + public override string CmdName { get { return "entity"; } } + public override string CmdUsage { get { return "entity "; } } + public override string CmdDesc { get { return ""; } } public override string Run(McClient handler, string command, Dictionary localVars) { @@ -33,10 +34,10 @@ namespace MinecraftClient.Commands { case "attack": handler.InteractEntity(entityID, 1); - return "Entity attacked"; + return Translations.Get("cmd.entityCmd.attacked"); case "use": handler.InteractEntity(entityID, 0); - return "Entity used"; + return Translations.Get("cmd.entityCmd.used"); default: Entity entity = handler.GetEntities()[entityID]; int id = entity.ID; @@ -56,52 +57,52 @@ namespace MinecraftClient.Commands color = "§e"; // Yellow string location = String.Format("X:{0}, Y:{1}, Z:{2}", Math.Round(entity.Location.X, 2), Math.Round(entity.Location.Y, 2), Math.Round(entity.Location.Y, 2)); - string done = String.Format("Entity: {0}\n [MCC] Type: {1}", id, type); + string done = Translations.Replace("([cmd.entityCmd.entity]): {0}\n [MCC] Type: {1}", id, type); if (!String.IsNullOrEmpty(nickname)) - done += String.Format("\n [MCC] Nickname: {0}", nickname); + done += Translations.Replace("\n [MCC] ([cmd.entityCmd.nickname]): {0}", nickname); else if (!String.IsNullOrEmpty(customname)) - done += String.Format("\n [MCC] CustomName: {0}§8", customname.Replace("&", "§")); + done += Translations.Replace("\n [MCC] ([cmd.entityCmd.customname]): {0}§8", customname.Replace("&", "§")); if (type == EntityType.Player) - done += String.Format("\n [MCC] Latency: {0}", latency); + done += Translations.Replace("\n [MCC] ([cmd.entityCmd.latency]): {0}", latency); else if (type == EntityType.Item || type == EntityType.ItemFrame || type == Mapping.EntityType.EyeOfEnder || type == Mapping.EntityType.Egg || type == Mapping.EntityType.EnderPearl || type == Mapping.EntityType.Potion || type == Mapping.EntityType.Fireball || type == Mapping.EntityType.FireworkRocket) { string displayName = item.DisplayName; if (String.IsNullOrEmpty(displayName)) - done += String.Format("\n [MCC] Item: {0} x{1}", item.Type, item.Count); + done += Translations.Replace("\n [MCC] ([cmd.entityCmd.item]): {0} x{1}", item.Type, item.Count); else - done += String.Format("\n [MCC] Item: {0} x{1} - {2}§8", item.Type, item.Count, displayName); + done += Translations.Replace("\n [MCC] ([cmd.entityCmd.item]): {0} x{1} - {2}§8", item.Type, item.Count, displayName); } if (entity.Equipment.Count >= 1 && entity.Equipment != null) { - done += String.Format("\n [MCC] Equipment:"); + done += Translations.Replace("\n [MCC] ([cmd.entityCmd.equipment]):"); if (entity.Equipment.ContainsKey(0) && entity.Equipment[0] != null) - done += String.Format("\n [MCC] MainHand: {0} x{1}", entity.Equipment[0].Type, entity.Equipment[0].Count); + done += Translations.Replace("\n [MCC] ([cmd.entityCmd.mainhand]): {0} x{1}", entity.Equipment[0].Type, entity.Equipment[0].Count); if (entity.Equipment.ContainsKey(1) && entity.Equipment[1] != null) - done += String.Format("\n [MCC] OffHand: {0} x{1}", entity.Equipment[1].Type, entity.Equipment[1].Count); + done += Translations.Replace("\n [MCC] ([cmd.entityCmd.offhand]): {0} x{1}", entity.Equipment[1].Type, entity.Equipment[1].Count); if (entity.Equipment.ContainsKey(5) && entity.Equipment[5] != null) - done += String.Format("\n [MCC] Helmet: {0} x{1}", entity.Equipment[5].Type, entity.Equipment[5].Count); + done += Translations.Replace("\n [MCC] ([cmd.entityCmd.helmet]): {0} x{1}", entity.Equipment[5].Type, entity.Equipment[5].Count); if (entity.Equipment.ContainsKey(4) && entity.Equipment[4] != null) - done += String.Format("\n [MCC] Chestplate: {0} x{1}", entity.Equipment[4].Type, entity.Equipment[4].Count); + done += Translations.Replace("\n [MCC] ([cmd.entityCmd.chestplate]): {0} x{1}", entity.Equipment[4].Type, entity.Equipment[4].Count); if (entity.Equipment.ContainsKey(3) && entity.Equipment[3] != null) - done += String.Format("\n [MCC] Leggings: {0} x{1}", entity.Equipment[3].Type, entity.Equipment[3].Count); + done += Translations.Replace("\n [MCC] ([cmd.entityCmd.leggings]): {0} x{1}", entity.Equipment[3].Type, entity.Equipment[3].Count); if (entity.Equipment.ContainsKey(2) && entity.Equipment[2] != null) - done += String.Format("\n [MCC] Boots: {0} x{1}", entity.Equipment[2].Type, entity.Equipment[2].Count); + done += Translations.Replace("\n [MCC] ([cmd.entityCmd.boots]): {0} x{1}", entity.Equipment[2].Type, entity.Equipment[2].Count); } - done += String.Format("\n [MCC] Pose: {0}", pose); - done += String.Format("\n [MCC] Health: {0}", color + health + "§8"); - done += String.Format("\n [MCC] Distance: {0}", distance); - done += String.Format("\n [MCC] Location: {0}", location); + done += Translations.Replace("\n [MCC] ([cmd.entityCmd.pose]): {0}", pose); + done += Translations.Replace("\n [MCC] ([cmd.entityCmd.health]): {0}", color + health + "§8"); + done += Translations.Replace("\n [MCC] ([cmd.entityCmd.distance]): {0}", distance); + done += Translations.Replace("\n [MCC] ([cmd.entityCmd.location]): {0}", location); return done; } } - else return "Entity not found"; + else return Translations.Get("cmd.entityCmd.not_found"); } else { EntityType interacttype = EntityType.Player; Enum.TryParse(args[0], out interacttype); - string actionst = "Entity attacked"; + string actionst = "cmd.entityCmd.attacked"; int actioncount = 0; foreach (var entity2 in handler.GetEntities()) { @@ -113,28 +114,28 @@ namespace MinecraftClient.Commands if (action == "attack") { handler.InteractEntity(entity2.Key, 1); - actionst = "Entity attacked"; + actionst = "cmd.entityCmd.attacked"; actioncount++; } else if (action == "use") { handler.InteractEntity(entity2.Key, 0); - actionst = "Entity used"; + actionst = "cmd.entityCmd.used"; actioncount++; } - else return CMDDesc; + else return GetCmdDescTranslated(); } } - return actioncount + " " + actionst; + return actioncount + " " + Translations.Get(actionst); } } - catch (FormatException) { return CMDDesc; } + catch (FormatException) { return GetCmdDescTranslated(); } } else { - Dictionary entities = handler.GetEntities(); + Dictionary entities = handler.GetEntities(); List response = new List(); - response.Add("Entities:"); + response.Add(Translations.Get("cmd.entityCmd.entities")); foreach (var entity2 in entities) { int id = entity2.Key; @@ -147,20 +148,20 @@ namespace MinecraftClient.Commands Item item = entity2.Value.Item; string location = String.Format("X:{0}, Y:{1}, Z:{2}", Math.Round(entity2.Value.Location.X, 2), Math.Round(entity2.Value.Location.Y, 2), Math.Round(entity2.Value.Location.Y, 2)); - if (type == EntityType.Item || type == EntityType.ItemFrame || type == Mapping.EntityType.EyeOfEnder || type == Mapping.EntityType.Egg || type == Mapping.EntityType.EnderPearl || type == Mapping.EntityType.Potion || type == Mapping.EntityType.Fireball || type == Mapping.EntityType.FireworkRocket) - response.Add(String.Format(" #{0}: Type: {1}, Item: {2}, Location: {3}", id, type, item.Type, location)); - else if (type == Mapping.EntityType.Player && !String.IsNullOrEmpty(nickname)) - response.Add(String.Format(" #{0}: Type: {1}, Nickname: §8{2}§8, Latency: {3}, Health: {4}, Pose: {5}, Location: {6}", id, type, nickname, latency, health, pose, location)); - else if (type == Mapping.EntityType.Player && !String.IsNullOrEmpty(customname)) - response.Add(String.Format(" #{0}: Type: {1}, CustomName: §8{2}§8, Latency: {3}, Health: {4}, Pose: {5}, Location: {6}", id, type, customname.Replace("&", "§"), latency, health, pose, location)); + if (type == EntityType.Item || type == EntityType.ItemFrame || type == EntityType.EyeOfEnder || type == EntityType.Egg || type == EntityType.EnderPearl || type == EntityType.Potion || type == EntityType.Fireball || type == EntityType.FireworkRocket) + response.Add(Translations.Replace(" #{0}: ([cmd.entityCmd.type]): {1}, ([cmd.entityCmd.item]): {2}, ([cmd.entityCmd.location]): {3}", id, type, item.Type, location)); + else if (type == EntityType.Player && !String.IsNullOrEmpty(nickname)) + response.Add(Translations.Replace(" #{0}: ([cmd.entityCmd.type]): {1}, ([cmd.entityCmd.nickname]): §8{2}§8, ([cmd.entityCmd.latency]): {3}, ([cmd.entityCmd.health]): {4}, ([cmd.entityCmd.pose]): {5}, ([cmd.entityCmd.location]): {6}", id, type, nickname, latency, health, pose, location)); + else if (type == EntityType.Player && !String.IsNullOrEmpty(customname)) + response.Add(Translations.Replace(" #{0}: ([cmd.entityCmd.type]): {1}, ([cmd.entityCmd.customname]): §8{2}§8, ([cmd.entityCmd.latency]): {3}, ([cmd.entityCmd.health]): {4}, ([cmd.entityCmd.pose]): {5}, ([cmd.entityCmd.location]): {6}", id, type, customname.Replace("&", "§"), latency, health, pose, location)); else - response.Add(String.Format(" #{0}: Type: {1}, Health: {2}, Location: {3}", id, type, health, location)); + response.Add(Translations.Replace(" #{0}: ([cmd.entityCmd.type]): {1}, ([cmd.entityCmd.health]): {2}, ([cmd.entityCmd.location]): {3}", id, type, health, location)); } - response.Add(CMDDesc); + response.Add(GetCmdDescTranslated()); return String.Join("\n", response); } } - else return "Please enable entityhandling in config to use this command."; + else return Translations.Get("extra.entity_required"); } } } diff --git a/MinecraftClient/Commands/Exit.cs b/MinecraftClient/Commands/Exit.cs index 7afc373b..8a442786 100644 --- a/MinecraftClient/Commands/Exit.cs +++ b/MinecraftClient/Commands/Exit.cs @@ -7,8 +7,9 @@ namespace MinecraftClient.Commands { public class Exit : Command { - public override string CMDName { get { return "exit"; } } - public override string CMDDesc { get { return "exit: disconnect from the server."; } } + public override string CmdName { get { return "exit"; } } + public override string CmdUsage { get { return "exit"; } } + public override string CmdDesc { get { return "cmd.exit.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { diff --git a/MinecraftClient/Commands/Health.cs b/MinecraftClient/Commands/Health.cs index 3711e277..95e084c1 100644 --- a/MinecraftClient/Commands/Health.cs +++ b/MinecraftClient/Commands/Health.cs @@ -7,12 +7,13 @@ namespace MinecraftClient.Commands { class Health : Command { - public override string CMDName { get { return "health"; } } - public override string CMDDesc { get { return "health: Display Health and Food saturation."; } } + public override string CmdName { get { return "health"; } } + public override string CmdUsage { get { return "health"; } } + public override string CmdDesc { get { return "cmd.health.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { - return "Health: " + handler.GetHealth() + ", Saturation: " + handler.GetSaturation() + ", Level: " + handler.GetLevel() + ", TotalExperience: " + handler.GetTotalExperience(); + return Translations.Get("cmd.health.response", handler.GetHealth(), handler.GetSaturation(), handler.GetLevel(), handler.GetTotalExperience()); } } } diff --git a/MinecraftClient/Commands/Inventory.cs b/MinecraftClient/Commands/Inventory.cs index ebbd6626..b44b3352 100644 --- a/MinecraftClient/Commands/Inventory.cs +++ b/MinecraftClient/Commands/Inventory.cs @@ -7,8 +7,9 @@ namespace MinecraftClient.Commands { class Inventory : Command { - public override string CMDName { get { return "inventory"; } } - public override string CMDDesc { get { return GetCommandDesc(); } } + public override string CmdName { get { return "inventory"; } } + public override string CmdUsage { get { return GetBasicUsage(); } } + public override string CmdDesc { get { return "cmd.inventory.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { @@ -32,17 +33,17 @@ namespace MinecraftClient.Commands { int count = int.Parse(args[3]); if (handler.DoCreativeGive(slot, itemType, count, null)) - return "Requested " + itemType + " x" + count + " in slot #" + slot; - else return "Failed to request Creative Give"; + return Translations.Get("cmd.inventory.creative_done", itemType, count, slot); + else return Translations.Get("cmd.inventory.creative_fail"); } - else return "You need Gamemode Creative"; + else return Translations.Get("cmd.inventory.need_creative"); } else { - return CMDDesc; + return GetCmdDescTranslated(); } } - else return CMDDesc; + else return GetCmdDescTranslated(); } else if (args[0].ToLower().StartsWith("p")) { @@ -55,7 +56,7 @@ namespace MinecraftClient.Commands availableIds.Remove(0); // remove player inventory ID from list if (availableIds.Count == 1) inventoryId = availableIds[0]; // one container, use it - else return "Cannot find container, please retry with explicit ID"; + else return Translations.Get("cmd.inventory.container_not_found"); } else if (args[0].ToLower() == "help") { @@ -73,65 +74,65 @@ namespace MinecraftClient.Commands { case "close": if (handler.CloseInventory(inventoryId)) - return "Closing Inventoy #" + inventoryId; - else return "Failed to close Inventory #" + inventoryId; + return Translations.Get("cmd.inventory.close", inventoryId); + else return Translations.Get("cmd.inventory.close_fail", inventoryId); case "list": Container inventory = handler.GetInventory(inventoryId); if(inventory==null) - return "Inventory #" + inventoryId + " do not exist"; + return Translations.Get("cmd.inventory.not_exist", inventoryId); List response = new List(); - response.Add("Inventory #" + inventoryId + " - " + inventory.Title + "§8"); + response.Add(Translations.Get("cmd.inventory.inventory") + " #" + inventoryId + " - " + inventory.Title + "§8"); foreach (KeyValuePair item in inventory.Items) { string displayName = item.Value.DisplayName; if (String.IsNullOrEmpty(displayName)) { if (item.Value.Damage != 0) - response.Add(String.Format(" #{0}: {1} x{2} | Damage: {3}", item.Key, item.Value.Type, item.Value.Count, item.Value.Damage)); + response.Add(String.Format(" #{0}: {1} x{2} | {3}: {4}", item.Key, item.Value.Type, item.Value.Count, Translations.Get("cmd.inventory.damage"), item.Value.Damage)); else response.Add(String.Format(" #{0}: {1} x{2}", item.Key, item.Value.Type, item.Value.Count)); } else { if (item.Value.Damage != 0) - response.Add(String.Format(" #{0}: {1} x{2} - {3}§8 | Damage: {4}", item.Key, item.Value.Type, item.Value.Count, displayName, item.Value.Damage)); + response.Add(String.Format(" #{0}: {1} x{2} - {3}§8 | {4}: {5}", item.Key, item.Value.Type, item.Value.Count, displayName, Translations.Get("cmd.inventory.damage"), item.Value.Damage)); else response.Add(String.Format(" #{0}: {1} x{2} - {3}§8", item.Key, item.Value.Type, item.Value.Count, displayName)); } } - if (inventoryId == 0) response.Add("Your selected hotbar is " + (handler.GetCurrentSlot() + 1)); + if (inventoryId == 0) response.Add(Translations.Get("cmd.inventory.hotbar", (handler.GetCurrentSlot() + 1))); return String.Join("\n", response.ToArray()); case "click": if (args.Length >= 3) { int slot = int.Parse(args[2]); WindowActionType actionType = WindowActionType.LeftClick; - string keyName = "Left"; + string keyName = "cmd.inventory.left"; if (args.Length >= 4) { string b = args[3]; if (b.ToLower()[0] == 'r') { actionType = WindowActionType.RightClick; - keyName = "Right"; + keyName = "cmd.inventory.right"; } if (b.ToLower()[0] == 'm') { actionType = WindowActionType.MiddleClick; - keyName = "Middle"; + keyName = "cmd.inventory.middle"; } } handler.DoWindowAction(inventoryId, slot, actionType); - return keyName + " clicking slot " + slot + " in window #" + inventoryId; + return Translations.Get("cmd.inventory.clicking", Translations.Get(keyName), slot, inventoryId); } - else return CMDDesc; + else return CmdUsage; case "drop": if (args.Length >= 3) { int slot = int.Parse(args[2]); // check item exist if (!handler.GetInventory(inventoryId).Items.ContainsKey(slot)) - return "No item in slot #" + slot; + return Translations.Get("cmd.inventory.no_item", slot); WindowActionType actionType = WindowActionType.DropItem; if (args.Length >= 4) { @@ -143,35 +144,35 @@ namespace MinecraftClient.Commands if (handler.DoWindowAction(inventoryId, slot, actionType)) { if (actionType == WindowActionType.DropItemStack) - return "Dropped whole item stack from slot #" + slot; - else return "Dropped 1 item from slot #" + slot; + return Translations.Get("cmd.inventory.drop_stack", slot); + else return Translations.Get("cmd.inventory.drop", slot); } else { return "Failed"; } } - else return CMDDesc; + else return GetCmdDescTranslated(); default: - return CMDDesc; + return GetCmdDescTranslated(); } } - catch (FormatException) { return CMDDesc; } + catch (FormatException) { return GetCmdDescTranslated(); } } else { Dictionary inventories = handler.GetInventories(); List response = new List(); - response.Add("Inventories:"); + response.Add(Translations.Get("cmd.inventory.inventories") + ":"); foreach (KeyValuePair inventory in inventories) { response.Add(String.Format(" #{0}: {1}", inventory.Key, inventory.Value.Title + "§8")); } - response.Add(CMDDesc); + response.Add(CmdUsage); return String.Join("\n", response); } } - else return "Please enable inventoryhandling in config to use this command."; + else return Translations.Get("extra.inventory_required"); } #region Methods for commands help @@ -182,26 +183,22 @@ namespace MinecraftClient.Commands private string GetAvailableActions() { - return "Available actions: list, close, click, drop."; + return Translations.Get("cmd.inventory.help.available") + ": list, close, click, drop."; } private string GetBasicUsage() { - return "Basic usage: /inventory > ."; + return Translations.Get("cmd.inventory.help.basic") + ": /inventory > ."; } private string GetHelp() { - return GetBasicUsage() - + "\n " + GetAvailableActions() + " Use \"/inventory help \" for action help." - + "\n Creative mode give: " + GetCreativeGiveHelp() - + "\n \"player\" and \"container\" can be simplified to \"p\" and \"c\"." - + "\n Note that parameters in \"[]\" are optional."; + return Translations.Get("cmd.inventory.help.help", GetAvailableActions(), GetCreativeGiveHelp()); } private string GetCreativeGiveHelp() { - return "Usage: /inventory creativegive "; + return Translations.Get("cmd.inventory.help.usage") + ": /inventory creativegive "; } private string GetSubCommandHelp(string cmd) @@ -209,17 +206,17 @@ namespace MinecraftClient.Commands switch (cmd) { case "list": - return "List your inventory. Usage: /inventory > list"; + return Translations.Get("cmd.inventory.help.list") + Translations.Get("cmd.inventory.help.usage") + ": /inventory > list"; case "close": - return "Close an opened container. Usage: /inventory > close"; + return Translations.Get("cmd.inventory.help.close") + Translations.Get("cmd.inventory.help.usage") + ": /inventory > close"; case "click": - return "Click on an item. Usage: /inventory > click [left|right|middle]. \nDefault is left click"; + return Translations.Get("cmd.inventory.help.click") + Translations.Get("cmd.inventory.help.usage") + ": /inventory > click [left|right|middle]. \nDefault is left click"; case "drop": - return "Drop an item from inventory. Usage: /inventory > drop [all]. \nAll means drop full stack"; + return Translations.Get("cmd.inventory.help.drop") + Translations.Get("cmd.inventory.help.usage") + ": /inventory > drop [all]. \nAll means drop full stack"; case "help": return GetHelp(); default: - return "Unknown action. " + GetAvailableActions(); + return Translations.Get("cmd.inventory.help.unknown") + GetAvailableActions(); } } #endregion diff --git a/MinecraftClient/Commands/List.cs b/MinecraftClient/Commands/List.cs index e4e488fe..7cc4575c 100644 --- a/MinecraftClient/Commands/List.cs +++ b/MinecraftClient/Commands/List.cs @@ -7,12 +7,13 @@ namespace MinecraftClient.Commands { public class List : Command { - public override string CMDName { get { return "list"; } } - public override string CMDDesc { get { return "list: get the player list."; } } + public override string CmdName { get { return "list"; } } + public override string CmdUsage { get { return "list"; } } + public override string CmdDesc { get { return "cmd.list.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { - return "PlayerList: " + String.Join(", ", handler.GetOnlinePlayers()); + return Translations.Get("cmd.list.players", String.Join(", ", handler.GetOnlinePlayers())); } } } diff --git a/MinecraftClient/Commands/Log.cs b/MinecraftClient/Commands/Log.cs index dcc39a97..9c0daf1e 100644 --- a/MinecraftClient/Commands/Log.cs +++ b/MinecraftClient/Commands/Log.cs @@ -7,8 +7,9 @@ namespace MinecraftClient.Commands { public class Log : Command { - public override string CMDName { get { return "log"; } } - public override string CMDDesc { get { return "log : log some text to the console."; } } + public override string CmdName { get { return "log"; } } + public override string CmdUsage { get { return "log "; } } + public override string CmdDesc { get { return "cmd.log.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { @@ -17,7 +18,7 @@ namespace MinecraftClient.Commands ConsoleIO.WriteLogLine(getArg(command)); return ""; } - else return CMDDesc; + else return GetCmdDescTranslated(); } } } diff --git a/MinecraftClient/Commands/Look.cs b/MinecraftClient/Commands/Look.cs index 30173db5..d27c09f5 100644 --- a/MinecraftClient/Commands/Look.cs +++ b/MinecraftClient/Commands/Look.cs @@ -8,8 +8,9 @@ namespace MinecraftClient.Commands { public class Look : Command { - public override string CMDName { get { return "look"; } } - public override string CMDDesc { get { return "look : look at direction or coordinates."; } } + public override string CmdName { get { return "look"; } } + public override string CmdUsage { get { return "look "; } } + public override string CmdDesc { get { return "cmd.look.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { @@ -28,7 +29,7 @@ namespace MinecraftClient.Commands case "west": direction = Direction.West; break; case "north": direction = Direction.North; break; case "south": direction = Direction.South; break; - default: return "Unknown direction '" + dirStr + "'."; + default: return Translations.Get("cmd.look.unknown", dirStr); } handler.UpdateLocation(handler.GetCurrentLocation(), direction); @@ -42,9 +43,9 @@ namespace MinecraftClient.Commands float pitch = Single.Parse(args[1]); handler.UpdateLocation(handler.GetCurrentLocation(), yaw, pitch); - return String.Format("Looking at YAW: {0} PITCH: {1}", yaw.ToString("0.00"), pitch.ToString("0.00")); + return Translations.Get("cmd.look.at", yaw.ToString("0.00"), pitch.ToString("0.00")); } - catch (FormatException) { return CMDDesc; } + catch (FormatException) { return GetCmdDescTranslated(); } } else if (args.Length == 3) { @@ -57,14 +58,14 @@ namespace MinecraftClient.Commands Location block = new Location(x, y, z); handler.UpdateLocation(handler.GetCurrentLocation(), block); - return "Looking at " + block; + return Translations.Get("cmd.look.block", block); } - catch (FormatException) { return CMDDesc; } + catch (FormatException) { return CmdUsage; } } - else return CMDDesc; + else return GetCmdDescTranslated(); } - else return "Please enable terrainandmovements in config to use this command."; + else return Translations.Get("extra.terrainandmovement_required"); } } } diff --git a/MinecraftClient/Commands/Move.cs b/MinecraftClient/Commands/Move.cs index 31010123..8b375d4b 100644 --- a/MinecraftClient/Commands/Move.cs +++ b/MinecraftClient/Commands/Move.cs @@ -8,8 +8,9 @@ namespace MinecraftClient.Commands { public class Move : Command { - public override string CMDName { get { return "move"; } } - public override string CMDDesc { get { return "move : walk or start walking."; } } + public override string CmdName { get { return "move"; } } + public override string CmdUsage { get { return "move "; } } + public override string CmdDesc { get { return "walk or start walking."; } } public override string Run(McClient handler, string command, Dictionary localVars) { @@ -19,12 +20,12 @@ namespace MinecraftClient.Commands if (argStr == "on") { handler.SetTerrainEnabled(true); - return "Enabling Terrain and Movements on next server login, respawn or world change."; + return Translations.Get("cmd.move.enable"); } else if (argStr == "off") { handler.SetTerrainEnabled(false); - return "Disabling Terrain and Movements."; + return Translations.Get("cmd.move.disable"); } else if (handler.GetTerrainEnabled()) { @@ -40,14 +41,14 @@ namespace MinecraftClient.Commands case "north": direction = Direction.North; break; case "south": direction = Direction.South; break; case "get": return handler.GetCurrentLocation().ToString(); - default: return "Unknown direction '" + argStr + "'."; + default: return Translations.Get("cmd.look.unknown", argStr); } if (Movement.CanMove(handler.GetWorld(), handler.GetCurrentLocation(), direction)) { handler.MoveTo(Movement.Move(handler.GetCurrentLocation(), direction)); - return "Moving " + argStr + '.'; + return Translations.Get("cmd.move.moving", argStr); } - else return "Cannot move in that direction."; + else return Translations.Get("cmd.move.dir_fail"); } else if (args.Length == 3) { @@ -58,14 +59,14 @@ namespace MinecraftClient.Commands int z = int.Parse(args[2]); Location goal = new Location(x, y, z); if (handler.MoveTo(goal)) - return "Walking to " + goal; - return "Failed to compute path to " + goal; + return Translations.Get("cmd.move.walk", goal); + return Translations.Get("cmd.move.fail", goal); } - catch (FormatException) { return CMDDesc; } + catch (FormatException) { return GetCmdDescTranslated(); } } - else return CMDDesc; + else return GetCmdDescTranslated(); } - else return "Please enable terrainandmovements to use this command."; + else return Translations.Get("extra.terrainandmovement_required"); } } } diff --git a/MinecraftClient/Commands/Reco.cs b/MinecraftClient/Commands/Reco.cs index a5ee220a..4119130c 100644 --- a/MinecraftClient/Commands/Reco.cs +++ b/MinecraftClient/Commands/Reco.cs @@ -7,8 +7,9 @@ namespace MinecraftClient.Commands { public class Reco : Command { - public override string CMDName { get { return "reco"; } } - public override string CMDDesc { get { return "reco [account]: restart and reconnect to the server."; } } + public override string CmdName { get { return "reco"; } } + public override string CmdUsage { get { return "reco [account]"; } } + public override string CmdDesc { get { return "cmd.reco.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { @@ -17,7 +18,7 @@ namespace MinecraftClient.Commands { if (!Settings.SetAccount(args[0])) { - return "Unknown account '" + args[0] + "'."; + return Translations.Get("cmd.connect.unknown", args[0]); } } Program.Restart(); diff --git a/MinecraftClient/Commands/Respawn.cs b/MinecraftClient/Commands/Respawn.cs index b490b14d..aece669c 100644 --- a/MinecraftClient/Commands/Respawn.cs +++ b/MinecraftClient/Commands/Respawn.cs @@ -7,13 +7,14 @@ namespace MinecraftClient.Commands { public class Respawn : Command { - public override string CMDName { get { return "respawn"; } } - public override string CMDDesc { get { return "respawn: Use this to respawn if you are dead."; } } + public override string CmdName { get { return "respawn"; } } + public override string CmdUsage { get { return "respawn"; } } + public override string CmdDesc { get { return "cmd.respawn.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { handler.SendRespawnPacket(); - return "You have respawned."; + return Translations.Get("cmd.respawn.done"); } } } diff --git a/MinecraftClient/Commands/Script.cs b/MinecraftClient/Commands/Script.cs index 727c6870..61145398 100644 --- a/MinecraftClient/Commands/Script.cs +++ b/MinecraftClient/Commands/Script.cs @@ -7,8 +7,9 @@ namespace MinecraftClient.Commands { public class Script : Command { - public override string CMDName { get { return "script"; } } - public override string CMDDesc { get { return "script : run a script file."; } } + public override string CmdName { get { return "script"; } } + public override string CmdUsage { get { return "script "; } } + public override string CmdDesc { get { return "cmd.script.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { @@ -17,7 +18,7 @@ namespace MinecraftClient.Commands handler.BotLoad(new ChatBots.Script(getArg(command), null, localVars)); return ""; } - else return CMDDesc; + else return GetCmdDescTranslated(); } } } diff --git a/MinecraftClient/Commands/Send.cs b/MinecraftClient/Commands/Send.cs index 1b78d2d2..945ec94d 100644 --- a/MinecraftClient/Commands/Send.cs +++ b/MinecraftClient/Commands/Send.cs @@ -7,8 +7,9 @@ namespace MinecraftClient.Commands { public class Send : Command { - public override string CMDName { get { return "send"; } } - public override string CMDDesc { get { return "send : send a chat message or command."; } } + public override string CmdName { get { return "send"; } } + public override string CmdUsage { get { return "send "; } } + public override string CmdDesc { get { return "cmd.send.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { @@ -17,7 +18,7 @@ namespace MinecraftClient.Commands handler.SendText(getArg(command)); return ""; } - else return CMDDesc; + else return GetCmdDescTranslated(); } } } diff --git a/MinecraftClient/Commands/Set.cs b/MinecraftClient/Commands/Set.cs index 4861c894..a58541c8 100644 --- a/MinecraftClient/Commands/Set.cs +++ b/MinecraftClient/Commands/Set.cs @@ -7,8 +7,9 @@ namespace MinecraftClient.Commands { public class Set : Command { - public override string CMDName { get { return "set"; } } - public override string CMDDesc { get { return "set varname=value: set a custom %variable%."; } } + public override string CmdName { get { return "set"; } } + public override string CmdUsage { get { return "set varname=value"; } } + public override string CmdDesc { get { return "cmd.set.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { @@ -21,11 +22,11 @@ namespace MinecraftClient.Commands { return ""; //Success } - else return "variable name must be A-Za-z0-9."; + else return Translations.Get("cmd.set.format"); } - else return CMDDesc; + else return GetCmdDescTranslated(); } - else return CMDDesc; + else return GetCmdDescTranslated(); } } } diff --git a/MinecraftClient/Commands/Sneak.cs b/MinecraftClient/Commands/Sneak.cs index c5d71a84..1ba6a94a 100644 --- a/MinecraftClient/Commands/Sneak.cs +++ b/MinecraftClient/Commands/Sneak.cs @@ -8,8 +8,9 @@ namespace MinecraftClient.Commands public class Sneak : Command { private bool sneaking = false; - public override string CMDName { get { return "Sneak"; } } - public override string CMDDesc { get { return "Sneak: Toggles sneaking"; } } + public override string CmdName { get { return "Sneak"; } } + public override string CmdUsage { get { return "Sneak"; } } + public override string CmdDesc { get { return "cmd.sneak.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { @@ -18,14 +19,14 @@ namespace MinecraftClient.Commands var result = handler.SendEntityAction(Protocol.EntityActionType.StopSneaking); if (result) sneaking = false; - return result ? "You aren't sneaking anymore" : "Fail"; + return Translations.Get(result ? "cmd.sneak.off" : "general.fail"); } else { var result = handler.SendEntityAction(Protocol.EntityActionType.StartSneaking); if (result) sneaking = true; - return result ? "You are sneaking now" : "Fail"; + return Translations.Get(result ? "cmd.sneak.on" : "general.fail"); } } diff --git a/MinecraftClient/Commands/Tps.cs b/MinecraftClient/Commands/Tps.cs index 0d70f759..356eb752 100644 --- a/MinecraftClient/Commands/Tps.cs +++ b/MinecraftClient/Commands/Tps.cs @@ -7,8 +7,9 @@ namespace MinecraftClient.Commands { class Tps : Command { - public override string CMDName { get { return "tps"; } } - public override string CMDDesc { get { return "Display server current tps (tick per second). May not be accurate"; } } + public override string CmdName { get { return "tps"; } } + public override string CmdUsage { get { return "tps"; } } + public override string CmdDesc { get { return "cmd.tps.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { @@ -19,7 +20,7 @@ namespace MinecraftClient.Commands else if (tps < 15) color = "§e"; // Yellow else color = "§a"; // Green - return "Current tps: " + color + tps; + return Translations.Get("cmd.tps.current") + ": " + color + tps; } } } diff --git a/MinecraftClient/Commands/UseItem.cs b/MinecraftClient/Commands/UseItem.cs index 1901f8c3..c2ffa966 100644 --- a/MinecraftClient/Commands/UseItem.cs +++ b/MinecraftClient/Commands/UseItem.cs @@ -7,17 +7,18 @@ namespace MinecraftClient.Commands { class UseItem : Command { - public override string CMDName { get { return "useitem"; } } - public override string CMDDesc { get { return "useitem: Use (left click) an item on the hand"; } } + public override string CmdName { get { return "useitem"; } } + public override string CmdUsage { get { return "useitem"; } } + public override string CmdDesc { get { return "cmd.useitem.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { if (handler.GetInventoryEnabled()) { handler.UseItemOnHand(); - return "Used an item"; + return Translations.Get("cmd.useitem.use"); } - else return "Please enable inventoryhandling in config to use this command."; + else return Translations.Get("extra.inventory_required"); } } } diff --git a/MinecraftClient/Commands/Useblock.cs b/MinecraftClient/Commands/Useblock.cs index f9fb2f81..ca56e6d8 100644 --- a/MinecraftClient/Commands/Useblock.cs +++ b/MinecraftClient/Commands/Useblock.cs @@ -8,12 +8,13 @@ namespace MinecraftClient.Commands { class Useblock : Command { - public override string CMDName { get { return "useblock"; } } - public override string CMDDesc { get { return "useblock : use block"; } } + public override string CmdName { get { return "useblock"; } } + public override string CmdUsage { get { return "useblock "; } } + public override string CmdDesc { get { return "cmd.useblock.desc"; } } public override string Run(McClient handler, string command, Dictionary localVars) { - if (!handler.GetTerrainEnabled()) return "Please enable TerrainHandling in the config file first."; + if (!handler.GetTerrainEnabled()) return Translations.Get("extra.terrainandmovement_required"); if (hasArg(command)) { string[] args = getArgs(command); @@ -24,9 +25,9 @@ namespace MinecraftClient.Commands int z = Convert.ToInt32(args[2]); handler.PlaceBlock(new Location(x, y, z), Direction.Down); } - else { return CMDDesc; } + else { return GetCmdDescTranslated(); } } - return CMDDesc; + return GetCmdDescTranslated(); } } } diff --git a/MinecraftClient/DefaultConfigResource.Designer.cs b/MinecraftClient/DefaultConfigResource.Designer.cs new file mode 100644 index 00000000..6befa012 --- /dev/null +++ b/MinecraftClient/DefaultConfigResource.Designer.cs @@ -0,0 +1,111 @@ +//------------------------------------------------------------------------------ +// +// 這段程式碼是由工具產生的。 +// 執行階段版本:4.0.30319.42000 +// +// 對這個檔案所做的變更可能會造成錯誤的行為,而且如果重新產生程式碼, +// 變更將會遺失。 +// +//------------------------------------------------------------------------------ + +namespace MinecraftClient { + using System; + + + /// + /// 用於查詢當地語系化字串等的強類型資源類別。 + /// + // 這個類別是自動產生的,是利用 StronglyTypedResourceBuilder + // 類別透過 ResGen 或 Visual Studio 這類工具。 + // 若要加入或移除成員,請編輯您的 .ResX 檔,然後重新執行 ResGen + // (利用 /str 選項),或重建您的 VS 專案。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class DefaultConfigResource { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal DefaultConfigResource() { + } + + /// + /// 傳回這個類別使用的快取的 ResourceManager 執行個體。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MinecraftClient.DefaultConfigResource", typeof(DefaultConfigResource).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 覆寫目前執行緒的 CurrentUICulture 屬性,對象是所有 + /// 使用這個強類型資源類別的資源查閱。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// 查詢類似 # Minecraft Console Client v1.16.3 + ///# Startup Config File + /// + ///[Main] + /// + ///# General settings + ///# Leave blank to prompt user on startup + ///# Use "-" as password for offline mode + /// + ///login= + ///password= + ///serverip= + /// + ///# Advanced settings + /// + ///language=en_GB + ///consoletitle=%username%@%serverip% - Minecraft Console Client + ///internalcmdchar=slash # Use 'none', 'slash' or 'backslash' + ///splitmessagedelay=2 # Seconds between each part of a long message + ///botowners=Player1,Player2,Player3 # Name list or [字串的其餘部分已遭截斷]"; 的當地語系化字串。 + /// + public static string MinecraftClient { + get { + return ResourceManager.GetString("MinecraftClient", resourceCulture); + } + } + + /// + /// 查詢類似 [mcc] + ///# Messages from MCC itself + ///mcc.description=Console Client for MC {0} to {1} - v{2} - By ORelio & Contributors + ///mcc.keyboard_debug=Keyboard debug mode: Press any key to display info + ///mcc.setting=Loading Settings from {0} + ///mcc.login=Login : + ///mcc.login_basic_io=Please type the username or email of your choice. + ///mcc.password=Password : + ///mcc.password_basic_io=Please type the password for {0}. + ///mcc.password_hidden=Password : {0} + ///mcc.offline=§8You chose to run in offline mode. + ///mcc.session_invalid=§8Cach [字串的其餘部分已遭截斷]"; 的當地語系化字串。 + /// + public static string TranslationEnglish { + get { + return ResourceManager.GetString("TranslationEnglish", resourceCulture); + } + } + } +} diff --git a/MinecraftClient/DefaultConfigResource.resx b/MinecraftClient/DefaultConfigResource.resx new file mode 100644 index 00000000..da58701d --- /dev/null +++ b/MinecraftClient/DefaultConfigResource.resx @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + Resources\config\MinecraftClient.ini;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + + Resources\lang\en.ini;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + \ No newline at end of file diff --git a/MinecraftClient/FileMonitor.cs b/MinecraftClient/FileMonitor.cs index 8cac6c1c..165a519d 100644 --- a/MinecraftClient/FileMonitor.cs +++ b/MinecraftClient/FileMonitor.cs @@ -25,7 +25,7 @@ namespace MinecraftClient if (Settings.DebugMessages) { string callerClass = new System.Diagnostics.StackFrame(1).GetMethod().DeclaringType.Name; - ConsoleIO.WriteLineFormatted(String.Format("§8[{0}] Initializing FileSystemWatcher for file: {1}", callerClass, Path.Combine(folder, filename))); + ConsoleIO.WriteLineFormatted(Translations.Get("filemonitor.init", callerClass, Path.Combine(folder, filename))); } try @@ -43,7 +43,7 @@ namespace MinecraftClient if (Settings.DebugMessages) { string callerClass = new System.Diagnostics.StackFrame(1).GetMethod().DeclaringType.Name; - ConsoleIO.WriteLineFormatted(String.Format("§8[{0}] Failed to initialize FileSystemWatcher, retrying using Polling", callerClass)); + ConsoleIO.WriteLineFormatted(Translations.Get("filemonitor.fail", callerClass)); } monitor = null; diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index 73d2ad59..ec35f08c 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -202,7 +202,7 @@ namespace MinecraftClient client = ProxyHandler.newTcpClient(host, port); client.ReceiveBufferSize = 1024 * 1024; handler = Protocol.ProtocolHandler.GetProtocolHandler(client, protocolversion, forgeInfo, this); - Console.WriteLine("Version is supported.\nLogging in..."); + Translations.WriteLine("mcc.version_supported"); try { @@ -211,7 +211,7 @@ namespace MinecraftClient if (singlecommand) { handler.SendChatMessage(command); - ConsoleIO.WriteLineFormatted("§7Command §8" + command + "§7 sent."); + ConsoleIO.WriteLineFormatted(Translations.Get("mcc.single_cmd", command)); Thread.Sleep(5000); handler.Disconnect(); Thread.Sleep(1000); @@ -222,9 +222,7 @@ namespace MinecraftClient BotLoad(bot, false); botsOnHold.Clear(); - Console.WriteLine("Server was successfully joined.\nType '" - + (Settings.internalCmdChar == ' ' ? "" : "" + Settings.internalCmdChar) - + "quit' to leave the server."); + Translations.WriteLine("mcc.joined", (Settings.internalCmdChar == ' ' ? "" : "" + Settings.internalCmdChar)); cmdprompt = new Thread(new ThreadStart(CommandPrompt)); cmdprompt.Name = "MCC Command prompt"; @@ -237,21 +235,21 @@ namespace MinecraftClient } else { - Console.WriteLine("Failed to login to this server."); + Translations.WriteLine("error.login_failed"); retry = true; } } catch (Exception e) { ConsoleIO.WriteLineFormatted("§8" + e.GetType().Name + ": " + e.Message); - Console.WriteLine("Failed to join this server."); + Translations.WriteLine("error.join"); retry = true; } } catch (SocketException e) { ConsoleIO.WriteLineFormatted("§8" + e.Message); - Console.WriteLine("Failed to connect to this IP."); + Translations.WriteLine("error.connect"); retry = true; } @@ -259,7 +257,7 @@ namespace MinecraftClient { if (ReconnectionAttemptsLeft > 0) { - ConsoleIO.WriteLogLine("Waiting 5 seconds (" + ReconnectionAttemptsLeft + " attempts left)..."); + ConsoleIO.WriteLogLine(Translations.Get("mcc.reconnect", ReconnectionAttemptsLeft)); Thread.Sleep(5000); ReconnectionAttemptsLeft--; Program.Restart(); @@ -340,7 +338,7 @@ namespace MinecraftClient { if (lastKeepAlive.AddSeconds(30) < DateTime.Now) { - OnConnectionLost(ChatBot.DisconnectReason.ConnectionLost, "Connection Timeout"); + OnConnectionLost(ChatBot.DisconnectReason.ConnectionLost, Translations.Get("error.timeout")); return; } } @@ -367,15 +365,15 @@ namespace MinecraftClient string help_cmdname = Command.getArgs(command)[0].ToLower(); if (help_cmdname == "help") { - response_msg = "help : show brief help about a command."; + response_msg = Translations.Get("icmd.help"); } else if (cmds.ContainsKey(help_cmdname)) { - response_msg = cmds[help_cmdname].CMDDesc; + response_msg = cmds[help_cmdname].GetCmdDescTranslated(); } - else response_msg = "Unknown command '" + command_name + "'. Use 'help' for command list."; + else response_msg = Translations.Get("icmd.unknown", command_name); } - else response_msg = "help . Available commands: " + String.Join(", ", cmd_names.ToArray()) + ". For server help, use '" + Settings.internalCmdChar + "send /help' instead."; + else response_msg = Translations.Get("icmd.list", String.Join(", ", cmd_names.ToArray()), Settings.internalCmdChar); } else if (cmds.ContainsKey(command_name)) { @@ -390,7 +388,7 @@ namespace MinecraftClient { if (!(e is ThreadAbortException)) { - ConsoleIO.WriteLogLine("OnInternalCommand: Got error from " + bot.ToString() + ": " + e.ToString()); + ConsoleIO.WriteLogLine(Translations.Get("icmd.error", bot.ToString(), e.ToString())); } else throw; //ThreadAbortException should not be caught } @@ -398,7 +396,7 @@ namespace MinecraftClient } else { - response_msg = "Unknown command '" + command_name + "'. Use '" + (Settings.internalCmdChar == ' ' ? "" : "" + Settings.internalCmdChar) + "help' for help."; + response_msg = Translations.Get("icmd.unknown", command_name); return false; } @@ -419,8 +417,8 @@ namespace MinecraftClient try { Command cmd = (Command)Activator.CreateInstance(type); - cmds[cmd.CMDName.ToLower()] = cmd; - cmd_names.Add(cmd.CMDName.ToLower()); + cmds[cmd.CmdName.ToLower()] = cmd; + cmd_names.Add(cmd.CmdName.ToLower()); foreach (string alias in cmd.getCMDAliases()) cmds[alias.ToLower()] = cmd; } @@ -439,21 +437,7 @@ namespace MinecraftClient /// public void Disconnect() { - foreach (ChatBot bot in bots.ToArray()) - { - try - { - bot.OnDisconnect(ChatBot.DisconnectReason.UserLogout, ""); - } - catch (Exception e) - { - if (!(e is ThreadAbortException)) - { - ConsoleIO.WriteLogLine("OnDisconnect: Got error from " + bot.ToString() + ": " + e.ToString()); - } - else throw; //ThreadAbortException should not be caught - } - } + DispatchBotEvent(bot => bot.OnDisconnect(ChatBot.DisconnectReason.UserLogout, "")); botsOnHold.Clear(); botsOnHold.AddRange(bots); @@ -498,22 +482,22 @@ namespace MinecraftClient switch (reason) { case ChatBot.DisconnectReason.ConnectionLost: - message = "Connection has been lost."; + message = Translations.Get("mcc.disconnect.lost"); ConsoleIO.WriteLine(message); break; case ChatBot.DisconnectReason.InGameKick: - ConsoleIO.WriteLine("Disconnected by Server :"); + Translations.WriteLine("mcc.disconnect.server"); ConsoleIO.WriteLineFormatted(message); break; case ChatBot.DisconnectReason.LoginRejected: - ConsoleIO.WriteLine("Login failed :"); + ConsoleIO.WriteLine("mcc.disconnect.login"); ConsoleIO.WriteLineFormatted(message); break; case ChatBot.DisconnectReason.UserLogout: - throw new InvalidOperationException("User-initiated logout should be done by calling Disconnect()"); + throw new InvalidOperationException(Translations.Get("exception.user_logout")); } foreach (ChatBot bot in bots.ToArray()) @@ -605,7 +589,7 @@ namespace MinecraftClient /// Description/usage of the command /// Method for handling the command /// True if successfully registered - public bool RegisterCommand(string cmdName, string cmdDesc, ChatBot.CommandRunner callback) + public bool RegisterCommand(string cmdName, string cmdDesc, string cmdUsage, ChatBot.CommandRunner callback) { if (cmds.ContainsKey(cmdName.ToLower())) { @@ -613,7 +597,7 @@ namespace MinecraftClient } else { - Command cmd = new ChatBot.ChatBotCommand(cmdName, cmdDesc, callback); + Command cmd = new ChatBot.ChatBotCommand(cmdName, cmdDesc, cmdUsage, callback); cmds.Add(cmdName.ToLower(), cmd); cmd_names.Add(cmdName.ToLower()); return true; @@ -1550,7 +1534,7 @@ namespace MinecraftClient { inventoryHandlingRequested = false; inventoryHandlingEnabled = true; - ConsoleIO.WriteLogLine("Inventory handling is now enabled."); + Translations.WriteLogLine("extra.inventory_enabled"); } ClearInventories(); @@ -1567,7 +1551,7 @@ namespace MinecraftClient { terrainAndMovementsEnabled = true; terrainAndMovementsRequested = false; - ConsoleIO.WriteLogLine("Terrain and Movements is now enabled."); + Translations.WriteLogLine("extra.terrainandmovement_enabled"); } if (terrainAndMovementsEnabled) @@ -1665,7 +1649,7 @@ namespace MinecraftClient case Direction.South: break; default: - throw new ArgumentException("Unknown direction", "direction"); + throw new ArgumentException(Translations.Get("exception.unknown_direction"), "direction"); } UpdateLocation(location, yaw, pitch); @@ -1696,7 +1680,7 @@ namespace MinecraftClient if (Settings.DisplayChatLinks) foreach (string link in links) - ConsoleIO.WriteLogLine("Link: " + link, false); + ConsoleIO.WriteLogLine(Translations.Get("mcc.link", link), false); DispatchBotEvent(bot => bot.GetText(text)); DispatchBotEvent(bot => bot.GetText(text, json)); @@ -1724,8 +1708,8 @@ namespace MinecraftClient if (inventoryID != 0) { - ConsoleIO.WriteLogLine("Inventory # " + inventoryID + " opened: " + inventory.Title); - ConsoleIO.WriteLogLine("Use /inventory to interact with it."); + ConsoleIO.WriteLogLine(Translations.Get("extra.inventory_open", inventoryID, inventory.Title)); + Translations.WriteLogLine("extra.inventory_interact"); DispatchBotEvent(bot => bot.OnInventoryOpen(inventoryID)); } } @@ -1741,7 +1725,7 @@ namespace MinecraftClient if (inventoryID != 0) { - ConsoleIO.WriteLogLine("Inventory # " + inventoryID + " closed."); + ConsoleIO.WriteLogLine(Translations.Get("extra.inventory_close", inventoryID)); DispatchBotEvent(bot => bot.OnInventoryClose(inventoryID)); } } @@ -2073,12 +2057,12 @@ namespace MinecraftClient { if (Settings.AutoRespawn) { - ConsoleIO.WriteLogLine("You are dead. Automatically respawning after 1 second."); + Translations.WriteLogLine("mcc.player_dead_respawn"); respawnTicks = 10; } else { - ConsoleIO.WriteLogLine("You are dead. Type /respawn to respawn."); + Translations.WriteLogLine("mcc.player_dead"); } DispatchBotEvent(bot => bot.OnDeath()); } diff --git a/MinecraftClient/MinecraftClient.csproj b/MinecraftClient/MinecraftClient.csproj index 4a470974..d006fb61 100644 --- a/MinecraftClient/MinecraftClient.csproj +++ b/MinecraftClient/MinecraftClient.csproj @@ -114,6 +114,11 @@ + + True + True + DefaultConfigResource.resx + @@ -208,6 +213,7 @@ + @@ -375,7 +381,16 @@ - + + + PublicResXFileCodeGenerator + DefaultConfigResource.Designer.cs + + + + + +