从 xlsx 读取翻译后的文本,对比旧的 XML 替换翻译,生成翻译后的 XML - idle
从 xlsx 读取翻译后的文本,对比旧的 XML 替换翻译,生成翻译后的 XML
记录:
using libxl; using System.Collections.Generic; using System.Xml.Linq; namespace Test { class Program { static void Main(string[] args) { var textData = new Dictionary<string, string>(); var doc = XDocument.Load("Old.xml"); foreach (var item in doc.Root.Descendants("text")) { textData[item.Attribute("t").Value] = item.Attribute("value").Value; } var dic = new Dictionary<string, string>(); Book book = new XmlBook(); book.load("new.xlsx"); var sheet = book.getSheet(0); for (int i = 0; i < 4886; i++) { var a1 = sheet.readStr(i, 0); var a2 = sheet.readStr(i, 1); dic[a1] = a2; } var newXml = new XElement("GameTextSet"); foreach (var node in textData) { string str; if (dic.TryGetValue(node.Value, out str)){} else if (dic.TryGetValue(node.Value.Trim(), out str)){} else str = node.Value + " 没有翻译"; newXml.Add(new XElement("text", new XAttribute("t", node.Key), new XAttribute("value", str))); } newXml.Save("New.xml"); } } }
2015年10月07日 15:02
好像天书的赶脚呀
2015年10月07日 15:03
来逛逛~
2015年10月27日 13:50
@广东办公家具厂家: 这是什么情况?推广?
2015年10月27日 13:50
@佛山窗帘厂家:你们这是推广?