Make locale configurable.

git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@610 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
Pasi Kallinen 2011-10-04 14:03:15 +00:00
parent acf2705aea
commit 1d7ceb5ddf
6 changed files with 17 additions and 2 deletions

View File

@ -93,6 +93,7 @@ watch_columns { return TYPE_WATCH_COLUMNS; }
commands { return TYPE_CMDQUEUE; } commands { return TYPE_CMDQUEUE; }
postcommands { return TYPE_POSTCMDQUEUE; } postcommands { return TYPE_POSTCMDQUEUE; }
encoding { return TYPE_ENCODING; } encoding { return TYPE_ENCODING; }
locale { return TYPE_LOCALE; }
yes { yylval.i = 1; return TYPE_BOOL; } yes { yylval.i = 1; return TYPE_BOOL; }
no { yylval.i = 0; return TYPE_BOOL; } no { yylval.i = 0; return TYPE_BOOL; }
dglstart { yylval.i = DGLTIME_DGLSTART; return TYPE_CMDQUEUENAME; } dglstart { yylval.i = DGLTIME_DGLSTART; return TYPE_CMDQUEUENAME; }

View File

@ -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_CMDQUEUE TYPE_DEFINE_MENU TYPE_BANNER_FILE TYPE_CURSOR
%token TYPE_POSTCMDQUEUE %token TYPE_POSTCMDQUEUE
%token TYPE_MAX_IDLE_TIME TYPE_MENU_MAX_IDLE_TIME TYPE_EXTRA_INFO_FILE %token TYPE_MAX_IDLE_TIME TYPE_MENU_MAX_IDLE_TIME TYPE_EXTRA_INFO_FILE
%token TYPE_ENCODING %token TYPE_ENCODING TYPE_LOCALE
%token <s> TYPE_VALUE %token <s> TYPE_VALUE
%token <i> TYPE_NUMBER TYPE_CMDQUEUENAME %token <i> TYPE_NUMBER TYPE_CMDQUEUENAME
%type <kt> KeyType %type <kt> KeyType
@ -206,6 +206,11 @@ KeyPair: TYPE_CMDQUEUE '[' TYPE_CMDQUEUENAME ']'
globalconfig.passwd = strdup($3); globalconfig.passwd = strdup($3);
break; break;
case TYPE_LOCALE:
if (globalconfig.locale) free(globalconfig.locale);
globalconfig.locale = strdup($3);
break;
default: default:
fprintf(stderr, "%s:%d: token %s does not take a string, bailing out\n", fprintf(stderr, "%s:%d: token %s does not take a string, bailing out\n",
config, line, lookup_token($1)); config, line, lookup_token($1));
@ -622,6 +627,7 @@ KeyType : TYPE_SUSER { $$ = TYPE_SUSER; }
| TYPE_PATH_LOCKFILE { $$ = TYPE_PATH_LOCKFILE; } | TYPE_PATH_LOCKFILE { $$ = TYPE_PATH_LOCKFILE; }
| TYPE_PATH_INPROGRESS { $$ = TYPE_PATH_INPROGRESS; } | TYPE_PATH_INPROGRESS { $$ = TYPE_PATH_INPROGRESS; }
| TYPE_ENCODING { $$ = TYPE_ENCODING; } | TYPE_ENCODING { $$ = TYPE_ENCODING; }
| TYPE_LOCALE { $$ = TYPE_LOCALE; }
| TYPE_RC_FMT { $$ = TYPE_RC_FMT; } | TYPE_RC_FMT { $$ = TYPE_RC_FMT; }
| TYPE_WATCH_SORTMODE { $$ = TYPE_WATCH_SORTMODE; } | TYPE_WATCH_SORTMODE { $$ = TYPE_WATCH_SORTMODE; }
| TYPE_SERVER_ID { $$ = TYPE_SERVER_ID; } | 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_SORTMODE: return "sortmode";
case TYPE_WATCH_COLUMNS: return "watch_columns"; case TYPE_WATCH_COLUMNS: return "watch_columns";
case TYPE_SERVER_ID: return "server_id"; case TYPE_SERVER_ID: return "server_id";
case TYPE_LOCALE: return "locale";
default: abort(); default: abort();
} }
} }

View File

@ -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) { if (showplayers) {
inprogressdisplay(-1); inprogressdisplay(-1);

View File

@ -225,6 +225,7 @@ struct dg_globalconfig
int allow_registration; /* allow registering new nicks */ int allow_registration; /* allow registering new nicks */
int sortmode; /* default watching-screen sortmode */ int sortmode; /* default watching-screen sortmode */
char *server_id; /* string for the server name or whatever */ char *server_id; /* string for the server name or whatever */
char *locale;
struct dg_cmdpart *cmdqueue[NUM_DGLTIMES]; struct dg_cmdpart *cmdqueue[NUM_DGLTIMES];

View File

@ -738,6 +738,7 @@ create_config ()
if (!globalconfig.allow_registration) globalconfig.allow_registration = 1; if (!globalconfig.allow_registration) globalconfig.allow_registration = 1;
globalconfig.menulist = NULL; globalconfig.menulist = NULL;
globalconfig.server_id = NULL; globalconfig.server_id = NULL;
globalconfig.locale = NULL;
globalconfig.shed_uid = (uid_t)-1; globalconfig.shed_uid = (uid_t)-1;
globalconfig.shed_gid = (gid_t)-1; globalconfig.shed_gid = (gid_t)-1;

View File

@ -74,6 +74,9 @@ banner = "/dgl-banner"
shed_uid = 5 shed_uid = 5
shed_gid = 60 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 # Maximum time in seconds user can idle in the dgamelaunch menus
# before dgl exits. Default value is 0, which disables the idling timer. # before dgl exits. Default value is 0, which disables the idling timer.
# Does not apply to external programs or config editors. # Does not apply to external programs or config editors.