private static void ReadResource(DirectoryInfo languageDir) { TransifexResource res = new TransifexResource(); res.LanguageDirectory = languageDir.FullName; // if no strings_en.xml, stop reading resource if (!File.Exists(res.LanguageDirectory + "\\strings_en.xml")) { return; } // try to read resource infos from xml file res = ReadResourceInfosFromXml(res); // if resource name not found in xml, take parent directory of language dir if (String.IsNullOrEmpty(res.Name)) { res.Name = languageDir.Parent.Name; res.ProjectSlug = "MP2"; } Console.WriteLine("resource [{0,-40}] found in language directory: {1}", res.GetProjectAndResourceCombined(), res.LanguageDirectory.Replace(targetDir, string.Empty)); TransifexResources.Add(res); }
private static TransifexResource ReadResourceInfosFromXml(TransifexResource oldRes) { TransifexResource newRes = oldRes; try { XmlDocument doc = new XmlDocument(); doc.Load(newRes.LanguageDirectory + "\\strings_en.xml"); XmlNodeList elemList = doc.GetElementsByTagName("resources"); newRes.Name = elemList[0].Attributes["name"].Value; newRes.ProjectSlug = elemList[0].Attributes["project"].Value; return(newRes); } catch (Exception) { return(oldRes); } }
private static TransifexResource ReadResourceInfosFromXml(TransifexResource oldRes) { TransifexResource newRes = oldRes; try { XmlDocument doc = new XmlDocument(); doc.Load(newRes.LanguageDirectory + "\\strings_en.xml"); XmlNodeList elemList = doc.GetElementsByTagName("resources"); newRes.Name = elemList[0].Attributes["name"].Value; newRes.ProjectSlug = elemList[0].Attributes["project"].Value; return newRes; } catch (Exception) { return oldRes; } }
private static void ReadResource(DirectoryInfo languageDir) { TransifexResource res = new TransifexResource(); res.LanguageDirectory = languageDir.FullName; // if no strings_en.xml, stop reading resource if (!File.Exists(res.LanguageDirectory + "\\strings_en.xml")) return; // try to read resource infos from xml file res = ReadResourceInfosFromXml(res); // if resource name not found in xml, take parent directory of language dir if (String.IsNullOrEmpty(res.Name)) { res.Name = languageDir.Parent.Name; res.ProjectSlug = "MP2"; } Console.WriteLine("resource [{0,-40}] found in language directory: {1}", res.GetProjectAndResourceCombined(), res.LanguageDirectory.Replace(targetDir, string.Empty)); TransifexResources.Add(res); }