Add support of language files (#1273)

* Basic support of language file
Only mapped main part of MCC.
* Translations function imporve
* Change translation file naming
* Fix default translation file naming
* Complete translation file mapping for main part
Command and ChatBot not done yet
* Complete translation mapping for commands
Except Entitycmd
* Complete translation mapping for ChatBots
* Add new method for replacing translation key
Just for Entitycmd. Be proud of yourself. We have a convenient method now.
* Complete all translation mapping
* Add default config and translation file to resource
* Remove untranslatable messages from default translation file
This commit is contained in:
ReinforceZwei 2020-10-17 19:41:31 +08:00 committed by GitHub
parent 0c88c18ea0
commit 2017d5d652
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
54 changed files with 1658 additions and 660 deletions

View file

@ -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();
}
}

View file

@ -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 <cmd name> 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 <recipe name>";
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 <command name>";
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);
}
/// <summary>
@ -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);
}
/// <summary>

View file

@ -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 <item name>";
return Translations.Get("cmd.inventory.help.usage") + ": add <item name>";
}
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 <item name>";
return Translations.Get("cmd.inventory.help.usage") + ": remove <item name>";
}
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()

View file

@ -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
/// </summary>
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;
}
}

View file

@ -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;

View file

@ -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();
}
}

View file

@ -156,53 +156,53 @@ namespace MinecraftClient.ChatBots
/// </summary>
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 <getmails|addignored|getignored|removeignored>", ProcessInternalCommand);
}
/// <summary>
@ -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<string> onlinePlayersLowercase = new HashSet<string>(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 + " <username>";
else return Translations.Get("bot.mailer.cmd.ignore.invalid", commandName);
}
}
return "See usage: /help mailer";
return Translations.Get("bot.mailer.cmd.help") + ": /help mailer";
}
}
}

View file

@ -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 <save|stop>", Command);
}
public override void OnNetworkPacket(int packetID, List<byte> 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)
{

View file

@ -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);

View file

@ -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,

View file

@ -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);
}
}
}