iOS Project internationalization

Source: Internet
Author: User

Now the development of the project will inevitably encounter the internationalization of processing, the following I understand the internationalization of relevant knowledge points summarized

1 First name the project name, systematic text, such as the name of the program

1. Add language to the project first

2 Add a infoplist.strings file

3. Convert Info.plist to regular key

4, Configuration Infoplist.strings

5 This is done, the name changes after you switch the system language.

--------------------------------------------------------------------------------------------------------------- -----------------------

--------------------------------------------------------------------------------------------------------------- ----------------------

Configure a general internationalization configuration file

1 Add a Localizable.strings file, and then the same action as above, and then in the corresponding different files set different key value

2 and then in the project according to different languages to get the name of the non-pass

Nslocalizedstring (@ "titlename", nil)

This enables the project to be multi-lingual

If you need to switch languages you only need to set the language

// "Zh-hans-us", Chinese //     ////Set language Nsarray *lans = @[@ "en-us"   ];    [[Nsuserdefaults Standarduserdefaults] Setobject:lans forkey: @" applelanguages "];

The project often encounters multi-person development may involve everyone to modify localizable.strings this will be handled poorly may conflict then you can create a strings definition yourself ****.strings

Then, when acquiring the internationalized name, you only need to specify which of the. Strings table gets the line code as follows

Self.bb.text=nslocalizedstringfromtable (@"TitleName"@ "Mine" , nil);

----------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------

Image internationalization Configuration

1 Drag a picture into the project directory, not drag into the Assets.xcassets

Then the same as before, and then look at the table of contents to replace the pictures in the different languages can be adapted to the picture

Then use the code to get a different picture.

NSString *imagename = nslocalizedstring (@ "doctor_start_10", nil);     *image = [UIImage imagenamed:imagename];    Self.img.image=image;

International adaptation complete

iOS Project 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.