Here's how I modified cocos2d-x code to distinguish simplified and traditional Chinese. Note, this is for cocos2d-x v3.0+.
For iOS, modify cocos2d_libs.xcodeproj/platform/ios/CCApplication-ios.mm
LanguageType Application::getCurrentLanguage()
{
// get the current language and country config
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
NSString *currentLanguage = [languages objectAtIndex:0];
// 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];
LanguageType ret = LanguageType::ENGLISH;
if ([languageCode isEqualToString:@"zh"])
{
/** CHANGE THE FOLLOWING LINES */
NSString* scriptCode = [temp objectForKey:NSLocaleScriptCode];
NSString* countryCode = [temp objectForKey:NSLocaleCountryCode];
// On iOS, either chinese hong kong or chinese taiwan are traditional chinese.
if ([scriptCode isEqualToString:@"Hant"] || [countryCode isEqualToString:@"HK"] || [countryCode isEqualToString:@"TW"]) {
ret = LanguageType::CHINESE_TRADITIONAL; // You need to add these enum values to LanguageType
} else {
ret = LanguageType::CHINESE_SIMPLIFIED; // You need to add these enum values to LanguageType
}
}
else if ([languageCode isEqualToString:@"en"])
{
ret = LanguageType::ENGLISH;
}
.....
.....
For Android , modify cocos2d/cocos/platform/android/CCApplication-android.cpp
LanguageType Application::getCurrentLanguage()
{
std::string languageName = getCurrentLanguageJNI();
const char* pLanguageName = languageName.c_str();
const char* languageCode = getCurrentLanguageCode();
LanguageType ret = LanguageType::ENGLISH;
if (0 == strcmp("zh", languageCode))
{
/** Change the following lines */
if (languageName.find("TW") != std::string::npos) {
ret = LanguageType::CHINESE_TRADITIONAL;
} else {
ret = LanguageType::CHINESE_SIMPLIFIED;
}
}
else if (0 == strcmp("en", languageCode))
{
ret = LanguageType::ENGLISH;
}
else if (0 == strcmp("fr", languageCode))
.....
.....
and also modify libcocos2d/org/cocos2dx/lib/Cocos2dxHelper.java
public static String getCurrentLanguage() {
// This would return language code as well as region code, e.g. zh_CN
return Locale.getDefault().toString();
}