nls: Rework NLS init to work with non-en_US locales.
We shouldn't blindly set the LC_CTYPE to en_US.utf8, because the user may not have it installed. So if the user already has a utf8 locale defined, just use it for LC_CTYPE. Fixed: SF Bug #87 (Problem of accentuation)
This commit is contained in:
parent
c985eee9c7
commit
520de165fb
18
minidlna.c
18
minidlna.c
@ -468,9 +468,21 @@ static int strtobool(const char *str)
|
||||
static void init_nls(void)
|
||||
{
|
||||
#ifdef ENABLE_NLS
|
||||
setlocale(LC_MESSAGES, "");
|
||||
setlocale(LC_CTYPE, "en_US.utf8");
|
||||
DPRINTF(E_DEBUG, L_GENERAL, "Using locale dir %s\n", bindtextdomain("minidlna", getenv("TEXTDOMAINDIR")));
|
||||
const char *messages, *ctype, *locale_dir;
|
||||
|
||||
ctype = setlocale(LC_CTYPE, "");
|
||||
if (!ctype || !strcmp(ctype, "C"))
|
||||
ctype = setlocale(LC_CTYPE, "en_US.utf8");
|
||||
if (!ctype)
|
||||
DPRINTF(E_WARN, L_GENERAL, "Unset locale\n");
|
||||
else if (!strstr(ctype, "utf8") && !strstr(ctype, "UTF8") &&
|
||||
!strstr(ctype, "utf-8") && !strstr(ctype, "UTF-8"))
|
||||
DPRINTF(E_WARN, L_GENERAL, "Using unsupported non-utf8 locale '%s'\n", ctype);
|
||||
messages = setlocale(LC_MESSAGES, "");
|
||||
if (!messages)
|
||||
messages = "unset";
|
||||
locale_dir = bindtextdomain("minidlna", getenv("TEXTDOMAINDIR"));
|
||||
DPRINTF(E_DEBUG, L_GENERAL, "Using locale dir '%s' and locale langauge %s/%s\n", locale_dir, messages, ctype);
|
||||
textdomain("minidlna");
|
||||
#endif
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user