private static void LoadFromXml(XmlDocument doc)
        {
            Debug.Print("Loading localized text xml.");
            if (doc.ChildNodes.Count <= 1 || doc.ChildNodes[1].Name != "base" || doc.ChildNodes[1].ChildNodes[0].Name != "tags" || !(doc.ChildNodes[1].ChildNodes[1].Name == "strings") && !(doc.ChildNodes[1].ChildNodes[1].Name == "functions") || doc.ChildNodes[1].ChildNodes[2] != null && (doc.ChildNodes[1].ChildNodes[2] == null || !(doc.ChildNodes[1].ChildNodes[2].Name == "strings")))
            {
                throw new TWXmlLoadException("Incorrect XML document format!");
            }
            string      str = "";
            bool        languageUnderDevelopment = false;
            XmlNodeList childNodes = doc.ChildNodes[1].ChildNodes[0].ChildNodes;

            for (int i = 0; i < childNodes.Count; ++i)
            {
                if (childNodes[i].Attributes?["language"] != null)
                {
                    str = childNodes[i].Attributes["language"].Value;
                }
                else if (childNodes[i].Attributes?["under_development"] != null)
                {
                    languageUnderDevelopment = Convert.ToBoolean(childNodes[i].Attributes?["under_development"].Value);
                }
            }
            if (str.IsStringNoneOrEmpty())
            {
                return;
            }
            if (!LocalizedTextManager._languageIds.ContainsKey(str))
            {
                LocalizedTextManager.AddLanguage(str, languageUnderDevelopment);
            }
            foreach (XmlNode childNode in doc.ChildNodes[1].ChildNodes)
            {
                if (childNode.Name == "strings")
                {
                    for (XmlNode node = doc.ChildNodes[1].ChildNodes[1].ChildNodes[0]; node != null; node = node.NextSibling)
                    {
                        if (node.Name == "string" && node.NodeType != XmlNodeType.Comment)
                        {
                            LocalizedTextManager.DeserilaizeStrings(node, str);
                        }
                    }
                }
                else if (childNode.Name == "functions")
                {
                    for (XmlNode node = doc.ChildNodes[1].ChildNodes[1].ChildNodes[0]; node != null; node = node.NextSibling)
                    {
                        if (node.Name == "function" && node.NodeType != XmlNodeType.Comment)
                        {
                            LocalizedTextManager.DeserilaizeFunctions(node, str);
                        }
                    }
                }
            }
        }
 public static void LoadLocalizationXmls(string[] loadedModules)
 {
     LocalizedTextManager._languageIds.Clear();
     LocalizedTextManager.AddLanguage("English", false);
     foreach (string loadedModule in loadedModules)
     {
         string path = loadedModule + "/ModuleData/Languages";
         if (Directory.Exists(path))
         {
             foreach (string file in Directory.GetFiles(path, "*.xml", SearchOption.AllDirectories))
             {
                 LocalizedTextManager.LoadLocalizedTexts(file);
             }
         }
     }
 }