使用python腳本和excel對比Telegram多國語言包資源

使用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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章