2017-07-15 54 views
0

我的每個頁面的文本都是在外部語言文件中定義的。例如在somthing.xml中。什麼是從XML文件中將美國Word替換爲英國Word的最佳方式

如何自動將somthing.xml中的拼寫從美國英語更改爲英國英語?

在somthing.xml中,我知道我可以對每個我想要顯示的文本使用str_replace,但實現起來非常耗時。

所以,我需要從XML文件中替換美國Word到英國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代碼,所以任何人都知道這一點。請告訴我。

這是不是有可能?

謝謝。

+0

你能提供一些美國的詞出現在示例XML –

+0

您可以檢查,如果這被證明對你有用:HTTPS://cloud.google .com/translate/docs/reference/translate –

+0

@Rajeev Akotkar,謝謝你的努力。和目前 美國的詞像組織,激進化..但我沒有檢查你的答案。 –

回答

相關問題