IOS development ------ Program Implementation Localizable
Study AssertsLibaray. framework and Photos. when the two native static libraries of the framework are used, the group names of the album must be marked as internationalized. Although the system provides the internationalization of the group names, it is necessary to understand the internationalization. Here we will make a little record as a reference. Language internationalization is the adaptation of different languages. Just like the iPhone, texts are converted into corresponding languages based on different languages. The compiler for the following operations isXcode 7.3
International content
1. Create a string internationalization File (Strings File)
2. Change the file nameLocalizable
You need to pay attention to this problem. It must be the name. Otherwise, the system will not find the file when searching for the adaptation file, and the suffix does not need to be specified. Otherwise, a file namedLocalizable.strings.strings
This is why the file cannot be found when the adaptation file is found. The landlord made this mistake before, and the following problems may occur.
3. Select the. strings file. You can view the relevant properties and operations in the attribute column on the right. ClickLocalize
Button to create
4. ClickLocalize
Option confirmation
5. FindPROJECT -> Info -> Localizations
Click+
You can add a variety of adaptation languages. only English and simplified Chinese are added here. A small arrow is displayed on the left of the strings file, indicating that there is a file with an adaptation language below.
6. the attribute column on the right of the file is originallyLocalize
The button becomes the file option for selecting the adaptation language. Select the language you want to adapt:
7. In their respective response files"key" = "value"
To adapt:
// Adapt to Chinese: // This is in Localizable. strings (Chinese (Simplified), adapt to Chinese "Hello" = "Hello ";
// English adaptation // This is in Localizable. strings (English), English adaptation "Hello" = "Hello ";
8. The adaptation is used in the Code as follows:
// Perform local language internationalization adaptation // Objective-Cself.lblText.text = NSLocalizedString (@ "Hello", @ "") // SwiftlblText. text! = NSLocalizedString ("Hello", comment :"")
You can perform the adaptation by setting and switching the iPhone language, as shown in the following figure. The adaptation of related content to English and Chinese is completed:
International Project Name
The steps are the same as the above content. There are only a few differences.
1. The file name is InfoPlist (. strings)
2. The content format isCFBundleDisplayName = ""
The document is written as follows:
// Adapted to Chinese: // This is in InfoPlist. strings (Chinese (Simplified), adapted to Chinese CFBundleDisplayName = "Yue ";
// English adaptation // This is in InfoPlist. strings (English), and the English adaptation CFBundleDisplayName = "EnName ";
The effect is as follows: