internal static void WriteLanguageXml(LanguageType type) { string languagePath = LanguageOption.GetLanguagePath(type); Directory.CreateDirectory(Path.Combine(LanguageOption.GetCurrentDirectoryPath(), "LanguageResource")); XElement xelement = new XElement((XName)"US"); switch (type) { case LanguageType.Chinese: xelement = new XElement((XName)"CHS"); break; case LanguageType.Korean: xelement = new XElement((XName)"KO"); break; case LanguageType.Japanese: xelement = new XElement((XName)"JA"); break; case LanguageType.Spanish: xelement = new XElement((XName)"SP"); break; } FieldInfo[] fields = LanguageOption.TypeLanguageInfo.GetFields(); if (File.Exists(languagePath)) { foreach (MemberInfo memberInfo in fields) { string name = memberInfo.Name; string translateInfo = LanguageOption.GetTranslateInfo(name, languagePath); xelement.Add((object)LanguageOption.CreatItem(name, translateInfo)); if (string.IsNullOrEmpty(translateInfo)) { xelement.Add((object)new XElement((XName)"GoTo")); } } xelement.Save(languagePath); } else { File.Delete(languagePath); using (File.Create(languagePath)) ; foreach (MemberInfo memberInfo in fields) { string name = memberInfo.Name; string translateInfo = LanguageOption.GetTranslateInfo(name, languagePath); xelement.Add((object)LanguageOption.CreatItem(name, translateInfo)); } xelement.Save(languagePath); } }
internal static void WriteChineseXml() { string str = Path.Combine(LanguageOption.GetCurrentDirectoryPath(), "LanguageResource/en-CHS.xml"); Directory.CreateDirectory(Path.Combine(LanguageOption.GetCurrentDirectoryPath(), "LanguageResource")); File.Delete(str); using (File.Create(str)) ; XElement xelement = new XElement((XName)"CH"); foreach (MemberInfo field in LanguageOption.TypeLanguageInfo.GetFields()) { string name = field.Name; string valueBykey = LanguageOption.GetValueBykey(name); xelement.Add((object)LanguageOption.CreatItem(name, valueBykey)); } xelement.Save(str); }
internal static string GetLanguagePath(LanguageType currentType) { string currentDirectoryPath = LanguageOption.GetCurrentDirectoryPath(); switch (LanguageOption.CurrentLanguage) { case LanguageType.Chinese: return(Path.Combine(currentDirectoryPath, "LanguageResource/en-CHS.xml")); case LanguageType.Korean: return(Path.Combine(currentDirectoryPath, "LanguageResource/en-KO.xml")); case LanguageType.Japanese: return(Path.Combine(currentDirectoryPath, "LanguageResource/en-JA.xml")); case LanguageType.Spanish: return(Path.Combine(currentDirectoryPath, "LanguageResource/en-SP.xml")); default: return(Path.Combine(currentDirectoryPath, "LanguageResource/en-US.xml")); } }