Merge pull request #545 from moadib/detect_russian_language

More simple and correct way to detect language for win32 application
This commit is contained in:
Walzer 2011-10-11 23:26:13 -07:00
commit ea2a428a57
4 changed files with 32 additions and 14 deletions

View File

@ -62,6 +62,7 @@ typedef enum LanguageType
kLanguageItalian,
kLanguageGerman,
kLanguageSpanish,
kLanguageRussian
} ccLanguageType;
NS_CC_END;

View File

@ -105,6 +105,10 @@ ccLanguageType CCApplication::getCurrentLanguage()
{
ret = kLanguageSpanish;
}
else if (0 == strcmp("ru", pLanguageName))
{
ret = kLanguageRussian;
}
return ret;
}

View File

@ -138,6 +138,9 @@ ccLanguageType CCApplication::getCurrentLanguage()
else if ([languageCode isEqualToString:@"es"]){
ret = kLanguageSpanish;
}
else if ([languageCode isEqualToString:@"ru"]){
ret = kLanguageRussian;
}
return ret;
}

View File

@ -127,22 +127,32 @@ CCApplication& CCApplication::sharedApplication()
ccLanguageType CCApplication::getCurrentLanguage()
{
int arrayChineseCode[] = {
2052, 4100, 1028, 3076, 5124
};
LCID LanguageID = GetUserDefaultLCID();
ccLanguageType ret = kLanguageEnglish;
int nCount = sizeof(arrayChineseCode) / sizeof(int);
for (int i = 0; i < nCount; ++i)
{
if (arrayChineseCode[i] == LanguageID)
{
ret = kLanguageChinese;
break;
}
}
LCID localeID = GetUserDefaultLCID();
unsigned short primaryLanguageID = localeID & 0xFF;
switch (primaryLanguageID)
{
case LANG_CHINESE:
ret = kLanguageChinese;
break;
case LANG_FRENCH:
ret = kLanguageFrench;
break;
case LANG_ITALIAN:
ret = kLanguageItalian;
break;
case LANG_GERMAN:
ret = kLanguageGerman;
break;
case LANG_SPANISH:
ret = kLanguageSpanish;
break;
case LANG_RUSSIAN:
ret = kLanguageRussian;
break;
}
return ret;
}