internal static LanguageFileContent LoadSelectedLanguage(string filename) { LanguageFileContent result = null; if (string.IsNullOrEmpty(filename) || !File.Exists(filename)) { return(result); } try { XmlDocument doc = new XmlDocument(); doc.Load(filename); XmlNodeList nodes = doc.GetElementsByTagName(Constants.LANGUAGE); if (nodes.Count > 0) { result = new LanguageFileContent(filename, nodes[0]); CreateChildEntries(nodes[0], ref result); } } catch (Exception ex) { string msg = string.Format(Messages.MSG_ERROR_0_DURING_LOADING_LANGUAGES, ex.Message); Messenger.AddError(msg, ex); MessageBox.Show(View.ParentForm, msg, Core.Messages.MSG_TITLE_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
private static void CreateChildEntries(XmlNode node, ref LanguageFileContent content) { foreach (XmlNode childNode in node.ChildNodes) { content.Entries.Add(new LanguageEntry(childNode)); CreateChildEntries(childNode, ref content); } }
private void cbTransToolLanguages_SelectedIndexChanged(object sender, EventArgs e) { string filename = GetFilePathByName(cbTransToolLanguages.SelectedItem); LanguageFileContent content = TranslationController.LoadSelectedLanguage(filename); if (content != null) { SetEnabledOfAllControls(cbTransToolEdit.Checked); LanguageFileContent = content; } else { SetEnabledOfAllControls(false); } }
internal static LanguageFileContent LoadSelectedLanguage(string filename) { LanguageFileContent result = null; if (string.IsNullOrEmpty(filename) || !File.Exists(filename)) return result; try { XmlDocument doc = new XmlDocument(); doc.Load(filename); XmlNodeList nodes = doc.GetElementsByTagName(Constants.LANGUAGE); if (nodes.Count > 0) { result = new LanguageFileContent(filename, nodes[0]); CreateChildEntries(nodes[0], ref result); } } catch (Exception ex) { string msg = string.Format(Messages.MSG_ERROR_0_DURING_LOADING_LANGUAGES, ex.Message); Messenger.AddError(msg, ex); MessageBox.Show(View.ParentForm, msg, Core.Messages.MSG_TITLE_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); } return result; }