diff --git a/config.l b/config.l index 95eadb0..0779001 100644 --- a/config.l +++ b/config.l @@ -93,6 +93,7 @@ watch_columns { return TYPE_WATCH_COLUMNS; } commands { return TYPE_CMDQUEUE; } postcommands { return TYPE_POSTCMDQUEUE; } encoding { return TYPE_ENCODING; } +locale { return TYPE_LOCALE; } yes { yylval.i = 1; return TYPE_BOOL; } no { yylval.i = 0; return TYPE_BOOL; } dglstart { yylval.i = DGLTIME_DGLSTART; return TYPE_CMDQUEUENAME; } diff --git a/config.y b/config.y index c500071..436bf67 100644 --- a/config.y +++ b/config.y @@ -59,7 +59,7 @@ static int sortmode_number(const char *sortmode_name) { %token TYPE_CMDQUEUE TYPE_DEFINE_MENU TYPE_BANNER_FILE TYPE_CURSOR %token TYPE_POSTCMDQUEUE %token TYPE_MAX_IDLE_TIME TYPE_MENU_MAX_IDLE_TIME TYPE_EXTRA_INFO_FILE -%token TYPE_ENCODING +%token TYPE_ENCODING TYPE_LOCALE %token TYPE_VALUE %token TYPE_NUMBER TYPE_CMDQUEUENAME %type KeyType @@ -206,6 +206,11 @@ KeyPair: TYPE_CMDQUEUE '[' TYPE_CMDQUEUENAME ']' globalconfig.passwd = strdup($3); break; + case TYPE_LOCALE: + if (globalconfig.locale) free(globalconfig.locale); + globalconfig.locale = strdup($3); + break; + default: fprintf(stderr, "%s:%d: token %s does not take a string, bailing out\n", config, line, lookup_token($1)); @@ -622,6 +627,7 @@ KeyType : TYPE_SUSER { $$ = TYPE_SUSER; } | TYPE_PATH_LOCKFILE { $$ = TYPE_PATH_LOCKFILE; } | TYPE_PATH_INPROGRESS { $$ = TYPE_PATH_INPROGRESS; } | TYPE_ENCODING { $$ = TYPE_ENCODING; } + | TYPE_LOCALE { $$ = TYPE_LOCALE; } | TYPE_RC_FMT { $$ = TYPE_RC_FMT; } | TYPE_WATCH_SORTMODE { $$ = TYPE_WATCH_SORTMODE; } | TYPE_SERVER_ID { $$ = TYPE_SERVER_ID; } @@ -657,6 +663,7 @@ const char* lookup_token (int t) case TYPE_WATCH_SORTMODE: return "sortmode"; case TYPE_WATCH_COLUMNS: return "watch_columns"; case TYPE_SERVER_ID: return "server_id"; + case TYPE_LOCALE: return "locale"; default: abort(); } } diff --git a/dgamelaunch.c b/dgamelaunch.c index 436ad6e..10c5cee 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -2687,7 +2687,9 @@ main (int argc, char** argv) } } - setlocale(LC_CTYPE, "en_US.UTF-8"); + if (globalconfig.locale) { + setlocale(LC_CTYPE, globalconfig.locale); + } if (showplayers) { inprogressdisplay(-1); diff --git a/dgamelaunch.h b/dgamelaunch.h index 41cc764..7f7daec 100644 --- a/dgamelaunch.h +++ b/dgamelaunch.h @@ -225,6 +225,7 @@ struct dg_globalconfig int allow_registration; /* allow registering new nicks */ int sortmode; /* default watching-screen sortmode */ char *server_id; /* string for the server name or whatever */ + char *locale; struct dg_cmdpart *cmdqueue[NUM_DGLTIMES]; diff --git a/dgl-common.c b/dgl-common.c index d8d5044..a3c7e42 100644 --- a/dgl-common.c +++ b/dgl-common.c @@ -738,6 +738,7 @@ create_config () if (!globalconfig.allow_registration) globalconfig.allow_registration = 1; globalconfig.menulist = NULL; globalconfig.server_id = NULL; + globalconfig.locale = NULL; globalconfig.shed_uid = (uid_t)-1; globalconfig.shed_gid = (gid_t)-1; diff --git a/examples/dgamelaunch.conf b/examples/dgamelaunch.conf index cd78773..bd98683 100644 --- a/examples/dgamelaunch.conf +++ b/examples/dgamelaunch.conf @@ -74,6 +74,9 @@ banner = "/dgl-banner" shed_uid = 5 shed_gid = 60 +# Locale. Leaving this out, dgamelaunch will not explicitly set locale. +locale = "en_US.UTF-8" + # Maximum time in seconds user can idle in the dgamelaunch menus # before dgl exits. Default value is 0, which disables the idling timer. # Does not apply to external programs or config editors.