2 回答

TA貢獻1829條經驗 獲得超9個贊
我在中國的所有應用程序都使用 Android 框架。步驟是:
維護所有字符串的列表。
不要在你的 Android Java 中硬編碼你的刺,參考 XML。
您可以使用諸如谷歌翻譯或百度繁易(翻譯)等服務器站點進行翻譯。
例如,這是我引用字符串的活動代碼示例:
tx1 = (TextView) findViewById(R.id.your_textview);
tx1.setText(R.string.msg_about_feedback);
這是 res>values>strings.xml 的摘錄
<string name="msg_about_feedback">Feedback</string>
<string name="msg_about_filesource">File Source</string>
<string name="msg_about_cloudIP">Server</string>
<string name="msg_about_localIP">Server</string>
<string name="msg_about_serverIP">Server</string>
這里是 res>values-zh>strings.xml
<string name="msg_about_feedback">反饋</string>
<string name="msg_about_filesource">文件源</string>
<string name="msg_about_cloudIP">服務器</string>
<string name="msg_about_localIP">服務器</string>
<string name="msg_about_serverIP">服務器 IP</string>
您必須確保每個語言文件中的條目匹配。如果文件中缺少其中一個字符串,Android Studio 將標記錯誤。使用這種方法,一切都由 Android 處理。
如果您不熟悉第二語言,那么最好請人檢查翻譯。由于上下文、語法等原因,當您盲目地獲取翻譯服務器的輸出時,通常不會得到正確的結果。
添加回答
舉報