我的问题是:在我国,一些默认词在string.xml中作为"wifi“必须改为"wifi”,而在其他国家,我应该保留“wifi”作为默认 string.xml。我也不希望在src代码中适合它,因为它将花费大量的时间来维护代码。
注意:我有不同的默认string.xml,在不同的国家
谢谢你帮忙!
发布于 2013-06-08 10:33:03
你需要用资源本地化。在那里你可以轻松地完成任务。
以下内容参考:支持不同的语言
若要添加对更多语言的支持,请在res/中创建附加值目录,其中包括目录名称末尾的连字符和ISO国家代码。例如,values es/是包含语言代码"es“的地区的简单资源的目录。Android在运行时根据设备的区域设置加载适当的资源。。
一旦决定了要支持的语言,就创建资源子目录和字符串资源文件。例如:
MyProject/ res/ values/ strings.xml值-es/ strings.xml值-fr/ strings.xml
将每个区域设置的字符串值添加到适当的文件中。
在运行时,Android系统根据当前为用户设备设置的区域设置使用适当的字符串资源集。
例如,下面是针对不同语言的一些不同的字符串资源文件。
英语(默认语言环境),/values/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="title">My Application</string>
<string name="hello_world">Hello World!</string>
</resources>
西班牙语,/values es/strings.xml s.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="title">Mi Aplicación</string>
<string name="hello_world">Hola Mundo!</string>
</resources>
参考资料:支持不同的语言
https://stackoverflow.com/questions/16998545
复制相似问题