[ios开发]判断手机设置语言是否为中文(简体或者繁体)


  NSString *lang;
    if([[self currentLanguage] compare:@"zh-Hans" options:NSCaseInsensitiveSearch]==NSOrderedSame || [[self currentLanguage] compare:@"zh-Hant" options:NSCaseInsensitiveSearch]==NSOrderedSame)
    {
        lang = @"zh";
        NSLog(@"current Language == Chinese");
    }else{
        lang = @"en";
        NSLog(@"current Language == English");

    }


currentLanguage 方法如下:


-(NSString*)currentLanguage
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
    NSString *currentLang = [languages objectAtIndex:0];
    return currentLang;
}


你可能感兴趣的:([ios开发]判断手机设置语言是否为中文(简体或者繁体))