Crowdin localization support (#2310)

* Switching to use resource files

* Update Crowdin configuration file

* Code cleanup
This commit is contained in:
BruceChen 2022-10-28 11:13:20 +08:00 committed by GitHub
parent a27491c1b6
commit 077e3a5e9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
193 changed files with 102089 additions and 3564 deletions

View file

@ -31,7 +31,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(Translations.Get("exception.csrunner.invalid_head")));
new InvalidDataException(Translations.exception_csrunner_invalid_head));
//Script hash for determining if it was previously compiled
ulong scriptHash = QuickHash(lines);

View file

@ -51,7 +51,7 @@ namespace MinecraftClient
return master.Handler;
if (_handler != null)
return _handler;
throw new InvalidOperationException(Translations.Get("exception.chatbot.init"));
throw new InvalidOperationException(Translations.exception_chatbot_init);
}
}
@ -843,7 +843,7 @@ namespace MinecraftClient
/// <param name="text">Log text to write</param>
protected void LogToConsole(object? text)
{
string botName = Translations.GetOrNull("botname." + GetType().Name) ?? GetType().Name;
string botName = Translations.ResourceManager.GetString("botname." + GetType().Name) ?? GetType().Name;
if (_handler == null || master == null)
ConsoleIO.WriteLogLine(String.Format("[{0}] {1}", botName, text));
else
@ -864,8 +864,9 @@ namespace MinecraftClient
}
}
protected static void LogToConsole(string botName, object? text)
protected static void LogToConsole(string originBotName, object? text)
{
string botName = Translations.ResourceManager.GetString(originBotName) ?? originBotName;
ConsoleIO.WriteLogLine(String.Format("[{0}] {1}", botName, text));
string logfile = Settings.Config.AppVar.ExpandVars(Config.Main.Advanced.ChatbotLogFile);
@ -900,7 +901,7 @@ namespace MinecraftClient
/// <param name="args"></param>
protected void LogToConsoleTranslated(string key, params object[] args)
{
LogToConsole(Translations.TryGet(key, args));
LogToConsole(string.Format(Translations.ResourceManager.GetString(key) ?? key, args));
}
/// <summary>
@ -910,7 +911,7 @@ namespace MinecraftClient
/// <param name="args"></param>
protected void LogDebugToConsoleTranslated(string key, params object?[] args)
{
LogDebugToConsole(Translations.TryGet(key, args));
LogDebugToConsole(string.Format(Translations.ResourceManager.GetString(key) ?? key, args));
}
/// <summary>
@ -923,8 +924,8 @@ namespace MinecraftClient
{
if (Settings.Config.Logging.DebugMessages)
{
string botName = Translations.GetOrNull("botname." + GetType().Name) ?? GetType().Name;
ConsoleIO.WriteLogLine(Translations.Get("chatbot.reconnect", botName));
string botName = Translations.ResourceManager.GetString("botname." + GetType().Name) ?? GetType().Name;
ConsoleIO.WriteLogLine(string.Format(Translations.chatbot_reconnect, botName));
}
McClient.ReconnectionAttemptsLeft = ExtraAttempts;
Program.Restart(delaySeconds);