public static LanguageEngine LoadDefault() { string dictionary_path = string.Format("./Assets/Languages/{0}.xml", App.Settings.DefaultLanguage); LanguageEngine le = null; if (System.IO.File.Exists(dictionary_path)) { try { le = Utility.Deserialize <LanguageEngine>(dictionary_path); } catch (System.Xml.XmlException) { //bad file, try to find another working file foreach (string lang in Utility.GetAvailableLanguages()) { if (lang.Equals(App.Settings.DefaultLanguage, StringComparison.OrdinalIgnoreCase)) { continue; } try { le = Utility.Deserialize <LanguageEngine>(string.Format("./Assets/Languages/{0}.xml", lang)); } catch { continue; } //end of try-catch } // loop } // end of the fallback-try-catch catch { } } if (le == null) { le = LanguageEngine.GetDummyLanguageEngine(); } return(le); }
/// <summary> /// Save an empty .xml file on the desktop to be used by translators. /// </summary> public static void SaveDummy() { Utility.Serialize <LanguageEngine>(LanguageEngine.GetDummyLanguageEngine(), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "byteflood_lang_empty.xml"), true); }