<sys:String x:Key="STR_License_WithoutLicense">Sorry, you are not authorized.</sys:String>
<ResourceDictionary> <sys:String x:Key="STR_Startup_LaunchRPD">Launching Polycom RealPresence Desktop</sys:String> <sys:String x:Key="STR_Startup_CheckFolder">Checking folder</sys:String>
<language-strings> <ABK_CALL comment="verb (command, button on screen to press to place a call);" controls="Button" products="HDX,VSX,CMAD,Venus Main"> <ARABIC notes="" last-change-date="" status="">打电话</ARABIC> <CHINESE_S notes="" last-change-date="" status="">呼叫</CHINESE_S>
import xml.dom.minidom
from xml.dom.minidom import Document
RPD_Str_path = "E:/PythonCode/StringResource.en-US.xaml"
RPD_dom = xml.dom.minidom.parse(RPD_Str_path)
CMAD_Str_path = "E:/PythonCode/M500_RPM13_0522.xml"
CMAD_dom = xml.dom.minidom.parse(CMAD_Str_path)
#得到根节点
RPD_root = RPD_dom.documentElement
CMAD_root = CMAD_dom.documentElement
def IsStr_already_Translated(RPD_Str):
for firstLevel in CMAD_root.childNodes:
for SecondLevel in firstLevel.childNodes:
if SecondLevel.nodeType == SecondLevel.ELEMENT_NODE:
if SecondLevel.nodeName == "ENGLISH_US":
if RPD_Str == SecondLevel.childNodes[0].data.strip():
return firstLevel.nodeName
else:
continue
else:
continue
else:
continue
else:
continue
else:
return "Null"
#用Document来写xml文件
Mapping_doc = Document()
Mapping_root = Mapping_doc.createElement("Common_String")
Mapping_doc.appendChild(Mapping_root)
Translation_doc = Document()
Translation_root = Translation_doc.createElement("Need_Translation_String")
Translation_doc.appendChild(Translation_root)
for node in RPD_root.childNodes:
if node.nodeType == node.ELEMENT_NODE:
# print node.getAttribute("x:Key") +" + "+ node.childNodes[0].data
CMAD_Key = IsStr_already_Translated(node.childNodes[0].data.strip())
if(CMAD_Key != "Null"):
mKey = Mapping_doc.createElement(node.getAttribute("x:Key"))
Mapping_root.appendChild(mKey)
mValue = Mapping_doc.createTextNode(CMAD_Key)
mKey.appendChild(mValue)
elif(CMAD_Key == "Null"):
Key = Translation_doc.createElement('sys:String')
Translation_root.appendChild(Key)
Key.setAttribute('x:Key', node.getAttribute("x:Key"))
Value = Translation_doc.createTextNode(node.childNodes[0].nodeValue)
Key.appendChild(Value)
continue
else:
path1 = "E:/PythonCode/ID_Mapping.xml"
try:
import codecs
f1 = codecs.open(path1, "wb", "utf-8")
f1.write(Mapping_doc.toprettyxml(indent=" "))
except:
print('Write xml file failed.... file:{0}'.format(path1))
path2 = "E:/PythonCode/Need_Translate_String.xml"
try:
f2 = codecs.open(path2, "wb", "utf-8")
f2.write(Translation_doc.toprettyxml(indent=" "))
except:
print('Write xml file failed.... file:{0}'.format(path2))
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有