mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 20:38:08 +01:00
wmaker: Moved the variable for Locale choice (I18N) to the global variable structure
This commit is contained in:
committed by
Carlos R. Mafra
parent
3892f3220a
commit
577506cbd2
@@ -461,6 +461,9 @@ extern struct wmaker_global_variables {
|
||||
wprog_state signal_state;
|
||||
} program;
|
||||
|
||||
/* locale to use. NULL==POSIX or C */
|
||||
const char *locale;
|
||||
|
||||
} w_global;
|
||||
|
||||
extern unsigned int ValidModMask;
|
||||
|
||||
24
src/main.c
24
src/main.c
@@ -78,8 +78,6 @@ unsigned int ValidModMask = 0xff;
|
||||
int inotifyFD;
|
||||
int inotifyWD;
|
||||
#endif
|
||||
/* locale to use. NULL==POSIX or C */
|
||||
char *Locale = NULL;
|
||||
|
||||
int wScreenCount = 0;
|
||||
|
||||
@@ -706,7 +704,7 @@ static int real_main(int argc, char **argv)
|
||||
wwarning(_("too few arguments for %s"), argv[i - 1]);
|
||||
exit(0);
|
||||
}
|
||||
Locale = argv[i];
|
||||
w_global.locale = argv[i];
|
||||
} else if (strcmp(argv[i], "-display") == 0 || strcmp(argv[i], "--display") == 0) {
|
||||
i++;
|
||||
if (i >= argc) {
|
||||
@@ -746,19 +744,19 @@ static int real_main(int argc, char **argv)
|
||||
check_defaults();
|
||||
}
|
||||
|
||||
if (Locale) {
|
||||
setenv("LANG", Locale, 1);
|
||||
if (w_global.locale) {
|
||||
setenv("LANG", w_global.locale, 1);
|
||||
} else {
|
||||
Locale = getenv("LC_ALL");
|
||||
if (!Locale) {
|
||||
Locale = getenv("LANG");
|
||||
w_global.locale = getenv("LC_ALL");
|
||||
if (!w_global.locale) {
|
||||
w_global.locale = getenv("LANG");
|
||||
}
|
||||
}
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
if (!Locale || strcmp(Locale, "C") == 0 || strcmp(Locale, "POSIX") == 0)
|
||||
Locale = NULL;
|
||||
if (!w_global.locale || strcmp(w_global.locale, "C") == 0 || strcmp(w_global.locale, "POSIX") == 0)
|
||||
w_global.locale = NULL;
|
||||
#ifdef I18N
|
||||
if (getenv("NLSPATH")) {
|
||||
bindtextdomain("WindowMaker", getenv("NLSPATH"));
|
||||
@@ -786,11 +784,11 @@ static int real_main(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Locale) {
|
||||
if (w_global.locale) {
|
||||
char *ptr;
|
||||
|
||||
Locale = wstrdup(Locale);
|
||||
ptr = strchr(Locale, '.');
|
||||
w_global.locale = wstrdup(w_global.locale);
|
||||
ptr = strchr(w_global.locale, '.');
|
||||
if (ptr)
|
||||
*ptr = 0;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,6 @@
|
||||
|
||||
#define MAX_SHORTCUT_LENGTH 32
|
||||
|
||||
extern char *Locale;
|
||||
extern WDDomain *WDRootMenu;
|
||||
extern Cursor wCursor[WCUR_LAST];
|
||||
|
||||
@@ -309,14 +308,14 @@ static char *getLocalizedMenuFile(const char *menu)
|
||||
char *buffer, *ptr, *locale;
|
||||
int len;
|
||||
|
||||
if (!Locale)
|
||||
if (!w_global.locale)
|
||||
return NULL;
|
||||
|
||||
len = strlen(menu) + strlen(Locale) + 8;
|
||||
len = strlen(menu) + strlen(w_global.locale) + 8;
|
||||
buffer = wmalloc(len);
|
||||
|
||||
/* try menu.locale_name */
|
||||
snprintf(buffer, len, "%s.%s", menu, Locale);
|
||||
snprintf(buffer, len, "%s.%s", menu, w_global.locale);
|
||||
if (access(buffer, F_OK) == 0)
|
||||
return buffer;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user