Xcode4 localized multi-language

Source: Internet
Author: User

1 xcode4.2, if it is simplified Chinese, put the international files in the zh-Hans.lproj shows normal. It cannot be placed in Zh. lproj.

 

2 string

1) Right-click "new file" in the "supporting files" directory of the project and select the IOS resource item on the left side of the pop-up window. The "string file" icon is displayed on the right. Create this file. The new file name must be "localizable. Strings"

2) click the file you just created, and some attribute information will be displayed on the right of "View"-"utilities"-"file inspect" in the menu.

3) Find the localization option. It should be empty now. Click "+" to add the domain name to the international market. Because I only made Chinese and English, I added "English" and "Chinese". Note that "Chinese" should be selected "zh_hans", which is simplified Chinese.

4) after adding, you can see that your project directory will generate the corresponding directory, the zh-Hans.lproj and EN. lproj directory is localizable. Strings File

5) in the project, you can see a triangle icon on the left side of the previously created localizable. Strings file. After you click it, two files, one Chinese file and one English file, will be expanded. Click Edit for each file.

6) The format of the file is "key" = "value"; the semicolons must all be in English.

7) when the program needs to use an international string, call nslocalizedstring (@ "key", nil) to display the string. The first string is the key in the file, and the second string can be replaced by nil or some comments can be written.

 

3. Application name

1) Create an empty file named infoplist. Strings. The general program will automatically produce this file.

2) perform infoplist. Strings. Click infoplist. Strings. Select View> utilities> file inspect ". Click the + plus sign under the Localization Option

Add the Chinese (zh-Hans) type to simplified Chinese. English should be added automatically. In infoplish. Strings, there will be two more Chinese-English files.

3) in this English version. Edit different infoplist. Strings files and set the display name

Cfbundledisplayname = "name ";

4) EDIT info. plist, add a new property application has localized display name, set its type to boolean, and set its value to the selected status.

Summarize these

 

4. Nib files and Images

First, the image cannot be directly localized. After the NIB file is localized, the corresponding image localization process is similar.

Localized nib files. 1) Click the NIB file and select "View"-"utilities"-"file inspect". Some attribute information is displayed on the right. Or press the shortcut key command + Option + 1.

Under the Localization Option, click the + plus sign to add Simplified Chinese (zh-Hans. English should be added automatically.

 

Localized images. Only after the NIB file is localized can the image be localized. 2) Click the image.

Select "View"-"utilities"-"file inspect", and some attributes are displayed on the right. Or press the shortcut key command + Option + 1.

Under the Localization Option, click the + plus sign to add Simplified Chinese (zh-Hans. English should be added automatically.

Reference: http://www.cocoachina.com/newbie/basic/2012/0109/3845.html

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.