diff --git a/cocos2dx/platform/CCCommon.h b/cocos2dx/platform/CCCommon.h index 0ac1f5b754..064d870ab5 100644 --- a/cocos2dx/platform/CCCommon.h +++ b/cocos2dx/platform/CCCommon.h @@ -64,7 +64,8 @@ typedef enum LanguageType kLanguageGerman, kLanguageSpanish, kLanguageRussian, - kLanguageKorean + kLanguageKorean, + kLanguageJapanese } ccLanguageType; // end of platform group diff --git a/cocos2dx/platform/android/CCApplication.cpp b/cocos2dx/platform/android/CCApplication.cpp index 2d2a76047a..44b0491f74 100644 --- a/cocos2dx/platform/android/CCApplication.cpp +++ b/cocos2dx/platform/android/CCApplication.cpp @@ -112,6 +112,10 @@ ccLanguageType CCApplication::getCurrentLanguage() { ret = kLanguageKorean; } + else if (0 == strcmp("ja", pLanguageName)) + { + ret = kLanguageJapanese; + } return ret; } diff --git a/cocos2dx/platform/blackberry/CCApplication.cpp b/cocos2dx/platform/blackberry/CCApplication.cpp index 5efe65864c..9744a0bcaf 100644 --- a/cocos2dx/platform/blackberry/CCApplication.cpp +++ b/cocos2dx/platform/blackberry/CCApplication.cpp @@ -147,10 +147,14 @@ ccLanguageType CCApplication::getCurrentLanguage() { ret_language = kLanguageRussian; } - else if (strcmp(language, "ko") == 0) + else if (strcmp(language, "ko") == 0) { ret_language = kLanguageKorean; } + else if (strcmp(language, "ja") == 0) + { + ret_language = kLanguageJapanese; + } free(language); free(country); diff --git a/cocos2dx/platform/ios/CCApplication.mm b/cocos2dx/platform/ios/CCApplication.mm index 56233311d3..e92448dd75 100644 --- a/cocos2dx/platform/ios/CCApplication.mm +++ b/cocos2dx/platform/ios/CCApplication.mm @@ -107,6 +107,9 @@ ccLanguageType CCApplication::getCurrentLanguage() else if ([languageCode isEqualToString:@"ko"]){ ret = kLanguageKorean; } + else if ([languageCode isEqualToString:@"ja"]){ + ret = kLanguageJapanese; + } return ret; } diff --git a/cocos2dx/platform/linux/CCApplication.cpp b/cocos2dx/platform/linux/CCApplication.cpp index 86c2352c02..823f2712a4 100644 --- a/cocos2dx/platform/linux/CCApplication.cpp +++ b/cocos2dx/platform/linux/CCApplication.cpp @@ -100,8 +100,56 @@ CCApplication* CCApplication::sharedApplication() ccLanguageType CCApplication::getCurrentLanguage() { - //TODO - return kLanguageEnglish; + char *pLanguageName = getenv("LANG"); + ccLanguageType ret = kLanguageEnglish; + if (!pLanguageName) + { + return kLanguageEnglish; + } + strtok(pLanguageName, "_"); + if (!pLanguageName) + { + return kLanguageEnglish; + } + + if (0 == strcmp("zh", pLanguageName)) + { + ret = kLanguageChinese; + } + else if (0 == strcmp("en", pLanguageName)) + { + ret = kLanguageEnglish; + } + else if (0 == strcmp("fr", pLanguageName)) + { + ret = kLanguageFrench; + } + else if (0 == strcmp("it", pLanguageName)) + { + ret = kLanguageItalian; + } + else if (0 == strcmp("de", pLanguageName)) + { + ret = kLanguageGerman; + } + else if (0 == strcmp("es", pLanguageName)) + { + ret = kLanguageSpanish; + } + else if (0 == strcmp("ru", pLanguageName)) + { + ret = kLanguageRussian; + } + else if (0 == strcmp("ko", pLanguageName)) + { + ret = kLanguageKorean; + } + else if (0 == strcmp("ja", pLanguageName)) + { + ret = kLanguageJapanese; + } + + return ret; } NS_CC_END diff --git a/cocos2dx/platform/mac/CCApplication.mm b/cocos2dx/platform/mac/CCApplication.mm index 8c2a985d25..266495d311 100755 --- a/cocos2dx/platform/mac/CCApplication.mm +++ b/cocos2dx/platform/mac/CCApplication.mm @@ -113,6 +113,9 @@ ccLanguageType CCApplication::getCurrentLanguage() else if ([languageCode isEqualToString:@"ko"]){ ret = kLanguageKorean; } + else if ([languageCode isEqualToString:@"ja"]){ + ret = kLanguageJapanese; + } return ret; } diff --git a/cocos2dx/platform/marmalade/CCApplication.cpp b/cocos2dx/platform/marmalade/CCApplication.cpp index 94e4d6e485..ce32d9473b 100644 --- a/cocos2dx/platform/marmalade/CCApplication.cpp +++ b/cocos2dx/platform/marmalade/CCApplication.cpp @@ -177,6 +177,10 @@ ccLanguageType CCApplication::getCurrentLanguage() currentLanguage = kLanguageKorean; break; + case S3E_DEVICE_LANGUAGE_JAPANESE: + currentLanguage = kLanguageJapanese; + break; + default: currentLanguage = kLanguageEnglish; break; diff --git a/cocos2dx/platform/win32/CCApplication.cpp b/cocos2dx/platform/win32/CCApplication.cpp index e46a242859..1bee37baa1 100644 --- a/cocos2dx/platform/win32/CCApplication.cpp +++ b/cocos2dx/platform/win32/CCApplication.cpp @@ -139,6 +139,9 @@ ccLanguageType CCApplication::getCurrentLanguage() case LANG_KOREAN: ret = kLanguageKorean; break; + case LANG_JAPANESE: + ret = kLanguageJapanese; + break; } return ret; diff --git a/samples/TestCpp/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp b/samples/TestCpp/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp index 0ef3d20c89..6c2f8d5459 100644 --- a/samples/TestCpp/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp +++ b/samples/TestCpp/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp @@ -33,9 +33,12 @@ CurrentLanguageTest::CurrentLanguageTest() case kLanguageSpanish: labelLanguage->setString("current language is Spanish"); break; - case kLanguageKorean: + case kLanguageKorean: labelLanguage->setString("current language is Korean"); break; + case kLanguageJapanese: + labelLanguage->setString("current language is Japanese"); + break; } addChild(labelLanguage); diff --git a/tools/tolua++/CCApplication.pkg b/tools/tolua++/CCApplication.pkg index 3f283ab186..ce2185e656 100644 --- a/tools/tolua++/CCApplication.pkg +++ b/tools/tolua++/CCApplication.pkg @@ -7,7 +7,9 @@ typedef enum LanguageType kLanguageItalian, kLanguageGerman, kLanguageSpanish, - kLanguageRussian + kLanguageRussian, + kLanguageKorean, + kLanguageJapanese } ccLanguageType; enum TargetPlatform