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;
|
wprog_state signal_state;
|
||||||
} program;
|
} program;
|
||||||
|
|
||||||
|
/* locale to use. NULL==POSIX or C */
|
||||||
|
const char *locale;
|
||||||
|
|
||||||
} w_global;
|
} w_global;
|
||||||
|
|
||||||
extern unsigned int ValidModMask;
|
extern unsigned int ValidModMask;
|
||||||
|
|||||||
24
src/main.c
24
src/main.c
@@ -78,8 +78,6 @@ unsigned int ValidModMask = 0xff;
|
|||||||
int inotifyFD;
|
int inotifyFD;
|
||||||
int inotifyWD;
|
int inotifyWD;
|
||||||
#endif
|
#endif
|
||||||
/* locale to use. NULL==POSIX or C */
|
|
||||||
char *Locale = NULL;
|
|
||||||
|
|
||||||
int wScreenCount = 0;
|
int wScreenCount = 0;
|
||||||
|
|
||||||
@@ -706,7 +704,7 @@ static int real_main(int argc, char **argv)
|
|||||||
wwarning(_("too few arguments for %s"), argv[i - 1]);
|
wwarning(_("too few arguments for %s"), argv[i - 1]);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
Locale = argv[i];
|
w_global.locale = argv[i];
|
||||||
} else if (strcmp(argv[i], "-display") == 0 || strcmp(argv[i], "--display") == 0) {
|
} else if (strcmp(argv[i], "-display") == 0 || strcmp(argv[i], "--display") == 0) {
|
||||||
i++;
|
i++;
|
||||||
if (i >= argc) {
|
if (i >= argc) {
|
||||||
@@ -746,19 +744,19 @@ static int real_main(int argc, char **argv)
|
|||||||
check_defaults();
|
check_defaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Locale) {
|
if (w_global.locale) {
|
||||||
setenv("LANG", Locale, 1);
|
setenv("LANG", w_global.locale, 1);
|
||||||
} else {
|
} else {
|
||||||
Locale = getenv("LC_ALL");
|
w_global.locale = getenv("LC_ALL");
|
||||||
if (!Locale) {
|
if (!w_global.locale) {
|
||||||
Locale = getenv("LANG");
|
w_global.locale = getenv("LANG");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
|
|
||||||
if (!Locale || strcmp(Locale, "C") == 0 || strcmp(Locale, "POSIX") == 0)
|
if (!w_global.locale || strcmp(w_global.locale, "C") == 0 || strcmp(w_global.locale, "POSIX") == 0)
|
||||||
Locale = NULL;
|
w_global.locale = NULL;
|
||||||
#ifdef I18N
|
#ifdef I18N
|
||||||
if (getenv("NLSPATH")) {
|
if (getenv("NLSPATH")) {
|
||||||
bindtextdomain("WindowMaker", getenv("NLSPATH"));
|
bindtextdomain("WindowMaker", getenv("NLSPATH"));
|
||||||
@@ -786,11 +784,11 @@ static int real_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (Locale) {
|
if (w_global.locale) {
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
Locale = wstrdup(Locale);
|
w_global.locale = wstrdup(w_global.locale);
|
||||||
ptr = strchr(Locale, '.');
|
ptr = strchr(w_global.locale, '.');
|
||||||
if (ptr)
|
if (ptr)
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,6 @@
|
|||||||
|
|
||||||
#define MAX_SHORTCUT_LENGTH 32
|
#define MAX_SHORTCUT_LENGTH 32
|
||||||
|
|
||||||
extern char *Locale;
|
|
||||||
extern WDDomain *WDRootMenu;
|
extern WDDomain *WDRootMenu;
|
||||||
extern Cursor wCursor[WCUR_LAST];
|
extern Cursor wCursor[WCUR_LAST];
|
||||||
|
|
||||||
@@ -309,14 +308,14 @@ static char *getLocalizedMenuFile(const char *menu)
|
|||||||
char *buffer, *ptr, *locale;
|
char *buffer, *ptr, *locale;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (!Locale)
|
if (!w_global.locale)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
len = strlen(menu) + strlen(Locale) + 8;
|
len = strlen(menu) + strlen(w_global.locale) + 8;
|
||||||
buffer = wmalloc(len);
|
buffer = wmalloc(len);
|
||||||
|
|
||||||
/* try menu.locale_name */
|
/* 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)
|
if (access(buffer, F_OK) == 0)
|
||||||
return buffer;
|
return buffer;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user