从XML文件将US Word替换为UK Word的最佳方法是什么



我的每个页面的文本都是在外部语言文件中定义的。例如在某些方面.xml。

如何自动更改某些内容的拼写.xml从美式英语更改为英式英语?

在某些事情.xml,我知道我可以对要显示的每个文本使用str_replace,但这实施起来非常耗时。

因此,我需要最好的方法将US Word从XML文件替换为UK Word。任何字典 API 都可以解决这个问题..??

我的 xml 文件 :

<?xml version="1.0" encoding="UTF-8"?><?mso-application progid="Word.Document"?><pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage">
<pkg:part pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:name="/_rels/.rels" pkg:padding="512">
<pkg:xmlData>
</pkg:xmlData>
</pkg:part>
<pkg:part pkg:contentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" pkg:name="/word/document.xml">
<pkg:xmlData>
<w:document xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing">
<w:body>
<w:p w:rsidP="003E0D43" w:rsidR="00074820" w:rsidRDefault="00074820" w:rsidRPr="009C081D">
<w:pPr>
<w:pStyle w:val="CL"/>
</w:pPr>
<w:r w:rsidRPr="009C081D">
<w:t>[GQ: PLEASE CONFIRM THAT ALL AUTHOR INFORMATION, INCLUDING NAMES, AFFILIATIONS, SEQUENCE, AND CONTACT DETAILS, IS CORRECT.]</w:t>
</w:r>
</w:p>
<w:p w:rsidP="003E0D43" w:rsidR="00074820" w:rsidRDefault="00074820" w:rsidRPr="009C081D">
<w:pPr>
<w:pStyle w:val="CL"/>
</w:pPr>
<w:r w:rsidRPr="009C081D">
<w:t>[GQ: PLEASE REVIEW THE ENTIRE DOCUMENT FOR TYPOGRAPHICAL ERRORS, MATHEMATICAL ERRORS, AND ANY OTHER NECESSARY CORRECTIONS; CHECK HEADINGS, TABLES, AND FIGURES.]</w:t>
</w:r>
</w:p>
<w:p w:rsidP="003E0D43" w:rsidR="00074820" w:rsidRDefault="00074820" w:rsidRPr="009C081D">
<w:pPr>
<w:pStyle w:val="CL"/>
</w:pPr>
<w:r w:rsidRPr="009C081D">
<w:t>[GQ: PLEASE CONFIRM YOU HAVE REVIEWED THIS PROOF TO YOUR SATISFACTION AND UNDERSTAND THIS IS YOUR FINAL OPPORTUNITY FOR REVIEW PRIOR TO PUBLICATION.]</w:t>
</w:r>
</w:p>
<w:p w:rsidP="003E0D43" w:rsidR="00074820" w:rsidRDefault="00074820" w:rsidRPr="009C081D">
<w:pPr>
<w:pStyle w:val="CL"/>
</w:pPr>
<w:r w:rsidRPr="009C081D">
<w:t>[GQ: PLEASE CONFIRM THAT THE FUNDING AND CONFLICT OF INTEREST STATEMENTS ARE ACCURATE.]</w:t>
</w:r>
</w:p>
<w:p w:rsidP="003E0D43" w:rsidR="00074820" w:rsidRDefault="00074820" w:rsidRPr="009C081D">
<w:pPr>
<w:pStyle w:val="AF"/>
<w:rPr>
<w:rPrChange w:author="Copyeditor43" w:date="2017-03-03T11:25:00Z" w:id="6">
<w:rPr/>
</w:rPrChange>
</w:rPr>
</w:pPr>
<w:bookmarkStart w:id="7" w:name="aff1"/>
<w:r w:rsidRPr="009C081D">
<w:rPr>
<w:vertAlign w:val="superscript"/>
</w:rPr>
<w:t>1</w:t>
</w:r>
<w:bookmarkEnd w:id="7"/>
<w:del w:author="Copyeditor43" w:date="2017-03-03T10:32:00Z" w:id="8">
<w:r w:rsidDel="00EC58EA" w:rsidRPr="009C081D">
<w:delText xml:space="preserve">International CyberCrime Research Centre, School of Criminology, </w:delText>
</w:r>
</w:del>
<w:r w:rsidRPr="009C081D">
<w:t xml:space="preserve">Simon Fraser University, Burnaby, </w:t>
</w:r>
<w:del w:author="Copyeditor43" w:date="2017-03-03T10:32:00Z" w:id="9">
<w:r w:rsidDel="00EC58EA" w:rsidRPr="009C081D">
<w:delText>BC</w:delText>
</w:r>
</w:del>
<w:ins w:author="Copyeditor43" w:date="2017-03-03T10:32:00Z" w:id="10">
<w:r w:rsidR="00EC58EA" w:rsidRPr="009C081D">
<w:t>British Columbia</w:t>
</w:r>
</w:ins>
<w:r w:rsidRPr="009C081D">
<w:rPr>
<w:rPrChange w:author="Copyeditor43" w:date="2017-03-03T11:25:00Z" w:id="11">
<w:rPr/>
</w:rPrChange>
</w:rPr>
<w:t>, Canada</w:t>
</w:r>
</w:p>
<w:p w:rsidR="00074820" w:rsidRPr="009C081D" w:rsidRDefault="00074820" w:rsidP="003E0D43">
<w:pPr>
<w:pStyle w:val="TEXT"/>
<w:rPr>
<w:rPrChange w:id="401" w:author="Copyeditor43" w:date="2017-03-03T11:25:00Z">
<w:rPr/>
</w:rPrChange>
</w:rPr>
</w:pPr>
<w:r w:rsidRPr="009C081D">
<w:rPr>
<w:rPrChange w:id="402" w:author="Copyeditor43" w:date="2017-03-03T11:25:00Z">
<w:rPr/>
</w:rPrChange>
</w:rPr>
<w:t>The online media output of extremist organizations has allowed their messages to be seen and heard by vast audiences, however, propaganda is even more effective when it inspires or pushes the individuals exposed to it towards radicalization or recruitment. Online media has become an increasingly important avenue for recruitment and has greatly enhanced the ability of extremist organizations to deliver their radicalizing messages (
</w:t>
</w:r>
<w:r w:rsidRPr="009C081D">
<w:rPr>
<w:rPrChange w:id="403" w:author="Copyeditor43" w:date="2017-03-03T11:25:00Z">
<w:rPr/>
</w:rPrChange>
</w:rPr>
<w:fldChar w:fldCharType="begin"/>
</w:r>
<w:r w:rsidRPr="009C081D">
<w:rPr>
</w:p>
</w:body>

我的美国和英国单词列表如下所示,

us_words_list = array('colors','flavors','organizations','radicalizing');
uk_words_list = array('colours', 'flavours','organisations','radicalising');

我使用的是java代码,所以任何人都知道这一点。请让我知道。

这在某种程度上可能吗?

谢谢。

这可能对您有用:

https://cloud.google.com/translate/docs/reference/translate

使用 DOM 解析器。解析 XML 文件并读取"w:t"(节点(标记。然后使用 Node.getTextContent(( 和 Node.setTextContent(usWord.replaceAll(word, ukWord((。

最新更新