1. In project settings, join Chinese and English in two languages:
2. Create a new localizable.strings file, as a multilingual dictionary, store multiple languages, click on the right side of the localization, check the English:
3. Add a field,
In 中文版, add: "submit_btn_title" = "Go";
In Chinese, add: "submit_btn_title" = " start ";
4. A tool class Gdlocalizablecontroller. To switch the local language:
gdlocalizablecontroller.h//guide-book////Created on 7/16/14.//Copyright (c). All rights reserved.//#import <Foundation/Foundation.h> @interface gdlocalizablecontroller:nsobject+ (nsbundle *) bundle;//get current resource file + (void) inituserlanguage;//initialization language file + (NSString *) userlanguage;//get app current language + (void) setuserlanguage :(NSString *) language;//set the current language @end////gdlocalizablecontroller.m//guide-book////Created by what on 7/16/14.//Copyrig HT (c). All rights reserved.//#import "GDLocalizableController.h" @implementation gdlocalizablecontrollerstatic nsbundle * Bundle = nil;+ (NSBundle *) bundle{return bundle;} + (void) inituserlanguage{nsuserdefaults *def = [Nsuserdefaults standarduserdefaults]; NSString *string = [def valueforkey:@ "Userlanguage"]; if (String.Length = = 0) {//Get the System current language version number nsarray* languages = [def objectforkey:@ "Applelanguages"]; NSString *current = [languages objectatindex:0]; string = current; [Def SetvAlue:current forkey:@ "Userlanguage"]; [Def synchronize];//persistent. No words will not be saved}//Get file path nsstring *path = [[NSBundle mainbundle] pathforresource:string oftype:@ "Lproj"]; bundle = [NSBundle bundlewithpath:path];//generate bundle}+ (NSString *) userlanguage{nsuserdefaults *def = [NSUserDefaults Standarduserdefaults]; NSString *language = [def valueforkey:@ "Userlanguage"]; return language;} + (void) Setuserlanguage: (NSString *) language{nsuserdefaults *def = [Nsuserdefaults standarduserdefaults]; 1. The first step changes the value of the bundle nsstring *path = [[NSBundle mainbundle] pathforresource:language oftype:@ "Lproj"]; bundle = [NSBundle Bundlewithpath:path]; 2. Persistence [def setvalue:language forkey:@ "Userlanguage"]; [Def synchronize];} @end
5. Define a macro yourself for easy handling:
-----Multi-language Set # define Chinese @ "Zh-hans" #define English @ "en" #define gdlocalizedstring (key) [[Gdlocalizablecontroller BUNDLE] Localizedstringforkey: (key) value:@ "" Table:nil]
6. Use:
[Gdlocalizablecontroller Setuserlanguage:chinese]; NSLog (Gdlocalizedstring (@ "Submit_btn_title")); [Gdlocalizablecontroller Setuserlanguage:english]; NSLog (Gdlocalizedstring (@ "Submit_btn_title"));
Reference: Internationalization within IOS apps, no trailing system language
[iOS] How to switch display language in iOS development for internationalization