public void ReadLanguageData(XmlRead xml, LocLanguage lang) { while (xml.ReadNextLineUntilEndTag(c_sTag)) { if (xml.IsTag(LocItem.c_sTag)) { string sItemID = xml.GetValue(LocItem.c_sID); LocItem item = Find(sItemID); if (null != item) item.ReadLanguageData(xml, lang); } if (xml.IsTag(LocGroup.c_sTag)) { string sGroupID = xml.GetValue(LocGroup.c_sID); LocGroup group = FindGroup(sGroupID); if (null != group) group.ReadLanguageData(xml, lang); } } }
static public LocLanguage ReadXML(int iIndex, XmlRead xml) { string sID = xml.GetValue(c_sID); string sName = xml.GetValue(c_sName); LocLanguage language = new LocLanguage(sID, sName, iIndex); string sFontName = xml.GetValue(c_sFontName); if (!string.IsNullOrEmpty(sFontName)) language.FontName = sFontName; string sFontSize = xml.GetValue(c_sFontSize); if (!string.IsNullOrEmpty(sFontSize)) { try { int n = Convert.ToInt16(sFontSize); if (n != 0) language.FontSize = n; } catch (Exception) { } } return language; }
public void ReadLanguageData(XmlRead xml, LocLanguage lang) { while (xml.ReadNextLineUntilEndTag(c_sTag)) { if (xml.IsTag(LocAlternate.c_sTag)) { string sLanguageID = xml.GetValue(LocAlternate.c_sID); if (sLanguageID != lang.ID) return; LocAlternate alt = LocAlternate.ReadXML(xml); AddAlternate(lang.Index, alt); } } }
public void WriteLanguageData(XmlField xmlParent, LocLanguage lang) { XmlField xml = xmlParent.GetDaughterXmlField(c_sTag, true); string s = xml.GetAttrString(c_sID, ID); xml.Begin(s); foreach (LocItem item in Items) item.WriteLanguageData(xml, lang); foreach (LocGroup sub in Groups) sub.WriteLanguageData(xml, lang); xml.End(); }
public void WriteLanguageData(XmlField xmlParent, LocLanguage lang) { // Initialize the Item field XmlField xml = xmlParent.GetDaughterXmlField(c_sTag, true); string s = xml.GetAttrString(c_sID, ID); xml.Begin(s); // Write the languge data LocAlternate alt = GetAlternate(lang.Index); if (null != alt) alt.WriteXML(xml, lang.ID); // Done xml.End(); }
void WriteLanguageData(LocLanguage lang) { // Build the language name string sPath = DataFolder + Path.DirectorySeparatorChar + lang.ID + ".xml"; // Save a backup in the current folder (See Bug0282.) JW_Util.CreateBackup(sPath, ".bak"); // Open the xml writer TextWriter w = JW_Util.GetTextWriter(sPath); XmlField xml = new XmlField(w, c_sTag); xml.Begin(); // Write out the language information lang.WriteXML(xml); // Write out the group's data foreach (LocGroup group in Groups) group.WriteLanguageData(xml, lang); // Done xml.End(); w.Close(); // Make a backup to the remote device if enabled. We have to create a file with the // date in it so that the BackupSystem has something to copy; we then delete that // file as there's no need to keep filling up the disk. (Bug0282) string sRemotePath = Path.GetFileNameWithoutExtension(sPath) + " " + DateTime.Today.ToString("yyyy-MM-dd") + ".xml"; try { //File.Copy(sPath, sRemotePath, true); //(new BackupSystem(sRemotePath)).MakeBackup(); //File.Delete(sRemotePath); } catch (Exception) { } }
public LocLanguage AppendLanguage(string sID, string sName) { LocLanguage lang = new LocLanguage(sID, sName, Languages.Length); AppendLanguage(lang); return lang; }
void AppendLanguage(LocLanguage lang) { LocLanguage[] v = new LocLanguage[Languages.Length + 1]; for (int i = 0; i < Languages.Length; i++) v[i] = Languages[i]; v[Languages.Length] = lang; m_vLanguages = v; }
void ParseAndAddLanguage(string s) { // We'll parse the ID and Name into these variables string sID = ""; string sName = ""; // Work through the string bool bIDFinished = false; foreach (char c in s) { if (c == ' ' && !bIDFinished) { bIDFinished = true; continue; } if (bIDFinished) sName += c; else sID += c; } sID = sID.Trim(); sName = sName.Trim(); if (sID.Length == 0 || sName.Length == 0) return; // Don't add if it is English if (c_mkrEnglish == sID) return; // If the language is already present, we're done if (FindLanguage(sID) != null) return; // Otherwise, create and add the new one LocLanguage lang = new LocLanguage(sID, sName, Languages.Length); AppendLanguage(lang); }