1.定义语言切换宏定义
#define NSLocalizedString(key, comment) \
(([[[NSLocale preferredLanguages] objectAtIndex:0] isEqual:@"zh-Hans-CN"]||[[[NSLocale preferredLanguages] objectAtIndex:0] hasPrefix:@"zh-Hans"])?([[NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"zh-Hans" ofType:@"lproj"]] localizedStringForKey:key value:@"" table:nil]):([[NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"en" ofType:@"lproj"]] localizedStringForKey:key value:@"" table:nil]))
2.调用改函数适应不同语言
NSArray*weekArray =@[NSLocalizedString(@"Sun",@""),NSLocalizedString(@"Mon",@""),NSLocalizedString(@"Tues",@""),NSLocalizedString(@"Wed",@""),NSLocalizedString(@"Thur",@""),NSLocalizedString(@"Fri",@""),NSLocalizedString(@"Sat",@"")];
3.新建不同语言配置文件
4.在对应的语言文件中填写翻译的键值
英文的
5.中文的
网友评论