More simple and correct way to detect language for win32 application, also added detection of all languages contained in ccLanguageType enumeration .

Added support for detect russian language.
This commit is contained in:
moadib 2011-10-12 09:32:59 +04:00
parent 66b20d7f7d
commit 5feee662e7
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;
}