Merge pull request #8646 from huangshiwu/v3_languagecode

fix bug that Application::getCurrentLanguageCode on ios and mac always r...
This commit is contained in:
minggo 2014-10-11 16:23:49 +08:00
commit c01d1b1166
3 changed files with 10 additions and 2 deletions

View File

@ -88,7 +88,7 @@ const char * Application::getCurrentLanguageCode()
// get the current language code.(such as English is "en", Chinese is "zh" and so on)
NSDictionary* temp = [NSLocale componentsFromLocaleIdentifier:currentLanguage];
NSString * languageCode = [temp objectForKey:NSLocaleLanguageCode];
[languageCode getCString:code maxLength:2 encoding:NSASCIIStringEncoding];
[languageCode getCString:code maxLength:3 encoding:NSASCIIStringEncoding];
code[2]='\0';
return code;
}

View File

@ -144,7 +144,7 @@ const char * Application::getCurrentLanguageCode()
// get the current language code.(such as English is "en", Chinese is "zh" and so on)
NSDictionary* temp = [NSLocale componentsFromLocaleIdentifier:currentLanguage];
NSString * languageCode = [temp objectForKey:NSLocaleLanguageCode];
[languageCode getCString:code maxLength:2 encoding:NSASCIIStringEncoding];
[languageCode getCString:code maxLength:3 encoding:NSASCIIStringEncoding];
code[2]='\0';
return code;
}

View File

@ -8,6 +8,13 @@ CurrentLanguageTest::CurrentLanguageTest()
auto labelLanguage = Label::createWithTTF("", "fonts/arial.ttf", 20);
labelLanguage->setPosition(VisibleRect::center());
auto labelLanguageCode = Label::createWithTTF("", "fonts/arial.ttf", 20);
labelLanguageCode->setPosition(VisibleRect::center().x, VisibleRect::center().y-50);
const char* currentLanguageCode = Application::getInstance()->getCurrentLanguageCode();
labelLanguageCode->setString(currentLanguageCode);
LanguageType currentLanguageType = Application::getInstance()->getCurrentLanguage();
switch (currentLanguageType)
@ -63,6 +70,7 @@ CurrentLanguageTest::CurrentLanguageTest()
}
addChild(labelLanguage);
addChild(labelLanguageCode);
}
void CurrentLanguageTestScene::runThisTest()