Internationalization of iOS Apps

Source: Internet
Author: User

The original address http://www.jianshu.com/p/63a1c1a40b93http://www.cocoachina.com/ios/20151120/14258.html, procedure internationalization preparation work:

1, first we have to create a project, we give him the name Internationalization-demo, and then add the language.


To detach text from your code:

Currently, all the text shown in the app is in Main.storyboard and viewcontroller with hard-coded strings. In order to localize these strings, you need to put them in a separate file. Instead of hard-coding in your method, he will simply refer to these strings in the package.
Xcode uses files with the. strings extension to store and retrieve all the strings used in the app to support each language. Depending on the language currently used by the iOS device, a simple method call in the code will find and return the required string.

2. Create a file with a. strings extension
Open File > New > File, select Strings Fils in Resource,
Click Next, name the file infoplist.strings, and then click Save.



3. After creation, you can see the project directory structure file as follows, click Infoplist.strings, view the properties on the right, and add the language in the localizable bar.



4. After adding, open the corresponding language files, such as
Add to 中文版:
Cfbundledisplayname = "Hello World";

Additions to the Chinese:
Cfbundledisplayname = "Hello World";



5, run, if your simulator is in Chinese, you will see your program name into the world Hello



Set the language to English in the settings and you will see your program name turned into Hello World


Ii. Internationalization of content

1. Create a new Localizable.strings file (Localizable.strings is the system default name)
2. Add language Ibid.
3. Add language content
In Localization.strings, follow the format of "key" = "value" and then use Nslocalizedstring (@ "key", @ "") to read the contents; If it is not used with the system default name
Localization.strings 中文版 File added
"Key" = "Hello World"

Localization.strings Chinese file added
"Key" = "Hello World"




Wen/R (Jane book author)
Original link: http://www.jianshu.com/p/63a1c1a40b93
Copyright belongs to the author, please contact the author to obtain authorization, and Mark "book author".

Internationalization of iOS apps

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.