Iphone app 国际化

获取localization   语言

 

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

NSArray *languages = [defaults objectForKey:@"AppleLanguages"];

NSLog(@"%@, %@",languages,NSLocalizedString(@"xxx"));

 

 

Resources---右键---new file ---(String files or empty file)命名为: Localizable.strings --右键 get info --- make file localizable 添加对应语言的localization

 

1:Localizable.strings:(针对字符串  NSLocalizedString)

在对应的zh-hans和English文件添加:

"xxx"="本地字符串";

"yyy"="本地字符串";

 

 

2:InfoPlist.strings:(针对app名称)

在对应的zh-hans和English文件添加:

CFBundleName="本地名";

CFBundleDisplayName="本地名";

 

 

注意一定要加“;”,否则报错类似于:/Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copystrings failed with exit code 1;

你可能感兴趣的:(ios,国际化)