IOS development ------ Program Implementation Localizable

Source: Internet
Author: User

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 nameLocalizableYou 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.stringsThis 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. ClickLocalizeButton to create



4. ClickLocalizeOption confirmation



5. FindPROJECT -> Info -> LocalizationsClick+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 originallyLocalizeThe 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:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.