Localization (internationalization)

Source: Internet
Author: User

1. Localization (internationalization)

To solve the same app, display the content of the corresponding language in different languages of the device.

The implementation of localization can be divided into "visualization", "Pure Code" two ways.

visualize the way:

> Click on the project name, under the info (note under Project, not targets), under the Localizations column, add the language

> Click Xib or Storyboard, select File Inspector (first tab) in the rightmost section, select Language under Localization, and you will find that the original Xib,storyboard file will automatically create the file in the corresponding language.

> in Xib,storyboard files in different languages, set the text of the view.

Pure Code Mode :

> Add the Localizable.strings file under the project directory, note that the name must be localizable, otherwise it cannot be localized .

> Localize this file, select the file, and add the language under File Inspector->localization

> Add the following format in different language versions of this file: "a1" = "abc"; Note that you have to take a semicolon, otherwise parse the error, and the name A1 in two files.

> in code lb.text = nslocalizedstring (@ "A1", nil)

In the actual development process, two ways to use, because different languages because of the different types of space occupied by different, resulting in the size of the control will vary, sometimes need to adjust in the interface file.

2. Application name localization

> Add Bundle display name to Info.plist

> Right-click on Show Raw keys/values (native underlying key value) in Info.plist file blank

> Copy the Cfbundledisplayname (corresponding Bundle display name)

> New infoplist.strings file, [note name, otherwise cannot localize], and localize this file, select the file, add the language under File Inspector->localization

> Add content in the following format in different language versions of this file: Cfbundledisplayname = "MyApp";

3. The application dynamically obtains the data localization, because these content is generally obtains by the network access, the different language content is provided by the server, the app only needs to provide the current device the language to the server, the server returns the content of the given language.

> Get the language of your device

[Nslocale Preferredlanguages]//Language preference list, the first one is the device's current language

Localization (internationalization)

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.