iOS Multi-language settings

Source: Internet
Author: User

Recently the company's projects need to be promoted abroad, so the app needs to add the appropriate language settings, to organize the process of documenting the multi-language settings. If there is a wrong place, welcome the big God to correct you. The following is a detailed description of the setup process:

1. Basic Settings

First step: FirstAdd the required languages in Project Engineering-Ptroject-info

If you click on the "+" sign will pop up the list of available languages, we select the language required to support the project.

Step Two: Create the localizable.strings (?? : Do not change the file name as a dictionary for multilingual resources, store multiple languages

Once created, you need to continue with the following actions:

(1) Select localizable.strings file, click the corresponding Localize in the right column ...

(2) Add the language you want to support in the localization, and tick

The third step, after the above steps, the basic setup is complete, you can set the required language in the localizable.strings. As shown below

Fourth step, set up the corresponding language, you can go to use. Then you can use it as follows

NSString * TempStr = nslocalizedstring (@ "Test_label", nil);

?? :

The above is the corresponding way to create a file call with the name localizable. If you set a custom name, such as Test.strings, it is called as follows:

Nslocalizedstringfromtable ("name", "Test", nil);

2, Storyboard and xib settings

Storyboard and Xib settings are similar to localizable.strings. Point that when we create the localizable.strings corresponding language file, the system automatically generates the corresponding system files of the existing storyboard in the app. For the post-add file, we can select the file, click on the right side of the localize ... and check the corresponding language.

For example, in storyboard and Xib there is a label, it will have an object ID. We can use this ID to set the corresponding language text

However, this recommendation is that all UI interfaces are set to complete before you set up multiple languages. Of course, you can set multiple languages in your code implementation by dragging lines to the control

3, application name and other related permissions multi-language settings

The settings for the application name are basically the same as the steps for several multilingual settings above, except that the file name is infoplist when you create the strings file.

Here in Chinese as an example, set the app name: "Cfbundledisplayname" = "test";

4, the language of the Judgment system

Nsarray *languages =*currentlanguage = [languages Objectatindex:0]; NSLog (@ "%@", currentlanguage);

?? : After setting the app language through [NSBundle bundlewithpath:[[nsbundle Mainbundle] pathforresource:language oftype:@ "Lproj"]] Be sure to remember to reset the window's Rootviewcontroller

All right, here's what iOS is all about.

iOS Multi-language 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.