我需要将我的默认(后备)语言设置为从英语到非英语。 例如我支持3种语言,例如en,fr,gr。现在如果用户选择中文,那么用户应该用fr语言显示。请帮我 。 我试过这段代码
self.strLanguage = [[NSLocale preferredLanguages] objectAtIndex:0];
NSLog(@"strLanguage : %@",self.strLanguage);
NSMutableArray *arraySupportedLanguages = [[NSMutableArray alloc] initWithObjects:@"en",@"fr",@"gr", nil];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@", self.strLanguage];
arraySupportedLanguages = [[arraySupportedLanguages filteredArrayUsingPredicate:predicate]mutableCopy];
NSLog(@"arraySupportedLanguages : %@",arraySupportedLanguages);
if (arraySupportedLanguages.count == 0) {
[[NSUserDefaults standardUserDefaults] setObject:@"nl" forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults]synchronize];
}