我的问题是:在我们国家,string.xml中的一些默认单词“wifi”必须更改为“wlan”,但在其他国家,我应该将“wifi”保留为默认的string.xml。而且我也不希望在 src 代码中适应它,因为它会花费大量时间进行代码维护。
注意:我在不同的国家有不同的默认 string.xml
感谢帮助!
我的问题是:在我们国家,string.xml中的一些默认单词“wifi”必须更改为“wlan”,但在其他国家,我应该将“wifi”保留为默认的string.xml。而且我也不希望在 src 代码中适应它,因为它会花费大量时间进行代码维护。
注意:我在不同的国家有不同的默认 string.xml
感谢帮助!
You need to Localizing with Resources. Where you can easily do you task.
Below content Reference : Supporting Different Languages
To add support for more languages, create additional values directories inside res/ that include a hyphen and the ISO country code at the end of the directory name. For example, values-es/ is the directory containing simple resourcess for the Locales with the language code "es". Android loads the appropriate resources according to the locale settings of the device at run time.
Once you’ve decided on the languages you will support, create the resource subdirectories and string resource files. For example:
MyProject/ res/ values/ strings.xml values-es/ strings.xml values-fr/ strings.xml
Add the string values for each locale into the appropriate file.
At runtime, the Android system uses the appropriate set of string resources based on the locale currently set for the user's device.
For example, the following are some different string resource files for different languages.
English (default locale), /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>
Spanish, /values-es/strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="title">Mi Aplicación</string>
<string name="hello_world">Hola Mundo!</string>
</resources>
Reference : Supporting Different Languages