mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Setting for choosing the language to use
- Download the appropriate language file regarding the language setting - Stores language files in the "lang" subfolder
This commit is contained in:
parent
86908c35a0
commit
eef5e92af5
2 changed files with 28 additions and 23 deletions
|
|
@ -95,29 +95,25 @@ namespace MinecraftClient
|
|||
TranslationRules["commands.message.display.incoming"] = "§7%s whispers to you: %s";
|
||||
TranslationRules["commands.message.display.outgoing"] = "§7You whisper to %s: %s";
|
||||
|
||||
//Use translations from Minecraft assets if translation file is not found but a copy of the game is installed?
|
||||
if (!System.IO.File.Exists(Settings.TranslationsFile) //Try en_GB.lang
|
||||
&& System.IO.File.Exists(Settings.TranslationsFile_FromMCDir))
|
||||
{
|
||||
Settings.TranslationsFile = Settings.TranslationsFile_FromMCDir;
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
ConsoleIO.WriteLine("Using en_GB.lang from your Minecraft directory.");
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
}
|
||||
//Language file in a subfolder, depending on the language setting
|
||||
if (!System.IO.Directory.Exists("lang"))
|
||||
System.IO.Directory.CreateDirectory("lang");
|
||||
|
||||
//Still not found? try downloading en_GB from Mojang's servers?
|
||||
if (!System.IO.File.Exists(Settings.TranslationsFile))
|
||||
string Language_File = "lang\\" + Settings.Language + ".lang";
|
||||
|
||||
//File not found? Try downloading language file from Mojang's servers?
|
||||
if (!System.IO.File.Exists(Language_File))
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
ConsoleIO.WriteLine("Downloading en_GB.lang from Mojang's servers...");
|
||||
ConsoleIO.WriteLine("Downloading '" + Settings.Language + ".lang' from Mojang servers...");
|
||||
try
|
||||
{
|
||||
string assets_index = downloadString(Settings.TranslationsFile_Website_Index);
|
||||
string[] tmp = assets_index.Split(new string[] { "lang/en_GB.lang" }, StringSplitOptions.None);
|
||||
string[] tmp = assets_index.Split(new string[] { "lang/" + Settings.Language + ".lang" }, StringSplitOptions.None);
|
||||
tmp = tmp[1].Split(new string[] { "hash\": \"" }, StringSplitOptions.None);
|
||||
string hash = tmp[1].Split('"')[0]; //Translations file identifier on Mojang's servers
|
||||
System.IO.File.WriteAllText(Settings.TranslationsFile, downloadString(Settings.TranslationsFile_Website_Download + '/' + hash.Substring(0, 2) + '/' + hash));
|
||||
ConsoleIO.WriteLine("Done. File saved as \"" + Settings.TranslationsFile + '"');
|
||||
System.IO.File.WriteAllText(Language_File, downloadString(Settings.TranslationsFile_Website_Download + '/' + hash.Substring(0, 2) + '/' + hash));
|
||||
ConsoleIO.WriteLine("Done. File saved as '" + Language_File + '\'');
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -126,10 +122,20 @@ namespace MinecraftClient
|
|||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
}
|
||||
|
||||
//Load the external dictionnary of translation rules or display an error message
|
||||
if (System.IO.File.Exists(Settings.TranslationsFile))
|
||||
//Download Failed? Defaulting to en_GB.lang if the game is installed
|
||||
if (!System.IO.File.Exists(Language_File) //Try en_GB.lang
|
||||
&& System.IO.File.Exists(Settings.TranslationsFile_FromMCDir))
|
||||
{
|
||||
string[] translations = System.IO.File.ReadAllLines(Settings.TranslationsFile);
|
||||
Language_File = Settings.TranslationsFile_FromMCDir;
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
ConsoleIO.WriteLine("Defaulting to en_GB.lang from your Minecraft directory.");
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
}
|
||||
|
||||
//Load the external dictionnary of translation rules or display an error message
|
||||
if (System.IO.File.Exists(Language_File))
|
||||
{
|
||||
string[] translations = System.IO.File.ReadAllLines(Language_File);
|
||||
foreach (string line in translations)
|
||||
{
|
||||
if (line.Length > 0)
|
||||
|
|
@ -149,8 +155,7 @@ namespace MinecraftClient
|
|||
else //No external dictionnary found.
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
ConsoleIO.WriteLine("Translations file not found: \"" + Settings.TranslationsFile + "\""
|
||||
+ "\nYou can pick a translation file from .minecraft\\assets\\lang\\"
|
||||
ConsoleIO.WriteLine("Translations file not found: \"" + Language_File + "\""
|
||||
+ "\nSome messages won't be properly printed without this file.");
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ namespace MinecraftClient
|
|||
public static string TranslationsFile_FromMCDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\.minecraft\assets\objects\9e\9e2fdc43fc1c7024ff5922b998fadb2971a64ee0"; //MC 1.7.4 en_GB.lang
|
||||
public static string TranslationsFile_Website_Index = "https://s3.amazonaws.com/Minecraft.Download/indexes/1.7.4.json";
|
||||
public static string TranslationsFile_Website_Download = "http://resources.download.minecraft.net";
|
||||
public static string TranslationsFile = "translations.lang";
|
||||
public static string Bots_OwnersFile = "bot-owners.txt";
|
||||
public static string Language = "en_GB";
|
||||
|
||||
//AntiAFK Settings
|
||||
public static bool AntiAFK_Enabled = false;
|
||||
|
|
@ -121,7 +121,7 @@ namespace MinecraftClient
|
|||
case "password": Password = argValue; break;
|
||||
case "serverip": ServerIP = argValue; break;
|
||||
case "singlecommand": SingleCommand = argValue; break;
|
||||
case "translationsfile": TranslationsFile = argValue; break;
|
||||
case "language": Language = argValue; break;
|
||||
case "botownersfile": Bots_OwnersFile = argValue; break;
|
||||
case "consoletitle": ConsoleTitle = argValue; break;
|
||||
}
|
||||
|
|
@ -212,7 +212,7 @@ namespace MinecraftClient
|
|||
+ "\r\n"
|
||||
+ "#Advanced settings\r\n"
|
||||
+ "\r\n"
|
||||
+ "translationsfile=translations.lang\r\n"
|
||||
+ "language=en_GB\r\n"
|
||||
+ "botownersfile=bot-owners.txt\r\n"
|
||||
+ "consoletitle=Minecraft Console Client - %username%\r\n"
|
||||
+ "\r\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue