Internationalization of IOS Apps

Source: Internet
Author: User

First, what is the internationalization of the application?

automatically switches our app to the language based on the language of the current user's current mobile device .

For individual developers, the foreign market is more valuable than the domestic market, after all, foreign copyright awareness, pay ideas better.

Second, how to do?

1. Localizing the application name

(1) The application name is set in the Infoplist.strings file, while the localized inofplist.strings (simple Chinese) etc in Xcode 5

You can then only click the plus sign in Project->info-> localizations to add. Operations such as




(2) Click "+" number to select the language you want to use after selecting Chinese

In the Infoplish.strings (中文版) file, add:

Cfbundledisplayname ="program";  

Similarly, in the Infoplish.strings (Chinese) file, add:

Cfbundledisplayname ="Application";
Where "Application" is the Chinese name, "program" is the English name.

Note:cfbundledisplayname does not add double quotes , which are somewhat different from localized strings.

(3) Edit Info.plist, add a new attribute application has localized display name,

Set its type to Boolean and set its value to Yes


2. Localizing strings

(1) Click "New File" and select the iOS resource item on the left side of the popup window, and on the right side you will see the "String File" icon.

Create this file, named "Localizable" (it must be this file name otherwise the call will have some differences) to generate a

Localizable.strings file;

(2) Set the localization properties of the Localizable.strings file, select the file when finished, and select Show in the property selector Inspector

You can see a number of buttons, such as


Note: When you add Chinese in the localized app name, the localized string is also not in Chinese.

A localizable.strings (Chinese) file is automatically added to the localizable.strings after adding Chinese.

(3) in the Localizable.strings (中文版) file, add:

                      "Welcome" Span style= "word-wrap:normal; Word-break:normal ">= " CLICK  on  the   screen  to  continue ... "
               Similarly, in Localizable.strings (Chinese) file:
"Welcome" = "Click on the screen to continue ..." ;

3. Localization Storyboard, Xib

Localized storyboard, Xib, and localized strings are similar, select File to add localization file

Do different processing in different files respectively.


Finally explain nsbundle the next few methods:

#define Nslocalizedstring (key, comment) \
[[NSBundle Mainbundle] Localizedstringforkey: (key) value:@ "" Table:nil]
#define Nslocalizedstringfromtable (Key, tbl, comment) \
[[NSBundle Mainbundle] Localizedstringforkey: (key) value:@ "" Table: (TBL)]
#define NSLOCALIZEDSTRINGFROMTABLEINBUNDLE (Key, TBL, bundle, comment) \
[Bundle Localizedstringforkey: (key) value:@ "" Table: (TBL)]
#define Nslocalizedstringwithdefaultvalue (Key, TBL, bundle, Val, comment) \
[Bundle Localizedstringforkey: (key) Value: (val) Table: (TBL)]

(Key, TBL, bundle, Val, comment)

1.key the string corresponding to the key

The string file name where the strings used by 2.TBL are located. If you ex:abc.strings, enter ABC.

The file directory where the 3.bundle resource strings file resides.

4.val default character.

5.comment comments


Reference Source:

http://blog.csdn.net/a_ss_a/article/details/37996265

Http://www.iliunian.com/2362.html

http://poolo.iteye.com/blog/1983753

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.