iOS development------Programs for internationalization localizable

Source: Internet
Author: User

When studying the two native static libraries of assertslibaray.framework and Photos.framework, the group name of the album needs to be internationalized to mark it, although the system provides the internationalization of the group name, but it is necessary to know a little bit about internationalization. Here is a little note for reference. Language internationalization is the adaptation to different languages, just like the iphone, depending on the language, the text will be translated into the appropriate language. The compiler for the following operations isXcode 7.3

Content Internationalization

1. Create a string internationalization file (Strings files)



2, the name of the file to change Localizable , here need to pay attention to a problem, it must be the name, or the system will find a suitable file when the file can not be found, followed by the suffix name does not need to hit, or will create a Localizable.strings.strings file called, this is to find a suitable file when the file is not found, Landlord before is made this mistake, the following will appear the name of the problem, mutual encouragement.



3. Select the. strings file, you can see the relevant properties and actions from the property bar on the right, click on the Marked Localize button to create



4. Click on the option in the box to Localize confirm



5. Find the number in the PROJECT -> Info -> Localizations bottom left-hand corner of the project + to add a variety of languages to match. This only adds its own English and Simplified Chinese, which is added, and a small arrow appears to the left of the previous. strings file to indicate that there are already files in the appropriate language.



6, the property bar on the right side of the file is the place of the Localize button to choose the appropriate language of the file options, the language of their own adaptation to tick:



7, in their respective response files, in accordance with "key" = "value" the form of adaptation can be:

//适配中文://这是在Localizable.strings( Chinese(Simplified) )中,对中文进行适配"Hello""你好啊";
//适配英文//这是在Localizable.strings( English )中,对英文进行适配"Hello""Hello";

8. The use of the appropriate code is as follows:

//进行本地语言国际化适配//Objective-Cself.lblText.text = NSLocalizedString(@"Hello", @"")//SwiftlblText.text! = NSLocalizedString("Hello""")

The iphone language can be set up and run to fit, shown below, complete the relevant content in English and Chinese adaptation:

Project name Internationalization

The steps are the same as above, just a few different points.
1, the file name is called Infoplist (. Strings)
2, the content of the form ofCFBundleDisplayName = ""

The landlord in the corresponding document in the following wording:

//适配中文://这是在InfoPlist.strings( Chinese(Simplified) )中,对中文进行适配"岳";
//适配英文//这是在InfoPlist.strings( English )中,对英文进行适配"EnName";

The effect is as follows:

iOS development------Programs for internationalization localizable

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.