mirror of https://github.com/axmolengine/axmol.git
Merge pull request #8646 from huangshiwu/v3_languagecode
fix bug that Application::getCurrentLanguageCode on ios and mac always r...
This commit is contained in:
commit
c01d1b1166
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue