美文网首页IOS理论知识
手机中文和英文模式识别

手机中文和英文模式识别

作者: IceWall_Rin | 来源:发表于2016-12-29 16:27 被阅读4次

    + (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;

    }

    相关文章

      网友评论

        本文标题:手机中文和英文模式识别

        本文链接:https://www.haomeiwen.com/subject/ktlpvttx.html