智慧 + 毅力 = 无所不能

正确性、健壮性、可靠性、效率、易用性、可读性、可复用性、兼容性、可移植性...

导航

cocos2d-x 判断系统语言

Posted on 2013-07-10 21:35  Bill Yuan  阅读(1484)  评论(0编辑  收藏  举报

转自:http://blog.csdn.net/tangaowen/article/details/8878193

//default language is local language
ccLanguageType currentLanguageType = CCApplication::sharedApplication()->getCurrentLanguage();
switch (currentLanguageType)
{
       case kLanguageEnglish:
                language_ = "english";
                break;
       case kLanguageChinese:
                //判断是否是简体的还是繁体的
                
                //如果是繁体的
                if (isTaiWanChinese() == true)
                {
                    language_ = "zhcnt";
                }
                //是简体的
                else
                {
                    language_ = "zhcn";
                }
                
                break;

        default:
                language_ = "english";
                break;
       }
}

//是否是繁体中文
bool  LanguageManager::isTaiWanChinese()
{
    // get the current language and country config
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
    NSString *currentLanguage = [languages objectAtIndex:0];
    
    if ( [currentLanguage isEqualToString:@"zh-Hant"])
    {
        return  true;
    }
    else
    {
        return  false;
    }
    
}