Beispiel #1
0
 private static void LoadFile()
 {
     _translation.Clear();
     _languages.Clear();
     try
     {
         //Lets load the xml
         XmlDocument xmlDoc = new XmlDocument();
         xmlDoc.Load(WOTHelper.GetTranslationFile());
         XmlElement  root     = xmlDoc.DocumentElement;
         XmlNodeList nodeList = root.SelectSingleNode("//WorldOfTanks").ChildNodes;
         foreach (XmlNode baseNode in nodeList)
         {
             foreach (XmlNode childNode in baseNode.ChildNodes)
             {
                 if (childNode.Name.ToUpper() == "LANGUAGES")
                 {
                     foreach (XmlNode fieldNode in childNode.ChildNodes)
                     {
                         string national = fieldNode.SelectSingleNode("NameNat").InnerText;
                         string english  = fieldNode.SelectSingleNode("NameENG").InnerText;
                         WOTHelper.AddToLog("Adding Language to dict: " + english);
                         _languages.Add(fieldNode.Attributes["ID"].Value, new Languages()
                         {
                             National = national, English = english
                         });
                     }
                 }
                 else if (childNode.Name.ToUpper() == "FIELDS")
                 {
                     foreach (XmlNode fieldNode in childNode.ChildNodes)
                     {
                         foreach (XmlNode item in fieldNode)
                         {
                             if (item.Name != "#comment")
                             {
                                 if (!_translation.ContainsKey(String.Format("{0}|{1}", fieldNode.Attributes["Name"].Value, item.Attributes["LanID"].Value)))
                                 {
                                     _translation.Add(String.Format("{0}|{1}", fieldNode.Attributes["Name"].Value, item.Attributes["LanID"].Value), item.InnerText);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         WOTHelper.AddToLog("Error with Translation: " + ex.Message);
         // throw ex;
     }
 }