1. In the custom resources directory Localizables Right-click, select New File,
Then choose the strings file resource want
Click Next, the file name is defined as "Localizable.strings", select the directory you want to save, create
2. Select the Localizable.strings file
In the tool panel on the right, click on the "+" key to add English and Chinese, respectively.
The directory structure on the left will become
The corresponding directory will generate two corresponding English en.lproj and Chinese zh-hans.lproj directories, as well as corresponding localizable.strings files.
As follows:
3. Localization
Localizable.strings the way a list of key-value pairs is used to localize application data
The format is:
"Key" = "value";
Where the input colon, equal sign, when good, must be in English state
Like what:
Write in Localizable.strings (中文版) file
"TestKey" = "test";
Write in Localizable.strings (Chinese) file
"TestKey" = "test";
When used, simply call system macro nslocalizedstring to use language to set unrelated string data
Form: nslocalizedstring (@ "key", nil)
Like what:
Nslocalizedstring The first parameter is the corresponding key name, the second parameter is a custom description, you can pass nil
4. Localization of application names
Edit Info.plist, add application has localized display name entry, set the value to Yes
If the program generates a infoplist.strings file automatically, if not, create one, and do the same 1 and 2 steps
Cfbundledisplayname values are defined in Infoplist.strings (中文版) and Infoplist.strings (Chinese) respectively
"Cfbundledisplayname" = "app name";
"Cfbundledisplayname" = "app name";
Set default setting to Chinese: Edit info.plist, add localization native development region entry, set to China
5. Image and Xib file localization similar, also can add the same name picture file and Xib file in the corresponding en.lproj and zh-hans.lproj directory
Then add files to the project list
--app Localization of the iphone development must-know point