使用EXCEL對應英文、德文、中文,各種文,然後生成strings.xml
Python真是又快又好啊。
思路:
1) 讀入中文包,加載到字典。
2)讀英文包,逐行寫入excel,同時在字典中找到中文,
3)如果中文有多餘,寫到尾部。
4)剩下的就是人工矯正了。
效果:
python腳本:
#coding=utf-8
import xml.dom.minidom
import openpyxl
# 中文映射
dictZh = {"1": ""}
dictZh.clear()
# 英文映射
dictEn = {"1": ""}
dictEn.clear()
#打開xml文檔
dom = xml.dom.minidom.parse('d:\\unofficial_classic_zh_cn.xml')
#得到文檔元素對象
root = dom.documentElement # "resources"
print(root.nodeName)
print(root.nodeValue)
print(root.nodeType )
print (root.ELEMENT_NODE)
nodes = root.getElementsByTagName('string') #獲取xml節點對象集合
# 行號
index = 1
for node in nodes:
name = node.getAttribute('name')
if (node.firstCh