The perfect solution for IOS multi-lingual localization

Source: Internet
Author: User

Multi-lingual localization is often used when we do iOS projects, the following are based on their own experience and use of the scene, to fully speak the multi-lingual localization of the solution.

First, we need to understand the principle and process of localization, in order to better understand the localization of the solution, localization mainly includes the following parts:

  • Localized application name
  • Localized strings
  • Localized images
  • Localizing Other files

First, localized application name, this only one scenario:

      • Click "New File" and select the iOS resource item on the left side of the popup window, and on the right you will see the "String File" icon. Create this file, named "Infoplist" (which must be the file name) to generate a infoplist.strings file;
      • Select Infoplist.strings Click Xcode-> view-> Utilities, File Inspector, in the localization midpoint "+", add Chinese (Zh-hans) type for Simplified Chinese, 中文版 should be added automatically. Then on the left side of the infoplish.strings will be a more triangle, click to expand can see Infoplish.strings (English) and Infoplish.strings (Chinese) Two versions of the file;
      • In the Infoplish.strings (中文版) file, add:
      • Cfbundledisplayname = "program"; Where "program" is the English application name, in the same vein in the Infoplish.strings (Chinese) file, add:
      • Cfbundledisplayname = "Application"; Where "Application" is the Chinese name, note: Cfbundledisplayname plus no double quotation marks are OK
      • Edit Info.plist, add a new property application has localized display name, set its type to Boolean, and set its value to Yes

Two, localized strings and localized images of the solution has the following two kinds:

      • Program to provide users with their own choice of opportunities, users can use buttons and other ways of their own switching language, and the current system of language is not related;
      • Automatically switches our app to the language based on the language of the current user's current mobile device.

The first approach seems to be relatively simple, then actually want to flexible implementation also need a little thought, the concrete implementation method is as follows:

 

  • Create multiple strings files, names cannot be used with localizable.strings.
  • multiple strings files, such as english.strings/chinese.strings/german.strings, and so on.
  • the contents and wording in each file are similar to localizable.strings.
  • How to use: Nslocalizedstringfromtable (@ "Start", @ "Chinese",  nil)  .
  • According to the actions of the user, To update the multi-language display of the page.
  • picture localization, Different languages to get different picture names can be.  

The second approach, the main points of the points:

  • Like the first step of "Localizing Application Name", click "New File" and select the iOS resource item on the left side of the pop-up window, and you will see the "String File" icon on the right. Create this file, named "Localizable" (must be this file name otherwise the call will have some difference) to generate a localizable.strings file;
  • Similar to "Localized application name" in the second third step, add the following in the Localizable.strings (中文版) file:
  • "Welcome" = "Click on the screen to continue ...";

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

    "Welcome" = "click on screen to continue ..."; Use Nslocalizedstring (< #key #>, < #comment #>) in your code to read the localized string.

Note: Images are localized, and the names of the images in different languages are the same, but they are placed in a different language folder.

Iii. Localization of other documents

Localizing other files and localizing images The second method is similar to adding a language in localization and then copying the corresponding version into the en.lproj and Zh-hans.lproj folders, and the last reference is OK.

The perfect solution for IOS multi-lingual localization

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.