IOS: Setting up internationalization and localization of apps

Source: Internet
Author: User

Original link: http://www.cocoachina.com/appstore/20160310/15632.html

Objective

There are many ways to set the name of the app, and if you don't make changes when the app is packaged, the name of the app will be the name of Xcode when you set up the project. The good habit is to use English (pinyin) when the project is built, then the app is the name of "English", although Xcode also supports naming projects directly in Chinese (even the method name ...). ), but sometimes it can cause some unnecessary trouble and even inexplicable bugs.
This article mainly introduces two methods of setting the name of the app, the first one is simpler, the second involves the simple version internationalization and localization (Localization) problem. The author of the two methods of cognition is also relatively basic, if there is inappropriate, but also look treatise.

1.Bundle Display Name

Let's look at the specific setup steps for this method:

    • Set up the project as follows, if you do not set the app name, the default app name is the project name.

    • Click Project-targets-info, add "Bundle Display Name", string value to fill in the name of the app to be set.

    • Compile again, the effect is as follows, this method is so simple.

There is not much to say, when retrieving app name settings, most of the answers are also this, because it's easier.

Mention the bundle name and bundle display name here:

Bundle Name-is folder name, where your app (including executable file and all resources) would be stored (Cool Program.ap P). We recommend that you do not modify the bundle name
Bundle display Name-is What would be is shown on the iphone screen, that is, when you install the app to the name displayed on the iphone.
Note: Bundle display name must correspond to bundle name, that is, bundle display name and bundle name cannot be too far apart. For example, the bundle name is set to Theapplication, and the bundle display name is set to "gold * * * * * * * * * * *", Apple will reject your app.

2.infoplist.strings->cfbundledisplayname

This method is cumbersome, but can support the multi-language version of the name of the settings, that is, localization, but also see the specific steps:

    • To create a new strings File, the naming should not necessarily be infoplist.strings, it should be a habit.

    • Click Project-project-info-localizations, add Simplified Chinese support, if you want to support traditional, you can continue to add, as well as other languages.

    • Click on the infoplist.strings you created earlier-click "Localizion" on the right-add Simplified Chinese

  can choose to support English

    • Set Chinese and English names separately

"Cfbundledisplayname" = "Chinese name";

"Cfbundledisplayname" = "englishname";

Name string yourself fill it out just a demonstration here

    • Compiling the project

You may need to add the application has localized display name key in the Plist file, set to Yes

Switch the language in the simulator settings to the Chinese and English modes, respectively, to see the changes in the names below APPIOCN:

3. Settings for the default language: Localization native development Region

When Xcode builds the project, the default locale is English, so when some system space is called (such as a camera album), the caption of the control key is displayed in English, and the quick setting is to set the value of localization native development region. Refer to this article for specific steps: Localization native development Region change the first paragraph in the language is invalid.

4. localizations version Internationalization

This is to let the app support multi-lingual environment, the best demo should be the official demo of the Ring letter, here is just a brief introduction to the use:

    1. Same as adding infoplist.strings, add a localizable.strings file

    2. For Chinese and English (other languages to add themselves), add the following statements, respectively:

"Alerttitle"="title";"Alertmessage"="Information";"Alertok"="Confirm";"Alertother"="other"; "Alerttitle"="title";"Alertmessage"="message";"Alertok"="Confirm";"Alertother"=" Other";

Regarding the above key and value, just the demonstration, can be defined by themselves, call these key-value need to use Nslocalizedstring (< #key #>, < #comment #>) system macros, For example: nslocalizedstring (@ "Alerttitle", @ "This is an annotation, according to the case"), the first parameter is a custom key in the strings file, depending on the locale, The system will automatically detect the value of this key (Chinese or English), the second parameter is a comment, for the sake of understanding, can be nil.
Actual Use cases:

- (void) Createalertviewwithtitle: (NSString *) title message: (NSString *) messageDelegate:(ID)DelegateCancel: (NSString *) Cancel Andother: (NSString *) Other {Uialertview* Alert = [[Uialertview alloc] Initwithtitle:title message:messageDelegate:DelegateCancelbuttontitle:cancel Otherbuttontitles:other, nil];  [Alert show]; }  //called[Self createalertviewwithtitle:nslocalizedstring (@"Alerttitle",@"This is an annotation, according to the situation") Message:nslocalizedstring (@"Alertmessage",@"")Delegate: Nil cancel:nslocalizedstring (@"Alertok", nil) andother:nslocalizedstring (@"Alertother", nil)];

Set the language environment of the system to the Chinese and English mode respectively, the effect is as follows:

The above wording seems to be more cumbersome than the habit of writing string to set the title, but commonly used titles can be two times macro definition management, so not only easy to use, but also convenient for unified management.
Take a look at the demonstration in the Ring letter demo:

This article simply introduces the relevant usage, as for the detailed description, you can refer to the article at the end of the reference article, there are a lot of good detailed handouts.

Reference article:

  • Localization native Development Region change language is invalid

  • How to set the default language in iOS

  • Xcode 6 about the internationalization of IOS apps

  • iOS learning iOS program name and content internationalization (localization)

  • How do I change the app name of a completed project?

  • How to modify the project name of the iOS app

  • iOS Modify app Name

  • IOS Xcode How to modify the name of an app

  • How can I change the name of the app display?

  • Bundle name and bundle Display name

  • iOS app internationalization tutorial (version 2014)

IOS: Setting up internationalization and localization of apps

Related Article

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.