获取设备当前语言设置

获取当前设备的语言:

+(NSString *)currentLanguage
{
    NSString *tmpLanguage = [[NSLocale preferredLanguages] objectAtIndex:0];

    if ([tmpLanguage isEqualToString:@"zh-Hans"] ) {
        return @"zh";   //简中
    }
    else if ([tmpLanguage isEqualToString:@"zh-Hant"]) {
        return @"hk"; //繁中
    }
    else if ([tmpLanguage isEqualToString:@"zh-HK"]) {
        return @"hk";
    }
    else if ([tmpLanguage isEqualToString:@"en"]) {
        return @"en";
    }
    else
    {
        return @"en"; //英语
    }
}

判断当前设备的语言环境是不是简体中文:

   //是不是简中
+(BOOL)currentLanguareIsZH
{
    NSString *tmpLanguage = [self currentLanguage];
    if ([tmpLanguage isEqualToString:@"zh"]) {
        return YES;
    }
    return NO;
}

你可能感兴趣的:(零零总总)