// Methods /// <summary> /// Loads the <see cref="Rewtek.GameLibrary.Localization.Language"/> from the specified path. /// </summary> /// <param name="path">The path.</param> /// <returns>A <see cref="Rewtek.GameLibrary.Localization.Language"/>.</returns> public static Language Load(string path) { if (!ResourceSystem.CheckFile(path)) { return(null); } Logger.Log("Loading language {0} ...", path); try { var document = XDocument.Load(path); var language = new Language(); if (document.Root.Attribute("Version").Value != FILE_VERSION) { MsgBox.Show(MsgBoxIcon.Error, Reflector.GetCaller(), "File Version Missmatch - " + path); return(null); } language.CultureName = document.Root.Attribute("CultureName").Value; language.NativeName = document.Root.Attribute("NativeName").Value; foreach (XElement element in document.Root.Descendants()) { language.Strings.Add(element.Attribute("Name").Value, element.Value); } return(language); } catch (XmlException ex) { Logger.Log("Language {0} could not be read. Syntax error on line {1}, column {2}", path, ex.LineNumber, ex.LinePosition); MsgBox.Show(MsgBoxIcon.Error, Reflector.GetCaller(), "Xml Syntax Error: {0}\nLine: {1}\nColumn: {2}", path, ex.LineNumber, ex.LinePosition); return(null); } catch (Exception) { Logger.Log("Language {0} could not be read", path); MsgBox.Show(MsgBoxIcon.Error, Reflector.GetCaller(), "Language {0} could not be read", path); return(null); } }