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

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