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:
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