Reference
[1] http://www.raywenderlich.com/2876/how-to-localize-an-iphone-app-tutorial
In addition to app name localization, app localization also includesUse text localization, XIB resource localization (buttons, etc.), and image resource localization, This article introduces the localization of the three
1. Use text Localization
1) Right-click the project file, select "new file", and select string file to create the localizable. Strings file.
1.1) If nslocalizedstring is used, you must use the localizable. Strings file name,
Because # define nslocalizedstring (Key, comment )\
[[Nsbundle mainbundle] localizedstringforkey :( key) value: @ "" table: Nil]
The value passed by table is nil, which is the default table, and the default table is localizable. Strings.
If it is changed to another file name, such as XXX. Strings, use nslocalizedstringfromtable (@ "key", @ "XXX", nil); for localization. XXX has no suffix. Strings
1.2) if you need to use localized files from other directories, you may not want to determine which localization to use based on the language of your mobile phone, but want to use the switch to control it.
You can use nslocalizedstringfromtableinbundle to create nsbundle according to the target directory. In addition, bundle is actually a directory.
# Define nslocalizedstringfromtableinbundle (Key, TBL, bundle, comment )\
[Bundle localizedstringforkey :( key) value: @ "Table :( TBL)]
Nsstring * result = key; static nsbundle * bundle = nil; static dispatch_once_t oncetoken; dispatch_once (& oncetoken, ^ {bundle = [[nsbundle bundlewithpath: bundlepath (path is only a directory)] retain] ;}); If ([key length]> 0 & bundle) {result = nslocalizedstringfromtableinbundle (Key, XXX (no suffix. strings), bundle, nil );}
2) Create Chinese localization for localizable. Strings
3) In localizable. Strings (Chinese), modify the title and key fields and set the language of the device to "Chinese". The result is as follows:
2. Localization of XIB Resources
3Localization of image resources
Then use an image with the same name but different content in EN. lproj and zh-Hans.lproj.