从 xlsx 读取翻译后的文本,对比旧的 XML 替换翻译,生成翻译后的 XML - idle

从 xlsx 读取翻译后的文本,对比旧的 XML 替换翻译,生成翻译后的 XML

views63 posted @ 2015年7月29日 20:05 in I with tags c# 为工具所累 test 工作? , 2050 阅读

记录:

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");
        }
    }
}
Avatar_small
views63 说:
2015年10月27日 13:50

@广东办公家具厂家: 这是什么情况?推广?

Avatar_small
views63 说:
2015年10月27日 13:50

@佛山窗帘厂家:你们这是推广?

AP 10th Physics Mode 说:
2022年9月15日 22:56

Physical Science is the part of Science known as Physics (PS), every student in class 10th grade studying at Government & Private Schools of the state board can download the AP SSC PS Model Paper 2023 with answers for all topics of the course designed by the board experts based on the new revised syllabus and curriculum of the BSEAP. Either Telugu medium, English medium and Urdu medium students of class 10th can download the AP SSC Physics model papers 2023 to practice with regular revisions and mock tests. AP 10th Physics Model Paper Class teachers and leading institutional experts are prepared those AP 10th Class PS Model Paper 2023 Pdf with answers that support all exam formats of the board such as Summative Assessments (SA-1 & SA-2) and Formative assessments (FA-1, FA-2, FA-3, FA-4) along with Assignments.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee