Added new language detection scheme that uses NLS data base instead of
hard coded values.
This commit is contained in:
parent
9f6d4bc0be
commit
56f8e274c7
|
@ -9,7 +9,6 @@
|
|||
|
||||
extern BOOL MAIN_MainInit(void);
|
||||
extern void MAIN_WineInit(void);
|
||||
extern int MAIN_GetLanguageID(char*lang, char*country, char*charset, char*dialect);
|
||||
extern void MAIN_ParseDebugOptions(const char *options);
|
||||
|
||||
extern BOOL RELAY_Init(void);
|
||||
|
|
356
misc/main.c
356
misc/main.c
|
@ -177,362 +177,6 @@ void MAIN_ParseDebugOptions( const char *arg )
|
|||
ExitProcess(1);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* MAIN_GetLanguageID
|
||||
*
|
||||
* INPUT:
|
||||
* Lang: a string whose two first chars are the iso name of a language.
|
||||
* Country: a string whose two first chars are the iso name of country
|
||||
* Charset: a string defining the chossen charset encoding
|
||||
* Dialect: a string defining a variation of the locale
|
||||
*
|
||||
* all those values are from the standardized format of locale
|
||||
* name in unix which is: Lang[_Country][.Charset][@Dialect]
|
||||
*
|
||||
* RETURNS:
|
||||
* the numeric code of the language used by Windows (or 0x00)
|
||||
*/
|
||||
int MAIN_GetLanguageID(LPCSTR Lang,LPCSTR Country,LPCSTR Charset,LPCSTR Dialect)
|
||||
{
|
||||
char lang[3]="??", country[3]={0,0,0};
|
||||
char *charset=NULL, *dialect=NULL;
|
||||
int i,j,ret=0;
|
||||
|
||||
if (Lang==NULL) return 0x00;
|
||||
if (Lang[0]) lang[0]=tolower(Lang[0]);
|
||||
if (Lang[1]) lang[1]=tolower(Lang[1]);
|
||||
|
||||
if (Country!=NULL) {
|
||||
if (Country[0]) country[0]=toupper(Country[0]);
|
||||
if (Country[1]) country[1]=toupper(Country[1]);
|
||||
}
|
||||
|
||||
if (Charset!=NULL) {
|
||||
j=strlen(Charset);
|
||||
charset=(char*)malloc(j+1);
|
||||
for (i=0;i<j;i++)
|
||||
charset[i]=toupper(Charset[i]);
|
||||
charset[i]='\0';
|
||||
}
|
||||
|
||||
if (Dialect!=NULL) {
|
||||
j=strlen(Dialect);
|
||||
dialect=(char*)malloc(j+1);
|
||||
for (i=0;i<j;i++)
|
||||
dialect[i]=tolower(Dialect[i]);
|
||||
dialect[i]='\0';
|
||||
} else {
|
||||
dialect = malloc(1);
|
||||
dialect[0] = '\0';
|
||||
}
|
||||
|
||||
#define LANG_ENTRY_BEGIN(x,y) if(!strcmp(lang, x )) { \
|
||||
if (!country[0]) { \
|
||||
ret=MAKELANGID(LANG_##y, SUBLANG_DEFAULT); \
|
||||
goto end_MAIN_GetLanguageID; \
|
||||
}
|
||||
#define LANG_SUB_ENTRY(x,y,z) if (!strcmp(country, x )) { \
|
||||
ret = MAKELANGID( LANG_##y , SUBLANG_##z ); \
|
||||
goto end_MAIN_GetLanguageID; \
|
||||
}
|
||||
#define LANG_DIALECT_ENTRY(x,y) { ret = MAKELANGID(LANG_##x , SUBLANG_##y ); \
|
||||
goto end_MAIN_GetLanguageID; }
|
||||
#define LANG_ENTRY_END(x) ret = MAKELANGID(LANG_##x , SUBLANG_DEFAULT); \
|
||||
goto end_MAIN_GetLanguageID; \
|
||||
}
|
||||
|
||||
/*x01*/ LANG_ENTRY_BEGIN( "ar", ARABIC )
|
||||
LANG_SUB_ENTRY( "SA", ARABIC, ARABIC)
|
||||
LANG_SUB_ENTRY( "IQ", ARABIC, ARABIC_IRAQ )
|
||||
LANG_SUB_ENTRY( "EG", ARABIC, ARABIC_EGYPT )
|
||||
LANG_SUB_ENTRY( "LY", ARABIC, ARABIC_LIBYA )
|
||||
LANG_SUB_ENTRY( "DZ", ARABIC, ARABIC_ALGERIA )
|
||||
LANG_SUB_ENTRY( "MA", ARABIC, ARABIC_MOROCCO )
|
||||
LANG_SUB_ENTRY( "TN", ARABIC, ARABIC_TUNISIA )
|
||||
LANG_SUB_ENTRY( "OM", ARABIC, ARABIC_OMAN )
|
||||
LANG_SUB_ENTRY( "YE", ARABIC, ARABIC_YEMEN )
|
||||
LANG_SUB_ENTRY( "SY", ARABIC, ARABIC_SYRIA )
|
||||
LANG_SUB_ENTRY( "JO", ARABIC, ARABIC_JORDAN )
|
||||
LANG_SUB_ENTRY( "LB", ARABIC, ARABIC_LEBANON )
|
||||
LANG_SUB_ENTRY( "KW", ARABIC, ARABIC_KUWAIT )
|
||||
LANG_SUB_ENTRY( "AE", ARABIC, ARABIC_UAE )
|
||||
LANG_SUB_ENTRY( "BH", ARABIC, ARABIC_BAHRAIN )
|
||||
LANG_SUB_ENTRY( "QA", ARABIC, ARABIC_QATAR )
|
||||
LANG_ENTRY_END( ARABIC )
|
||||
/*x02*/ LANG_ENTRY_BEGIN( "bu", BULGARIAN )
|
||||
LANG_ENTRY_END( BULGARIAN )
|
||||
/*x03*/ LANG_ENTRY_BEGIN( "ca", CATALAN )
|
||||
LANG_ENTRY_END( CATALAN )
|
||||
/*x04*/ LANG_ENTRY_BEGIN( "zh", CHINESE )
|
||||
LANG_SUB_ENTRY( "TW", CHINESE, CHINESE_TRADITIONAL )
|
||||
LANG_SUB_ENTRY( "CN", CHINESE, CHINESE_SIMPLIFIED )
|
||||
LANG_SUB_ENTRY( "HK", CHINESE, CHINESE_HONGKONG )
|
||||
LANG_SUB_ENTRY( "SG", CHINESE, CHINESE_SINGAPORE )
|
||||
LANG_SUB_ENTRY( "MO", CHINESE, CHINESE_MACAU )
|
||||
LANG_ENTRY_END( CHINESE )
|
||||
/*x05*/ LANG_ENTRY_BEGIN( "cs", CZECH )
|
||||
LANG_ENTRY_END( CZECH )
|
||||
/*x06*/ LANG_ENTRY_BEGIN( "da", DANISH )
|
||||
LANG_ENTRY_END( DANISH )
|
||||
/*x07*/ LANG_ENTRY_BEGIN( "de", GERMAN )
|
||||
LANG_SUB_ENTRY( "DE", GERMAN, GERMAN )
|
||||
LANG_SUB_ENTRY( "CH", GERMAN, GERMAN_SWISS )
|
||||
LANG_SUB_ENTRY( "AT", GERMAN, GERMAN_AUSTRIAN )
|
||||
LANG_SUB_ENTRY( "LU", GERMAN, GERMAN_LUXEMBOURG )
|
||||
LANG_SUB_ENTRY( "LI", GERMAN, GERMAN_LIECHTENSTEIN )
|
||||
LANG_ENTRY_END( GERMAN )
|
||||
/*x08*/ LANG_ENTRY_BEGIN( "el", GREEK )
|
||||
LANG_ENTRY_END( GREEK )
|
||||
/*x09*/ LANG_ENTRY_BEGIN( "en", ENGLISH )
|
||||
LANG_SUB_ENTRY( "US", ENGLISH, ENGLISH_US )
|
||||
LANG_SUB_ENTRY( "UK", ENGLISH, ENGLISH_UK )
|
||||
LANG_SUB_ENTRY( "GB", ENGLISH, ENGLISH_UK )
|
||||
LANG_SUB_ENTRY( "AU", ENGLISH, ENGLISH_AUS )
|
||||
LANG_SUB_ENTRY( "CA", ENGLISH, ENGLISH_CAN )
|
||||
LANG_SUB_ENTRY( "NZ", ENGLISH, ENGLISH_NZ )
|
||||
LANG_SUB_ENTRY( "EI", ENGLISH, ENGLISH_EIRE )
|
||||
LANG_SUB_ENTRY( "ZA", ENGLISH, ENGLISH_SAFRICA )
|
||||
LANG_SUB_ENTRY( "JM", ENGLISH, ENGLISH_JAMAICA )
|
||||
/* LANG_SUB_ENTRY( "AG", ENGLISH, ENGLISH_CARIBBEAN ) */
|
||||
LANG_SUB_ENTRY( "BZ", ENGLISH, ENGLISH_BELIZE )
|
||||
LANG_SUB_ENTRY( "TT", ENGLISH, ENGLISH_TRINIDAD )
|
||||
LANG_SUB_ENTRY( "ZW", ENGLISH, ENGLISH_ZIMBABWE )
|
||||
LANG_SUB_ENTRY( "PH", ENGLISH, ENGLISH_PHILIPPINES )
|
||||
LANG_ENTRY_END( ENGLISH )
|
||||
/*x0a*/ LANG_ENTRY_BEGIN( "es", SPANISH )
|
||||
/* traditional sorting */
|
||||
if (!strcmp(dialect,"tradicional"))
|
||||
LANG_DIALECT_ENTRY( SPANISH, SPANISH )
|
||||
LANG_SUB_ENTRY( "MX", SPANISH, SPANISH_MEXICAN )
|
||||
LANG_SUB_ENTRY( "ES", SPANISH, SPANISH_MODERN )
|
||||
LANG_SUB_ENTRY( "GT", SPANISH, SPANISH_GUATEMALA )
|
||||
LANG_SUB_ENTRY( "CR", SPANISH, SPANISH_COSTARICA )
|
||||
LANG_SUB_ENTRY( "PA", SPANISH, SPANISH_PANAMA )
|
||||
LANG_SUB_ENTRY( "DO", SPANISH, SPANISH_DOMINICAN )
|
||||
LANG_SUB_ENTRY( "VE", SPANISH, SPANISH_VENEZUELA )
|
||||
LANG_SUB_ENTRY( "CO", SPANISH, SPANISH_COLOMBIA )
|
||||
LANG_SUB_ENTRY( "PE", SPANISH, SPANISH_PERU )
|
||||
LANG_SUB_ENTRY( "AR", SPANISH, SPANISH_ARGENTINA )
|
||||
LANG_SUB_ENTRY( "EC", SPANISH, SPANISH_ECUADOR )
|
||||
LANG_SUB_ENTRY( "CL", SPANISH, SPANISH_CHILE )
|
||||
LANG_SUB_ENTRY( "UY", SPANISH, SPANISH_URUGUAY )
|
||||
LANG_SUB_ENTRY( "PY", SPANISH, SPANISH_PARAGUAY )
|
||||
LANG_SUB_ENTRY( "BO", SPANISH, SPANISH_BOLIVIA )
|
||||
LANG_SUB_ENTRY( "HN", SPANISH, SPANISH_HONDURAS )
|
||||
LANG_SUB_ENTRY( "NI", SPANISH, SPANISH_NICARAGUA )
|
||||
LANG_SUB_ENTRY( "PR", SPANISH, SPANISH_PUERTO_RICO )
|
||||
LANG_ENTRY_END( SPANISH )
|
||||
/*x0b*/ LANG_ENTRY_BEGIN( "fi", FINNISH )
|
||||
LANG_ENTRY_END( FINNISH )
|
||||
/*x0c*/ LANG_ENTRY_BEGIN( "fr", FRENCH )
|
||||
LANG_SUB_ENTRY( "FR", FRENCH, FRENCH )
|
||||
LANG_SUB_ENTRY( "BE", FRENCH, FRENCH_BELGIAN )
|
||||
LANG_SUB_ENTRY( "CA", FRENCH, FRENCH_CANADIAN )
|
||||
LANG_SUB_ENTRY( "CH", FRENCH, FRENCH_SWISS )
|
||||
LANG_SUB_ENTRY( "LU", FRENCH, FRENCH_LUXEMBOURG )
|
||||
LANG_SUB_ENTRY( "MC", FRENCH, FRENCH_MONACO )
|
||||
LANG_ENTRY_END( FRENCH )
|
||||
/*x0d*/ LANG_ENTRY_BEGIN( "iw", HEBREW )
|
||||
LANG_ENTRY_END( HEBREW )
|
||||
/*x0e*/ LANG_ENTRY_BEGIN( "hu", HUNGARIAN )
|
||||
LANG_ENTRY_END( HUNGARIAN )
|
||||
/*x0f*/ LANG_ENTRY_BEGIN( "ic", ICELANDIC )
|
||||
LANG_ENTRY_END( ICELANDIC )
|
||||
/*x10*/ LANG_ENTRY_BEGIN( "it", ITALIAN )
|
||||
LANG_SUB_ENTRY( "IT", ITALIAN, ITALIAN )
|
||||
LANG_SUB_ENTRY( "CH", ITALIAN, ITALIAN_SWISS )
|
||||
LANG_ENTRY_END( ITALIAN )
|
||||
/*x11*/ LANG_ENTRY_BEGIN( "ja", JAPANESE )
|
||||
LANG_ENTRY_END( JAPANESE )
|
||||
/*x12*/ LANG_ENTRY_BEGIN( "ko", KOREAN )
|
||||
/* JOHAB encoding */
|
||||
if (!strcmp(charset,"JOHAB"))
|
||||
LANG_DIALECT_ENTRY( KOREAN, KOREAN_JOHAB )
|
||||
else
|
||||
LANG_DIALECT_ENTRY( KOREAN, KOREAN )
|
||||
LANG_ENTRY_END( KOREAN )
|
||||
/*x13*/ LANG_ENTRY_BEGIN( "nl", DUTCH )
|
||||
LANG_SUB_ENTRY( "NL", DUTCH, DUTCH )
|
||||
LANG_SUB_ENTRY( "BE", DUTCH, DUTCH_BELGIAN )
|
||||
LANG_SUB_ENTRY( "SR", DUTCH, DUTCH_SURINAM )
|
||||
LANG_ENTRY_END( DUTCH )
|
||||
/*x14*/ LANG_ENTRY_BEGIN( "no", NORWEGIAN )
|
||||
/* nynorsk */
|
||||
if (!strcmp(dialect,"nynorsk"))
|
||||
LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_NYNORSK )
|
||||
else
|
||||
LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_BOKMAL )
|
||||
LANG_ENTRY_END( NORWEGIAN )
|
||||
/*x15*/ LANG_ENTRY_BEGIN( "pl", POLISH )
|
||||
LANG_ENTRY_END( POLISH )
|
||||
/*x16*/ LANG_ENTRY_BEGIN( "pt", PORTUGUESE )
|
||||
LANG_SUB_ENTRY( "BR", PORTUGUESE, PORTUGUESE_BRAZILIAN )
|
||||
LANG_SUB_ENTRY( "PT", PORTUGUESE, PORTUGUESE )
|
||||
LANG_ENTRY_END( PORTUGUESE )
|
||||
/*x17*/ LANG_ENTRY_BEGIN( "rm", RHAETO_ROMANCE )
|
||||
LANG_ENTRY_END( RHAETO_ROMANCE )
|
||||
/*x18*/ LANG_ENTRY_BEGIN( "ro", ROMANIAN )
|
||||
LANG_SUB_ENTRY( "RO", ROMANIAN, ROMANIAN )
|
||||
LANG_SUB_ENTRY( "MD", ROMANIAN, ROMANIAN_MOLDAVIA )
|
||||
LANG_ENTRY_END( ROMANIAN )
|
||||
/*x19*/ LANG_ENTRY_BEGIN( "ru", RUSSIAN )
|
||||
LANG_SUB_ENTRY( "RU", RUSSIAN, RUSSIAN )
|
||||
LANG_SUB_ENTRY( "MD", RUSSIAN, RUSSIAN_MOLDAVIA )
|
||||
LANG_ENTRY_END( RUSSIAN )
|
||||
/*x1a*/ if (!strcmp(lang,"sh") || !strcmp(lang,"hr") || !strcmp(lang,"sr")) {
|
||||
if (!country[0])
|
||||
LANG_DIALECT_ENTRY( SERBO_CROATIAN, NEUTRAL)
|
||||
if (!strcmp(charset,"ISO-8859-5"))
|
||||
LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN )
|
||||
LANG_SUB_ENTRY( "HR", SERBO_CROATIAN, CROATIAN )
|
||||
if (!strcmp(country,"YU") && !strcmp(charset,"ISO-8859-2"))
|
||||
LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
|
||||
LANG_SUB_ENTRY( "YU", SERBO_CROATIAN, SERBIAN )
|
||||
LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
|
||||
}
|
||||
/*x1b*/ LANG_ENTRY_BEGIN( "sk", SLOVAK )
|
||||
LANG_ENTRY_END( SLOVAK )
|
||||
/*x1c*/ LANG_ENTRY_BEGIN( "sq", ALBANIAN )
|
||||
LANG_ENTRY_END( ALBANIAN )
|
||||
/*x1d*/ LANG_ENTRY_BEGIN( "sv", SWEDISH )
|
||||
LANG_SUB_ENTRY( "SE", SWEDISH, SWEDISH )
|
||||
LANG_SUB_ENTRY( "FI", SWEDISH, SWEDISH_FINLAND )
|
||||
LANG_ENTRY_END( SWEDISH )
|
||||
/*x1e*/ LANG_ENTRY_BEGIN( "th", THAI )
|
||||
LANG_ENTRY_END( THAI )
|
||||
/*x1f*/ LANG_ENTRY_BEGIN( "tr", TURKISH )
|
||||
LANG_ENTRY_END( TURKISH )
|
||||
/*x20*/ LANG_ENTRY_BEGIN( "ur", URDU )
|
||||
LANG_ENTRY_END( URDU )
|
||||
/*x21*/ LANG_ENTRY_BEGIN( "in", INDONESIAN )
|
||||
LANG_ENTRY_END( INDONESIAN )
|
||||
/*x22*/ LANG_ENTRY_BEGIN( "uk", UKRAINIAN )
|
||||
LANG_ENTRY_END( UKRAINIAN )
|
||||
/*x23*/ LANG_ENTRY_BEGIN( "be", BYELORUSSIAN )
|
||||
LANG_ENTRY_END( BYELORUSSIAN )
|
||||
/*x24*/ LANG_ENTRY_BEGIN( "sl", SLOVENIAN )
|
||||
LANG_ENTRY_END( SLOVENIAN )
|
||||
/*x25*/ LANG_ENTRY_BEGIN( "et", ESTONIAN )
|
||||
LANG_ENTRY_END( ESTONIAN )
|
||||
/*x26*/ LANG_ENTRY_BEGIN( "lv", LATVIAN )
|
||||
LANG_ENTRY_END( LATVIAN )
|
||||
/*x27*/ LANG_ENTRY_BEGIN( "lt", LITHUANIAN )
|
||||
/* traditional sorting ? */
|
||||
if (!strcmp(dialect,"classic") || !strcmp(dialect,"traditional"))
|
||||
LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN_CLASSIC )
|
||||
else
|
||||
LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN )
|
||||
LANG_ENTRY_END( LITHUANIAN )
|
||||
/*x28*/ LANG_ENTRY_BEGIN( "mi", MAORI )
|
||||
LANG_ENTRY_END( MAORI )
|
||||
/*x29*/ LANG_ENTRY_BEGIN( "fa", FARSI )
|
||||
LANG_ENTRY_END( FARSI )
|
||||
/*x2a*/ LANG_ENTRY_BEGIN( "vi", VIETNAMESE )
|
||||
LANG_ENTRY_END( VIETNAMESE )
|
||||
/*x2b*/ LANG_ENTRY_BEGIN( "hy", ARMENIAN )
|
||||
LANG_ENTRY_END( ARMENIAN )
|
||||
/*x2c*/ LANG_ENTRY_BEGIN( "az", AZERI )
|
||||
/* Cyrillic */
|
||||
if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
|
||||
LANG_DIALECT_ENTRY( AZERI, AZERI_CYRILLIC )
|
||||
else
|
||||
LANG_DIALECT_ENTRY( AZERI, AZERI )
|
||||
LANG_ENTRY_END( AZERI )
|
||||
/*x2d*/ LANG_ENTRY_BEGIN( "eu", BASQUE )
|
||||
LANG_ENTRY_END( BASQUE )
|
||||
/*x2e*/ /*LANG_ENTRY_BEGIN( "??", SORBIAN )
|
||||
LANG_ENTRY_END( SORBIAN ) */
|
||||
/*x2f*/ LANG_ENTRY_BEGIN( "mk", MACEDONIAN )
|
||||
LANG_ENTRY_END( MACEDONIAN )
|
||||
/*x30*/ /*LANG_ENTRY_BEGIN( "??", SUTU )
|
||||
LANG_ENTRY_END( SUTU ) */
|
||||
/*x31*/ LANG_ENTRY_BEGIN( "ts", TSONGA )
|
||||
LANG_ENTRY_END( TSONGA )
|
||||
/*x32*/ /*LANG_ENTRY_BEGIN( "??", TSWANA )
|
||||
LANG_ENTRY_END( TSWANA ) */
|
||||
/*x33*/ /*LANG_ENTRY_BEGIN( "??", VENDA )
|
||||
LANG_ENTRY_END( VENDA ) */
|
||||
/*x34*/ LANG_ENTRY_BEGIN( "xh", XHOSA )
|
||||
LANG_ENTRY_END( XHOSA )
|
||||
/*x35*/ LANG_ENTRY_BEGIN( "zu", ZULU )
|
||||
LANG_ENTRY_END( ZULU )
|
||||
/*x36*/ LANG_ENTRY_BEGIN( "af", AFRIKAANS )
|
||||
LANG_ENTRY_END( AFRIKAANS )
|
||||
/*x37*/ LANG_ENTRY_BEGIN( "ka", GEORGIAN )
|
||||
LANG_ENTRY_END( GEORGIAN )
|
||||
/*x38*/ LANG_ENTRY_BEGIN( "fo", FAEROESE )
|
||||
LANG_ENTRY_END( FAEROESE )
|
||||
/*x39*/ LANG_ENTRY_BEGIN( "hi", HINDI )
|
||||
LANG_ENTRY_END( HINDI )
|
||||
/*x3a*/ LANG_ENTRY_BEGIN( "mt", MALTESE )
|
||||
LANG_ENTRY_END( MALTESE )
|
||||
/*x3b*/ /*LANG_ENTRY_BEGIN( "??", SAAMI )
|
||||
LANG_ENTRY_END( SAAMI ) */
|
||||
/*x3c*/ LANG_ENTRY_BEGIN( "ga", GAELIC )
|
||||
LANG_DIALECT_ENTRY( GAELIC, GAELIC )
|
||||
LANG_ENTRY_END( GAELIC )
|
||||
/*x3c*/ LANG_ENTRY_BEGIN( "gd", GAELIC )
|
||||
LANG_DIALECT_ENTRY( GAELIC, GAELIC_SCOTTISH )
|
||||
LANG_ENTRY_END( GAELIC )
|
||||
/* 0x3d */
|
||||
/*x3e*/ LANG_ENTRY_BEGIN( "ms", MALAY )
|
||||
LANG_SUB_ENTRY( "MY", MALAY, MALAY )
|
||||
LANG_SUB_ENTRY( "BN", MALAY, MALAY_BRUNEI_DARUSSALAM )
|
||||
LANG_ENTRY_END( MALAY )
|
||||
/*x3f*/ LANG_ENTRY_BEGIN( "kk", KAZAKH )
|
||||
LANG_ENTRY_END( KAZAKH )
|
||||
/* 0x40 */
|
||||
/*x41*/ LANG_ENTRY_BEGIN( "sw", SWAHILI )
|
||||
LANG_ENTRY_END( SWAHILI )
|
||||
/* 0x42 */
|
||||
/*x43*/ LANG_ENTRY_BEGIN( "uz", UZBEK )
|
||||
/* Cyrillic */
|
||||
if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
|
||||
LANG_DIALECT_ENTRY( UZBEK, UZBEK_CYRILLIC )
|
||||
else
|
||||
LANG_DIALECT_ENTRY( UZBEK, UZBEK )
|
||||
LANG_ENTRY_END( UZBEK )
|
||||
/*x44*/ LANG_ENTRY_BEGIN( "tt", TATAR )
|
||||
LANG_ENTRY_END( TATAR )
|
||||
/*x45*/ LANG_ENTRY_BEGIN( "bn", BENGALI )
|
||||
LANG_ENTRY_END( BENGALI )
|
||||
/*x46*/ LANG_ENTRY_BEGIN( "pa", PUNJABI )
|
||||
LANG_ENTRY_END( PUNJABI )
|
||||
/*x47*/ LANG_ENTRY_BEGIN( "gu", GUJARATI )
|
||||
LANG_ENTRY_END( GUJARATI )
|
||||
/*x48*/ LANG_ENTRY_BEGIN( "or", ORIYA )
|
||||
LANG_ENTRY_END( ORIYA )
|
||||
/*x49*/ LANG_ENTRY_BEGIN( "ta", TAMIL )
|
||||
LANG_ENTRY_END( TAMIL )
|
||||
/*x4a*/ LANG_ENTRY_BEGIN( "te", TELUGU )
|
||||
LANG_ENTRY_END( TELUGU )
|
||||
/*x4b*/ LANG_ENTRY_BEGIN( "kn", KANNADA )
|
||||
LANG_ENTRY_END( KANNADA )
|
||||
/*x4c*/ LANG_ENTRY_BEGIN( "ml", MALAYALAM )
|
||||
LANG_ENTRY_END( MALAYALAM )
|
||||
/*x4d*/ LANG_ENTRY_BEGIN( "as", ASSAMESE )
|
||||
LANG_ENTRY_END( ASSAMESE )
|
||||
/*x4e*/ LANG_ENTRY_BEGIN( "mr", MARATHI )
|
||||
LANG_ENTRY_END( MARATHI )
|
||||
/*x4f*/ LANG_ENTRY_BEGIN( "sa", SANSKRIT )
|
||||
LANG_ENTRY_END( SANSKRIT )
|
||||
/* 0x50 -> 0x56 */
|
||||
/*x57*/ /*LANG_ENTRY_BEGIN( "??", KONKANI )
|
||||
LANG_ENTRY_END( KONKANI ) */
|
||||
/* 0x58 -> ... */
|
||||
LANG_ENTRY_BEGIN( "eo", ESPERANTO ) /* not official */
|
||||
LANG_ENTRY_END( ESPERANTO )
|
||||
LANG_ENTRY_BEGIN( "wa", WALON ) /* not official */
|
||||
LANG_ENTRY_END( WALON )
|
||||
|
||||
end_MAIN_GetLanguageID:
|
||||
if (Charset) free(charset);
|
||||
free(dialect);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* MAIN_WineInit
|
||||
*
|
||||
|
|
171
ole/ole2nls.c
171
ole/ole2nls.c
|
@ -159,6 +159,175 @@ LCID WINAPI GetSystemDefaultLCID(void)
|
|||
return GetUserDefaultLCID();
|
||||
}
|
||||
|
||||
#define NLS_MAX_LANGUAGES 20
|
||||
typedef struct {
|
||||
char lang[128];
|
||||
char country[128];
|
||||
LANGID found_lang_id[NLS_MAX_LANGUAGES];
|
||||
char found_language[NLS_MAX_LANGUAGES][3];
|
||||
char found_country[NLS_MAX_LANGUAGES][3];
|
||||
int n_found;
|
||||
} LANG_FIND_DATA;
|
||||
|
||||
static BOOL CALLBACK NLS_FindLanguageID_ProcA(HMODULE hModule, LPCSTR type,
|
||||
LPCSTR name, WORD LangID, LONG lParam)
|
||||
{
|
||||
LANG_FIND_DATA *l_data = (LANG_FIND_DATA *)lParam;
|
||||
LCID lcid = MAKELCID(LangID, SORT_DEFAULT);
|
||||
char buf_language[128];
|
||||
char buf_country[128];
|
||||
char buf_en_language[128];
|
||||
|
||||
TRACE("%04X\n", (UINT)LangID);
|
||||
if(PRIMARYLANGID(LangID) == LANG_NEUTRAL)
|
||||
return TRUE; /* continue search */
|
||||
|
||||
buf_language[0] = 0;
|
||||
buf_country[0] = 0;
|
||||
|
||||
GetLocaleInfoA(lcid, LOCALE_SISO639LANGNAME|LOCALE_NOUSEROVERRIDE,
|
||||
buf_language, sizeof(buf_language));
|
||||
TRACE("LOCALE_SISO639LANGNAME: %s\n", buf_language);
|
||||
|
||||
GetLocaleInfoA(lcid, LOCALE_SISO3166CTRYNAME|LOCALE_NOUSEROVERRIDE,
|
||||
buf_country, sizeof(buf_country));
|
||||
TRACE("LOCALE_SISO3166CTRYNAME: %s\n", buf_country);
|
||||
|
||||
if(l_data->lang && strlen(l_data->lang) > 0 && !strcasecmp(l_data->lang, buf_language))
|
||||
{
|
||||
if(l_data->country && strlen(l_data->country) > 0)
|
||||
{
|
||||
if(!strcasecmp(l_data->country, buf_country))
|
||||
{
|
||||
l_data->found_lang_id[0] = LangID;
|
||||
l_data->n_found = 1;
|
||||
TRACE("Found lang_id %04X for %s_%s\n", LangID, l_data->lang, l_data->country);
|
||||
return FALSE; /* stop enumeration */
|
||||
}
|
||||
}
|
||||
else /* l_data->country not specified */
|
||||
{
|
||||
if(l_data->n_found < NLS_MAX_LANGUAGES)
|
||||
{
|
||||
l_data->found_lang_id[l_data->n_found] = LangID;
|
||||
strncpy(l_data->found_country[l_data->n_found], buf_country, 3);
|
||||
strncpy(l_data->found_language[l_data->n_found], buf_language, 3);
|
||||
l_data->n_found++;
|
||||
TRACE("Found lang_id %04X for %s\n", LangID, l_data->lang);
|
||||
return TRUE; /* continue search */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Just in case, check LOCALE_SENGLANGUAGE too,
|
||||
* in hope that possible alias name might have that value.
|
||||
*/
|
||||
buf_en_language[0] = 0;
|
||||
GetLocaleInfoA(lcid, LOCALE_SENGLANGUAGE|LOCALE_NOUSEROVERRIDE,
|
||||
buf_en_language, sizeof(buf_en_language));
|
||||
TRACE("LOCALE_SENGLANGUAGE: %s\n", buf_en_language);
|
||||
|
||||
if(l_data->lang && strlen(l_data->lang) > 0 && !strcasecmp(l_data->lang, buf_en_language))
|
||||
{
|
||||
l_data->found_lang_id[l_data->n_found] = LangID;
|
||||
strncpy(l_data->found_country[l_data->n_found], buf_country, 3);
|
||||
strncpy(l_data->found_language[l_data->n_found], buf_language, 3);
|
||||
l_data->n_found++;
|
||||
TRACE("Found lang_id %04X for %s\n", LangID, l_data->lang);
|
||||
}
|
||||
|
||||
return TRUE; /* continue search */
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* NLS_GetLanguageID
|
||||
*
|
||||
* INPUT:
|
||||
* Lang: a string whose two first chars are the iso name of a language.
|
||||
* Country: a string whose two first chars are the iso name of country
|
||||
* Charset: a string defining the chossen charset encoding
|
||||
* Dialect: a string defining a variation of the locale
|
||||
*
|
||||
* all those values are from the standardized format of locale
|
||||
* name in unix which is: Lang[_Country][.Charset][@Dialect]
|
||||
*
|
||||
* RETURNS:
|
||||
* the numeric code of the language used by Windows
|
||||
*
|
||||
* FIXME: Charset and Dialect are not handled
|
||||
*/
|
||||
static LANGID NLS_GetLanguageID(LPCSTR Lang, LPCSTR Country, LPCSTR Charset, LPCSTR Dialect)
|
||||
{
|
||||
LANG_FIND_DATA l_data;
|
||||
char lang_string[256];
|
||||
|
||||
if(!Lang)
|
||||
{
|
||||
l_data.found_lang_id[0] = MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT);
|
||||
goto END;
|
||||
}
|
||||
|
||||
memset(&l_data, 0, sizeof(LANG_FIND_DATA));
|
||||
strncpy(l_data.lang, Lang, sizeof(l_data.lang));
|
||||
|
||||
if(Country && strlen(Country) > 0)
|
||||
strncpy(l_data.country, Country, sizeof(l_data.country));
|
||||
|
||||
EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), RT_STRINGA,
|
||||
(LPCSTR)LOCALE_ILANGUAGE, NLS_FindLanguageID_ProcA, (LONG)&l_data);
|
||||
|
||||
strcpy(lang_string, l_data.lang);
|
||||
if(l_data.country && strlen(l_data.country) > 0)
|
||||
{
|
||||
strcat(lang_string, "_");
|
||||
strcat(lang_string, l_data.country);
|
||||
}
|
||||
|
||||
if(!l_data.n_found)
|
||||
{
|
||||
if(l_data.country && strlen(l_data.country) > 0)
|
||||
{
|
||||
MESSAGE("Warning: Language '%s' was not found, retrying without country name...\n", lang_string);
|
||||
l_data.country[0] = 0;
|
||||
EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), RT_STRINGA,
|
||||
(LPCSTR)LOCALE_ILANGUAGE, NLS_FindLanguageID_ProcA, (LONG)&l_data);
|
||||
}
|
||||
}
|
||||
|
||||
/* Re-evaluate lang_string */
|
||||
strcpy(lang_string, l_data.lang);
|
||||
if(l_data.country && strlen(l_data.country) > 0)
|
||||
{
|
||||
strcat(lang_string, "_");
|
||||
strcat(lang_string, l_data.country);
|
||||
}
|
||||
|
||||
if(!l_data.n_found)
|
||||
{
|
||||
MESSAGE("Warning: Language '%s' was not recognized, defaulting to English\n", lang_string);
|
||||
l_data.found_lang_id[0] = MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(l_data.n_found == 1)
|
||||
TRACE("For language '%s' lang_id %04X was found\n", lang_string, l_data.found_lang_id[0]);
|
||||
else /* l_data->n_found > 1 */
|
||||
{
|
||||
int i;
|
||||
MESSAGE("For language '%s' several language ids were found:\n", lang_string);
|
||||
for(i = 0; i < l_data.n_found; i++)
|
||||
MESSAGE("%s_%s - %04X; ", l_data.found_language[i], l_data.found_country[i], l_data.found_lang_id[i]);
|
||||
|
||||
MESSAGE("\nInstead of using first in the list, suggest to define\n"
|
||||
"your LANG environment variable like this: LANG=%s_%s\n",
|
||||
l_data.found_language[0], l_data.found_country[0]);
|
||||
}
|
||||
}
|
||||
END:
|
||||
TRACE("Returning %04X\n", l_data.found_lang_id[0]);
|
||||
return l_data.found_lang_id[0];
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* GetUserDefaultLangID [KERNEL32.426]
|
||||
*/
|
||||
|
@ -192,7 +361,7 @@ LANGID WINAPI GetUserDefaultLangID(void)
|
|||
charset=strchr(lang,'.'); if (charset) *charset++='\0';
|
||||
country=strchr(lang,'_'); if (country) *country++='\0';
|
||||
|
||||
userLCID = MAIN_GetLanguageID(lang, country, charset, dialect);
|
||||
userLCID = NLS_GetLanguageID(lang, country, charset, dialect);
|
||||
|
||||
lang=next;
|
||||
} while (lang && !userLCID);
|
||||
|
|
Loading…
Reference in New Issue