// Loads all languages in the /languages folder. public void LoadLanguages() { LangFileObject languageFile; //Console.WriteLine(string.Format("Language files found: {0}", Directory.GetFiles(JsonIO.LANGUAGE_PATH).Length)); // Debug garbage. // checks to see if the directory exists. If not, we will create it. if (!Directory.Exists(JsonIO.LANGUAGE_PATH)) { Directory.CreateDirectory(JsonIO.LANGUAGE_PATH); } try { // We'll clear the list of languages first, in case we're reloading. languageFiles.Clear(); // We run through the list of language JSON files in the languages folder. foreach (string path in Directory.GetFiles(JsonIO.LANGUAGE_PATH)) { if (path.Contains(".json")) // If it's a .json file... { // Create a new language object. If this isn't here, the languageFile data and ID are never updated. languageFile = new LangFileObject(); // Console.WriteLine("Language file: {0}", path); // Debug garbage. languageFile.data = JsonIO.ReadJsonFile(path, false).data; languageFile.id = languageFile.GetValue(LanguageFileConsts.KEY_LANGUAGE); // Make sure we're not loading a duplicate. if (!CheckLanguageWithIdIsValid(languageFile.id)) { languageFiles.Add(languageFile); } else { Console.WriteLine("Language file with this ID already exists."); } } } } catch (Exception e) { Console.WriteLine(string.Format("Unable to load language files. Error: {0}", e)); } }
// Localization stoofs private void InitializeLanguage() { label_courage_static.Text = language.GetValue(LanguageFileConsts.KEY_LABEL_COURAGE); label_power_static.Text = language.GetValue(LanguageFileConsts.KEY_LABEL_POWER); label_wisdom_static.Text = language.GetValue(LanguageFileConsts.KEY_LABEL_WISDOM); label_speed_static.Text = language.GetValue(LanguageFileConsts.KEY_LABEL_SPEED); label_energy_static.Text = language.GetValue(LanguageFileConsts.KEY_LABEL_ENERGY); button_courage_adjust.Text = language.GetValue(LanguageFileConsts.KEY_BUTTON_ADJUST); button_power_adjust.Text = language.GetValue(LanguageFileConsts.KEY_BUTTON_ADJUST); button_wisdom_adjust.Text = language.GetValue(LanguageFileConsts.KEY_BUTTON_ADJUST); button_speed_adjust.Text = language.GetValue(LanguageFileConsts.KEY_BUTTON_ADJUST); button_energy_adjust.Text = language.GetValue(LanguageFileConsts.KEY_BUTTON_ADJUST); button_courage_font.Text = language.GetValue(LanguageFileConsts.KEY_BUTTON_FONT); button_power_font.Text = language.GetValue(LanguageFileConsts.KEY_BUTTON_FONT); button_wisdom_font.Text = language.GetValue(LanguageFileConsts.KEY_BUTTON_FONT); button_speed_font.Text = language.GetValue(LanguageFileConsts.KEY_BUTTON_FONT); button_energy_font.Text = language.GetValue(LanguageFileConsts.KEY_BUTTON_FONT); button_courage_reset.Text = language.GetValue(LanguageFileConsts.KEY_BUTTON_RESET); button_power_reset.Text = language.GetValue(LanguageFileConsts.KEY_BUTTON_RESET); button_wisdom_reset.Text = language.GetValue(LanguageFileConsts.KEY_BUTTON_RESET); button_speed_reset.Text = language.GetValue(LanguageFileConsts.KEY_BUTTON_RESET); button_energy_reset.Text = language.GetValue(LanguageFileConsts.KEY_BUTTON_RESET); button_resetAll.Text = language.GetValue(LanguageFileConsts.KEY_BUTTON_RESET_ALL); fileToolStripMenuItem.Text = language.GetValue(LanguageFileConsts.KEY_MENU_FILE); writeFromFileToolStripMenuItem.Text = language.GetValue(LanguageFileConsts.KEY_MENU_WRITE_FROM_FILE); loadImageToolStripMenuItem.Text = language.GetValue(LanguageFileConsts.KEY_MENU_LOAD_IMAGE); saveAsToolStripMenuItem.Text = language.GetValue(LanguageFileConsts.KEY_MENU_SAVE_AS); aboutToolStripMenuItem.Text = language.GetValue(LanguageFileConsts.KEY_MENU_ABOUT); settingsToolStripMenuItem.Text = language.GetValue(LanguageFileConsts.KEY_MENU_SETTINGS); versionToolStripMenuItem.Text = string.Format("{0} {1}", language.GetValue(LanguageFileConsts.KEY_LABEL_VERSION), System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()); this.Text = Program.language.GetValue(LanguageFileConsts.KEY_PROGRAM_TITLE); }