在實際的開發中,當我們完成了一個apk,一般都是英語和中文簡體這兩種語語言,如果釋出了,則需要把字元轉換給翻譯公司,讓他們幫忙翻譯,一般提供一個 Excel 表格,如下:


String 轉換成 Excel
首先,在工程的根目錄,寫一個資料夾,比如 Test:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">OtaService</string>
<string name="anim_time">200</string>
<string name="system_update">System upgrade</string>
<string name="check_new_version">Find a new version. Download it?</string>
</resources>
複製程式碼
arrays 如下:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="test_array">
<item>one</item>
<item>two</item>
<item>three</item>
</string-array>
<string-array name="test2_array">
<item>hour</item>
<item>min</item>
<item>second</item>
</string-array>
</resources>
複製程式碼
開始轉換
找到工程下的 WriteXmlToXls

需要新增 資料夾的名字:




Excel 轉 strings.xml 和 arrays
上面,我們已經把 strings 和 arrays 轉換成 Excel 了,那麼接下來就是對 Excel 傳承我們最喜歡 的string 和 arrays 了。 把 test.xlsx 的 strings 新增多幾個字元,和新增一箇中文繁體的

arrays 也加一個:

然後把 test.xlsl 放在根目錄下,並找到 ReadXlsToXml 這個類

ReadXlsToXml 可以配置一些資訊:

看下面的 動圖:

按 F5 重新整理一下,就可以看到 也生成了 value-zh-rTW 的繁體字元了。