IOS app Localization

Source: Internet
Author: User

Because iPhone, iPad, and other Apple products are widely used all over the world, users who download applications through app store will also be from all over the world, therefore, developers are bound to consider the use of users in different language environments during the development process. Fortunately, IOS has a robust localization architecture, you can use it to easily translate applications into multiple languages.

 
There are two common approaches for multilingual applications:

1. The program provides users with the opportunity to select their own language;
2. The app is automatically switched to the corresponding language based on the current language of the mobile device of the current user. The following two items need to be set in the settings: Language) and region format (Region format ).

The first approach is relatively simple and fully depends on your own. Here we will focus on the second approach, mainly including the following points:

1. localized application name ------ infoplist. plist

2. localized string ----- localizable. Strings
3. localized image files
4. localized storyboard file ----- mainstoryboard. storyboard

1. Application localization steps:

(1) first, add the above localized elements to the project, that is, add the above files to the project according to the project's needs. Generally, you need to add string files and image files, the other two projects have been automatically created.

  • Add the string file localizable. Strings (select strings file in resource). Note that the file name must be localizable.
  • It's easy to add an image file -- add file.

(2) then localize the newly added projects respectively.

(3) Add a language and select the content to be localized.



(4) The basic xoode operation is complete.




2. Edit These localization-related files.


(1) The first step is to set the application name, which needs to be added to the infoplist. plist file.

Cfbundledisplayname =
"Application name ";

(2) then the local string is added to the localizable. Strings file (all key-value pairs)

As follows:

/* The number 5 */"LABEL_FIVE" = "Five";/* The number 4 */"LABEL_FOUR" = "Four";/* The number 1 */"LABEL_ONE" = "One";/* The number 3 */"LABEL_THREE" = "Three";/* The number 2 */"LABEL_TWO" = "Two";

(3) Localized image files

The localization of image files is generally to replace files directly in the finder.

(4) Localized storyboard files

The localization of this part is quite diverse. For example, this demo selects different national flags.

This method is widely used in program localization.

NSString *NSLocalizedString(NSString *key, NSString *comment)

Obtain the value in the string file by using the key. Comment is only an interpreted string, indicating the meaning and content of the string. It can be set to nil.

This part of content is relatively simple, with a small demo

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.