手机中文和英文模式识别

+ (NSString *)getLanguage {

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

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

NSString *preferredLang = [allLanguages objectAtIndex:0];

return preferredLang;

}

+ (BOOL)languageIsChinese {

BOOL isChinese = NO;

NSString *language = [self getLanguage];

if ([language rangeOfString:@"zh-Hans"].location != NSNotFound ||

[language rangeOfString:@"zh-Hant"].location != NSNotFound ||

[language rangeOfString:@"zh-TW"].location != NSNotFound ||

[language rangeOfString:@"zh-HK"].location != NSNotFound)

isChinese = YES;

return isChinese;

}

你可能感兴趣的:(手机中文和英文模式识别)