IOS Development Learning 35 localization, ios development 35 Localization
Add a new language to open Project-Info-Localizations
Click + add language under Localization
Define multi-language Files add String Files
On Supporting Files, add String Files named Localizable. strings
Set
The settings are displayed as follows:
String Localization
Define Localizable. strings (English)
"welcome"="Welcome";
Define Localizable. strings (Simplified)
"Welcome" = "welcome ";
Call in code:
_lbl.text=NSLocalizedString(@"welcome", nil);
Resource Localization
Select the image to be localized in the storyboard, add chinese (zh-hans) in Localization in File Instpector, and store different versions of images in en. lproj and zh-Hans.lproj respectively.
Get the current language through code
NSArray *languages = [NSLocale preferredLanguages]; NSString *currentLanguage = [languages objectAtIndex:0]; NSLog(@"language is %@",currentLanguage);
IOS switching Language