Xcode 4.5 IOS multi-language settings

Source: Internet
Author: User
Tags custom name

Turn: http://blog.csdn.net/samuelltk/article/details/8480403

I upgraded to xcode4.5 a few days ago. Now I am using xcode4.5 + ios6 Development Project. When I was using internationalization, I encountered a problem. I created localizable in xcode of the previous version. after strings, the "+" Number of the added language disappeared. After half a day, I did my research and found a solution on stackoverflow, apple changed the "+" number to a place. Next let's take a look at how to use it.

Create a resource file named localizable. Strings

After the file is selected, multiple buttons are displayed in the property selector:

After clicking this button, the international language selection box appears, but there is only one option for English:

It doesn't matter. Continue. Click localize. Only English is supported. In versions earlier than xcode4.5, there will be a "+" number in the attribute selector to add support for other languages. Now it's gone, but it's actually somewhere else. Click the project root directory, select project, and select the info tab. The localizations is displayed at the bottom:

Click "+" and select a language to add. Here I select "Chinese" and "OK". Now, let's look at localizable. the strings file has two more sub-files, which support both English and Chinese:

English and Chinese are also seen in the attribute selector:

In this way, the settings and operations for internationalization on xcode4.5 are completed. The following describes how to use them.

Select the localizable. Strings (English) file and add the following content:

"Loading"="Loading ...";

Select the localizable. Strings (Chinese) file and add the following content:

"Loading"="Loading...";

Note that the content must end with a semicolon; otherwise, it cannot be recognized. ThenCodeUsed in:

Nsstring * loading = nslocalizedstring(@ "Loading",@"");

The system will identify whether to use Chinese or English based on the language environment of the current device. At this point, the international operation on xcode4.5 will be completed.

If the name of The. Strings file is localizable. strings, you can use the following method to call it:

Nslocalizedstring (@"Title", Nil)

The two methods have the same purpose:

    1. Nslog (@ "Local string0: % @", nslocalizedstring (@ "str0", nil ));
    2. Nslog (@ "Local string1: % @", nslocalizedstringfromtable (@ "str1", @ "localizable", nil ));

If the. Strings file is created with a custom name, for example, internation. Strings, the call method is as follows:

Nslocalizedstringfromtable (@ "title", @ "internation", nil );

The nslocalizedstring method does not work after the User-Defined name. Note the following;

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.