The internationalization of iOS apps is divided into 3 main parts:
- Internationalization of Info.plist files
- Internationalization of the. xib file
- Internationalization of. m files
I'll show you the following one by one.
internationalization of info.plist files
We use Xcode 4.5 to create a new project that automatically creates a en.lproj directory, which stores files that need to be internationalized (the default is English). Below, we also need to create Chinese internationalization support.
1. Create a directory named Zh-hans.lproj
2. Add the configuration localizations in the project's Info.plist file, adding support for English and Chinese: 中文版, Chinese (Simplified)
3. Copy the En.lproj/infoplist.strings file to the Zh-hans.lproj/infoplist.strings file.
4. Add the Zh-hans.lproj directory to the project. Note To select Add to targets
5. Select File--Info--Localization for the corresponding language
In the Infoplist.strings file, we can internationalize some application information, for example:
Cfbundledisplayname app display name. This allows us to display application names in different languages depending on the language.
For more field information, refer to
http://developer.apple.com/library/ios/#documentation/general/reference/infoplistkeyreference/articles/ Corefoundationkeys.html
The Key Summary section.
internationalization of the. xib file
We have created an English xib file under the En.lproj file. Then, you need to use the command line to manipulate:
1. Extract the text from the. xib file and save it as a. strings file.
Ibtool--generate-strings-file mainviewcontroller.strings Mainviewcontroller.xib
2. Copy the mainviewcontroller.strings to the Zh-hans.lproj directory and then the text in the file
3. Execute the order, according to the English. xib files and. strings files to generate a Chinese-language. xib file
Ibtool--strings-file zh-hans.lproj/mainviewcontroller.strings--write zh-hans.lproj/mainviewcontroller.xib En.lproj/mainviewcontroller.xib
4. Add the generated. xib file to the Zh-hans.lproj group in the project, and note to select Add to Targets
5. Select File--Info--Localization for the corresponding language
At this point, the Xib file of the Han has been completed.
internationalization of. m Files
1. In the code, any text that requires internationalization uses the Nslocalizedstring function, for example
Nslocalizedstring (@ "Hello_world", @ "Hello world!");
2. Execute the command, extract all the text in the. m file that need to be Chinese, and put it in the En.lproj folder
Genstrings-o en.lproj *.M
At this point, the Localizable.strings file is automatically generated. The file is then copied to the Zh-hans.lproj folder. This file is something that needs to be Chinese.
3. Add the. strings file to the appropriate Chinese directory in the project, and be careful to select Add to Targets
4. Select File--Info--Localization for the corresponding language
Then we run the program, and by modifying the system language discovery, the file display name, the. xib file, and the. m file are automatically switched to the display language.
http://blog.csdn.net/midfar/article/details/8165380
Internationalization of iOS Apps