Find automatically a translation file from MC 1.7+

Load a translation file if Minecraft is installed on the computer
This commit is contained in:
ORelio 2014-01-06 18:10:19 +01:00
parent ccc2fd57b4
commit 6beb5588ce
2 changed files with 8 additions and 4 deletions

View file

@ -95,10 +95,13 @@ namespace MinecraftClient
TranslationRules["commands.message.display.incoming"] = "§7%s whispers to you: %s"; TranslationRules["commands.message.display.incoming"] = "§7%s whispers to you: %s";
TranslationRules["commands.message.display.outgoing"] = "§7You whisper to %s: %s"; TranslationRules["commands.message.display.outgoing"] = "§7You whisper to %s: %s";
//Use translations from Minecraft assets if a copy of the game is installed? //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) if (!System.IO.File.Exists(Settings.TranslationsFile) //Try en_US.lang
&& System.IO.File.Exists(Settings.TranslationsFile_FromMCDir)) && System.IO.File.Exists(Settings.TranslationsFile_FromMCDir))
{ Settings.TranslationsFile = Settings.TranslationsFile_FromMCDir; } { Settings.TranslationsFile = Settings.TranslationsFile_FromMCDir; }
if (!System.IO.File.Exists(Settings.TranslationsFile) //Still not found? try en_GB.lang
&& System.IO.File.Exists(Settings.TranslationsFile_FromMCDir_Alt))
{ Settings.TranslationsFile = Settings.TranslationsFile_FromMCDir_Alt; }
//Load an external dictionnary of translation rules //Load an external dictionnary of translation rules
if (System.IO.File.Exists(Settings.TranslationsFile)) if (System.IO.File.Exists(Settings.TranslationsFile))
@ -123,7 +126,7 @@ namespace MinecraftClient
else //No external dictionnary found. else //No external dictionnary found.
{ {
Console.ForegroundColor = ConsoleColor.DarkGray; Console.ForegroundColor = ConsoleColor.DarkGray;
ConsoleIO.WriteLine("MC 1.6+ warning: Translations file not found: \"" + Settings.TranslationsFile + "\"" ConsoleIO.WriteLine("Translations file not found: \"" + Settings.TranslationsFile + "\""
+ "\nYou can pick a translation file from .minecraft\\assets\\lang\\" + "\nYou can pick a translation file from .minecraft\\assets\\lang\\"
+ "\nSome messages won't be properly printed without this file."); + "\nSome messages won't be properly printed without this file.");
Console.ForegroundColor = ConsoleColor.Gray; Console.ForegroundColor = ConsoleColor.Gray;

View file

@ -23,7 +23,8 @@ namespace MinecraftClient
public static string SingleCommand = ""; public static string SingleCommand = "";
//Other Settings //Other Settings
public static string TranslationsFile_FromMCDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\.minecraft\assets\lang\en_US.lang"; public static string TranslationsFile_FromMCDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\.minecraft\assets\virtual\legacy\lang\en_US.lang";
public static string TranslationsFile_FromMCDir_Alt = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\.minecraft\assets\virtual\legacy\lang\en_GB.lang";
public static string TranslationsFile = "translations.lang"; public static string TranslationsFile = "translations.lang";
public static string Bots_OwnersFile = "bot-owners.txt"; public static string Bots_OwnersFile = "bot-owners.txt";