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

@ -219,7 +219,7 @@ namespace MinecraftClient.Protocol
//File not found? Try downloading language file from Mojang's servers?
if (!File.Exists(Language_File))
{
ConsoleIO.WriteLineFormatted(Translations.Get("chat.download", Config.Main.Advanced.Language));
ConsoleIO.WriteLineFormatted(string.Format(Translations.chat_download, Config.Main.Advanced.Language));
HttpClient httpClient = new();
try
{
@ -233,7 +233,7 @@ namespace MinecraftClient.Protocol
string hash = tmp[1].Split('"')[0]; //Translations file identifier on Mojang's servers
string translation_file_location = Settings.TranslationsFile_Website_Download + '/' + hash[..2] + '/' + hash;
if (Settings.Config.Logging.DebugMessages)
ConsoleIO.WriteLineFormatted(Translations.Get("chat.request", translation_file_location));
ConsoleIO.WriteLineFormatted(string.Format(Translations.chat_request, translation_file_location));
Task<string> fetch_file = httpClient.GetStringAsync(translation_file_location);
fetch_file.Wait();
@ -245,11 +245,11 @@ namespace MinecraftClient.Protocol
stringBuilder.Append(entry.Key).Append('=').Append(entry.Value.StringValue.Replace("\n", "\\n").Replace("\r", String.Empty)).Append(Environment.NewLine);
File.WriteAllText(Language_File, stringBuilder.ToString());
ConsoleIO.WriteLineFormatted(Translations.Get("chat.done", Language_File));
ConsoleIO.WriteLineFormatted(string.Format(Translations.chat_done, Language_File));
}
catch
{
Translations.WriteLineFormatted("chat.fail");
ConsoleIO.WriteLineFormatted(Translations.chat_fail, acceptnewlines: true);
}
httpClient.Dispose();
}
@ -259,7 +259,7 @@ namespace MinecraftClient.Protocol
&& File.Exists(Settings.TranslationsFile_FromMCDir))
{
Language_File = Settings.TranslationsFile_FromMCDir;
Translations.WriteLineFormatted("chat.from_dir");
ConsoleIO.WriteLineFormatted(Translations.chat_from_dir, acceptnewlines: true);
}
//Load the external dictionnary of translation rules or display an error message
@ -278,11 +278,11 @@ namespace MinecraftClient.Protocol
}
if (Settings.Config.Logging.DebugMessages)
Translations.WriteLineFormatted("chat.loaded");
ConsoleIO.WriteLineFormatted(Translations.chat_loaded, acceptnewlines: true);
}
else //No external dictionnary found.
{
ConsoleIO.WriteLineFormatted(Translations.Get("chat.not_found", Language_File));
ConsoleIO.WriteLineFormatted(string.Format(Translations.chat_not_found, Language_File));
}
}