Made --language behave the same as setting the LANGUAGE environment
variable.
This commit is contained in:
parent
10b1b23d40
commit
ce4784d8a5
|
@ -11,7 +11,6 @@ extern BOOL MAIN_MainInit( char *argv[] );
|
|||
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 void MAIN_ParseLanguageOption( const char *arg );
|
||||
|
||||
extern BOOL RELAY_Init(void);
|
||||
extern int RELAY_ShowDebugmsgRelay(const char *func);
|
||||
|
|
|
@ -585,9 +585,6 @@ DWORD WINAPI RtlGetAce(
|
|||
|
||||
/* string functions */
|
||||
|
||||
WCHAR CDECL NTDLL_towupper(WCHAR code);
|
||||
WCHAR CDECL NTDLL_towlower(WCHAR code);
|
||||
|
||||
VOID WINAPI RtlInitAnsiString(
|
||||
PANSI_STRING target,
|
||||
LPCSTR source);
|
||||
|
|
|
@ -9,58 +9,12 @@
|
|||
|
||||
#include "windef.h"
|
||||
|
||||
/* Supported languages */
|
||||
/* When adding a new language look at ole/ole2nls.c
|
||||
* for the LANG_Xx name to choose, and uncomment there
|
||||
* the proper case line
|
||||
*/
|
||||
typedef enum
|
||||
{ LANG_Xx, /* Just to ensure value 0 is not used */
|
||||
LANG_En, /* English */
|
||||
LANG_Es, /* Spanish */
|
||||
LANG_De, /* German */
|
||||
LANG_No, /* Norwegian */
|
||||
LANG_Fr, /* French */
|
||||
LANG_Fi, /* Finnish */
|
||||
LANG_Da, /* Danish */
|
||||
LANG_Cs, /* Czech */
|
||||
LANG_Eo, /* Esperanto */
|
||||
LANG_It, /* Italian */
|
||||
LANG_Ko, /* Korean */
|
||||
LANG_Hu, /* Hungarian */
|
||||
LANG_Pl, /* Polish */
|
||||
LANG_Pt, /* Portuguese */
|
||||
LANG_Sk, /* Slovak */
|
||||
LANG_Sv, /* Swedish */
|
||||
LANG_Ca, /* Catalan */
|
||||
LANG_Nl, /* Dutch */
|
||||
LANG_Ru, /* Russian */
|
||||
LANG_Wa, /* Walon */
|
||||
LANG_Br, /* Breton */
|
||||
LANG_Cy, /* Welsh */
|
||||
LANG_Ga, /* Irish Gaelic */
|
||||
LANG_Gd, /* Scots Gaelic */
|
||||
LANG_Gv, /* Manx Gaelic */
|
||||
LANG_Kw, /* Cornish */
|
||||
LANG_Ja, /* Japanese */
|
||||
LANG_Hr /* Croatian */
|
||||
} WINE_LANGUAGE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *name;
|
||||
WORD langid;
|
||||
} WINE_LANGUAGE_DEF;
|
||||
|
||||
extern const WINE_LANGUAGE_DEF Languages[];
|
||||
|
||||
struct options
|
||||
{
|
||||
char * desktopGeometry; /* NULL when no desktop */
|
||||
char * display; /* display name */
|
||||
char *dllFlags; /* -dll flags (hack for Winelib support) */
|
||||
int synchronous; /* X synchronous mode */
|
||||
WINE_LANGUAGE language; /* Current language */
|
||||
int managed; /* Managed windows */
|
||||
char * configFileName; /* Command line config file */
|
||||
};
|
||||
|
|
64
misc/main.c
64
misc/main.c
|
@ -42,44 +42,7 @@
|
|||
|
||||
USER_DRIVER *USER_Driver = NULL;
|
||||
|
||||
/* when adding new languages look at ole/ole2nls.c
|
||||
* for proper iso name and Windows code (add 0x0400
|
||||
* to the code listed there)
|
||||
*/
|
||||
const WINE_LANGUAGE_DEF Languages[] =
|
||||
{
|
||||
{"En",0x0409}, /* LANG_En */
|
||||
{"Es",0x040A}, /* LANG_Es */
|
||||
{"De",0x0407}, /* LANG_De */
|
||||
{"No",0x0414}, /* LANG_No */
|
||||
{"Fr",0x040C}, /* LANG_Fr */
|
||||
{"Fi",0x040B}, /* LANG_Fi */
|
||||
{"Da",0x0406}, /* LANG_Da */
|
||||
{"Cs",0x0405}, /* LANG_Cs */
|
||||
{"Eo",0x048f}, /* LANG_Eo */
|
||||
{"It",0x0410}, /* LANG_It */
|
||||
{"Ko",0x0412}, /* LANG_Ko */
|
||||
{"Hu",0x040e}, /* LANG_Hu */
|
||||
{"Pl",0x0415}, /* LANG_Pl */
|
||||
{"Pt",0x0416}, /* LANG_Pt */
|
||||
{"Sk",0x041b}, /* LANG_Sk */
|
||||
{"Sv",0x041d}, /* LANG_Sv */
|
||||
{"Ca",0x0403}, /* LANG_Ca */
|
||||
{"Nl",0x0413}, /* LANG_Nl */
|
||||
{"Ru",0x0419}, /* LANG_Ru */
|
||||
{"Wa",0x0490}, /* LANG_Wa */
|
||||
{"Ga",0x043c}, /* LANG_Ga */
|
||||
{"Gd",0x083c}, /* LANG_Gd */
|
||||
{"Gv",0x0c3c}, /* LANG_Gv */
|
||||
{"Kw",0x0491}, /* LANG_Kw */
|
||||
{"Cy",0x0492}, /* LANG_Cy */
|
||||
{"Br",0x0493}, /* LANG_Br */
|
||||
{"Ja",0x0411}, /* LANG_Ja */
|
||||
{"Hr",0x041A}, /* LANG_Hr */
|
||||
{NULL,0}
|
||||
};
|
||||
|
||||
WORD WINE_LanguageId = 0x409; /* english as default */
|
||||
|
||||
/***********************************************************************
|
||||
* MAIN_ParseDebugOptions
|
||||
|
@ -574,8 +537,6 @@ int MAIN_GetLanguageID(LPCSTR Lang,LPCSTR Country,LPCSTR Charset,LPCSTR Dialect)
|
|||
LANG_ENTRY_BEGIN( "wa", WALON ) /* not official */
|
||||
LANG_ENTRY_END( WALON )
|
||||
|
||||
ret = LANG_ENGLISH;
|
||||
|
||||
end_MAIN_GetLanguageID:
|
||||
if (Charset) free(charset);
|
||||
free(dialect);
|
||||
|
@ -583,31 +544,6 @@ end_MAIN_GetLanguageID:
|
|||
return ret;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* MAIN_ParseLanguageOption
|
||||
*
|
||||
* Parse -language option.
|
||||
*/
|
||||
void MAIN_ParseLanguageOption( const char *arg )
|
||||
{
|
||||
const WINE_LANGUAGE_DEF *p = Languages;
|
||||
|
||||
Options.language = LANG_Xx; /* First (dummy) language */
|
||||
for (;p->name;p++)
|
||||
{
|
||||
if (!lstrcmpiA( p->name, arg ))
|
||||
{
|
||||
WINE_LanguageId = p->langid;
|
||||
return;
|
||||
}
|
||||
Options.language++;
|
||||
}
|
||||
MESSAGE( "Invalid language specified '%s'. Supported languages are: ", arg );
|
||||
for (p = Languages; p->name; p++) MESSAGE( "%s ", p->name );
|
||||
MESSAGE( "\n" );
|
||||
ExitProcess(1);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* called_at_exit
|
||||
|
|
|
@ -36,7 +36,6 @@ struct options Options =
|
|||
NULL, /* display */
|
||||
NULL, /* dllFlags */
|
||||
FALSE, /* synchronous */
|
||||
0, /* language */
|
||||
FALSE, /* Managed windows */
|
||||
NULL /* Alternate config file name */
|
||||
};
|
||||
|
@ -64,6 +63,7 @@ static void do_desktop( const char *arg );
|
|||
static void do_display( const char *arg );
|
||||
static void do_dll( const char *arg );
|
||||
static void do_help( const char *arg );
|
||||
static void do_language( const char *arg );
|
||||
static void do_managed( const char *arg );
|
||||
static void do_synchronous( const char *arg );
|
||||
static void do_version( const char *arg );
|
||||
|
@ -84,7 +84,7 @@ static const struct option option_table[] =
|
|||
"--dosver x.xx DOS version to imitate (e.g. 6.22). Only valid with --winver win31" },
|
||||
{ "help", 'h', 0, 0, do_help,
|
||||
"--help,-h Show this help message" },
|
||||
{ "language", 0, 1, 1, MAIN_ParseLanguageOption,
|
||||
{ "language", 0, 1, 1, do_language,
|
||||
"--language xx Set the language (one of Br,Ca,Cs,Cy,Da,De,En,Eo,Es,Fi,Fr,Ga,Gd,Gv,\n"
|
||||
" Hr,Hu,It,Ja,Ko,Kw,Nl,No,Pl,Pt,Sk,Sv,Ru,Wa)" },
|
||||
{ "managed", 0, 0, 0, do_managed,
|
||||
|
@ -138,6 +138,11 @@ static void do_dll( const char *arg )
|
|||
Options.dllFlags = xstrdup( arg );
|
||||
}
|
||||
|
||||
static void do_language( const char *arg )
|
||||
{
|
||||
SetEnvironmentVariableA( "LANGUAGE", arg );
|
||||
}
|
||||
|
||||
static void do_managed( const char *arg )
|
||||
{
|
||||
Options.managed = TRUE;
|
||||
|
|
|
@ -166,25 +166,23 @@ LANGID WINAPI GetUserDefaultLangID(void)
|
|||
{
|
||||
/* caching result, if defined from environment, which should (?) not change during a WINE session */
|
||||
static LANGID userLCID = 0;
|
||||
if (Options.language) {
|
||||
return Languages[Options.language].langid;
|
||||
}
|
||||
|
||||
if (userLCID == 0) {
|
||||
char *buf=NULL;
|
||||
if (userLCID == 0)
|
||||
{
|
||||
char buf[256];
|
||||
char *lang,*country,*charset,*dialect,*next;
|
||||
int ret=0;
|
||||
|
||||
buf=getenv("LANGUAGE");
|
||||
if (!buf) buf=getenv("LANG");
|
||||
if (!buf) buf=getenv("LC_ALL");
|
||||
if (!buf) buf=getenv("LC_MESSAGES");
|
||||
if (!buf) buf=getenv("LC_CTYPE");
|
||||
if (!buf) return userLCID = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
|
||||
|
||||
if (!strcmp(buf,"POSIX") || !strcmp(buf,"C")) {
|
||||
return MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
|
||||
}
|
||||
|
||||
if (GetEnvironmentVariableA( "LANGUAGE", buf, sizeof(buf) )) goto ok;
|
||||
if (GetEnvironmentVariableA( "LANG", buf, sizeof(buf) )) goto ok;
|
||||
if (GetEnvironmentVariableA( "LC_ALL", buf, sizeof(buf) )) goto ok;
|
||||
if (GetEnvironmentVariableA( "LC_MESSAGES", buf, sizeof(buf) )) goto ok;
|
||||
if (GetEnvironmentVariableA( "LC_CTYPE", buf, sizeof(buf) )) goto ok;
|
||||
|
||||
return userLCID = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
|
||||
|
||||
ok:
|
||||
if (!strcmp(buf,"POSIX") || !strcmp(buf,"C"))
|
||||
return userLCID = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
|
||||
|
||||
lang=buf;
|
||||
|
||||
|
@ -194,14 +192,17 @@ LANGID WINAPI GetUserDefaultLangID(void)
|
|||
charset=strchr(lang,'.'); if (charset) *charset++='\0';
|
||||
country=strchr(lang,'_'); if (country) *country++='\0';
|
||||
|
||||
ret=MAIN_GetLanguageID(lang, country, charset, dialect);
|
||||
userLCID = MAIN_GetLanguageID(lang, country, charset, dialect);
|
||||
|
||||
lang=next;
|
||||
|
||||
} while (lang && !ret);
|
||||
|
||||
/* FIXME : are strings returned by getenv() to be free()'ed ? */
|
||||
userLCID = (LANGID)ret;
|
||||
} while (lang && !userLCID);
|
||||
|
||||
if (!userLCID)
|
||||
{
|
||||
MESSAGE( "Warning: language '%s' not recognized, defaulting to English\n",
|
||||
buf );
|
||||
userLCID = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
|
||||
}
|
||||
}
|
||||
return userLCID;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue