cocos2d-x获得系统的语言

时间:2023-02-08 15:37:59

获得手机系统的语言cocos2d-x获得系统的语言


    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    CCLabelTTF *label = CCLabelTTF::create("", "Arail", 24);
    label->setPosition(ccp(winSize.width/2, winSize.height/2));
    this->addChild(label);
    
    LanguageType languageType = CCApplication::sharedApplication()->getCurrentLanguage();
    switch (languageType) {
        case kLanguageEnglish:
            label->setString("language is english");
            break;
        case kLanguageChinese:
            label->setString("language is chinese");
            break;
        default:
            break;
    }