"Go" iOS Multi-language localization (internationalization) settings

Source: Internet
Author: User

Original URL: http://www.jianshu.com/p/2b7743ae9c90

Discussion of multi-language settings in iOS apps, Ok is generally two things:

1. Automatically toggle display based on current device language

2. Language settings are available in the app

So far, 6 of the projects I've personally done involve multiple languages, all of which need to be set up in the app. In fact, there is no big relationship, we will first say that according to the current device language to switch interface display (these are online can be found, I tidy up the steps to their own clear point to see it later). While the application in the language setting, is actually to get the current locale and through the code to make changes, the other operations are consistent.

Let's talk about a few of the localization settings that involve multiple languages:

1. Localized app Name

2. Localizing strings (text)

3. Localize images, materials

4. Localization Storyboard (XIB)

!! The key points above are nonsense:

Here is the configuration based on the current device language automatically switch the display of the steps, do not map, do not explain why:

1. Configuration Engineering supports multiple languages

Select Item->project (default is check targets, toggle)->info->localizations-> Set the multilanguage environment

2. Internationalized Application Name

(1) Create the infoplist.string and make the localization configuration:

Click on new File-->resource-->strings File in the project and rename to Infoplist--> click Create.

Check infoplist.strings-> in the right sidebar of Xcode to find localization-> in localization midpoint "+" to configure. (If not, click Xcode->view->utilities->file Inspector)

(2) Add attributes:

Enter the following code in the corresponding infoplist.string file:

Cfbundledisplayname = "Multi-language test";

Note: Cfbundledisplayname does not add double quotation marks, "Multi-language test" is the corresponding application name.

(3) Edit info.plist:

Open Info.plist, add a new property application has localized display name, set its type to Boolean, and set its value to Yes

3. Internationalized Text

(1) Create the Localizable.strings file (must be the name, whether the method is not the same) and make the localization configuration.

(2) Add Key=value to the localizable.strings of the corresponding language, string (key in each language file is the same)

(3) Use Nslocalizedstring (< #key #>, < #comment #>) in the code to read the localized string.

Note: If your strings file name is not localizable but custom, such as Wang.strings, then you have to use nslocalizedstringfromtable (key, @ "Wang", nil) To read the localized string, the middle one is the @ "Wang" file name.

* Multi-language text can also contain variable content: obtained through the following code:

NSString *string = [NSString localizedstringwithformat:nslocalizedstring (@ "Password error%ld times, can also input%ld times", nil), 2, 1];

4. International images

There are two ways of doing this:

(1) Specify different picture names in localizable.strings of different languages, get different picture names after nslocalizedstring () to display different pictures (this is the international text that)

(2) According to the internationalization of the application name and text to the picture marked two different languages display (but the picture in the Images.xcassets, there seems to be no place to choose the international language)

5. Internationalization Storyboard: (not recommended)

In the 1th step of the configuration of the project multiple languages will be prompted to include the changed files, which have storyboard, select. This will cause a base file and language file to appear.

But one problem is that after you change the controls in the SB, the content in the language pack does not change, so our operation is temporarily unsupported by the internationalized sb.

Refer to the above section: http://blog.csdn.net/wangqiuyun/article/details/7875442



Wen/cocoawmm (author of Jane's book)
Original link: http://www.jianshu.com/p/2b7743ae9c90
Copyright belongs to the author, please contact the author to obtain authorization, and Mark "book author".

"Go" iOS Multi-language localization (internationalization) settings

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.