Gettext and LC_MESSAGES
Hi,
I found a peculiar behavior of setlocale() and gettext.
At first, I wrote the following program to test setlocale().
-----------------------------------------
/* setlocale.c */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
int main(int argc, char **argv)
{
char *loc;
loc = setlocale(LC_ALL, "");
if (!loc) printf("setlocale(LC_ALL) fails.\n");
else printf("LC_ALL = %s\n", loc);
loc = setlocale(LC_MESSAGES, "");
if (!loc) printf("setlocale(LC_MESSAGES) fails.\n");
else printf("LC_MESSAGES = %s\n", loc);
return 0;
}
-----------------------------------------
~$ LANG=C ./setlocale
LC_ALL = C
LC_MESSAGES = C
~$ LANG=C ls foobar
ls: foobar: No such file or directory
~$ LANG=de_DE ./setlocale
LC_ALL = de_DE
LC_MESSAGES = de_DE
~$ LANG=de_DE ls foobar
ls: foobar: Datei oder Verzeichnis nicht gefunden
~$ LANG=de ./setlocale
setlocale(LC_ALL) fails.
setlocale(LC_MESSAGES) fails.
~$ LANG=de ls foobar
ls: foobar: Datei oder Verzeichnis nicht gefunden
The first and second examples work well. However, the third example
shows that gettext does not obey LC_MESSAGES locale.
There should be two discussions: (1) Why setlocale(LC_MESSAGES, "de")
fails? Should we improve locale database to have "de" locale?
(2) Why German message is displayed while setlocale() fails? Is this
a bug of gettext or glibc?
Or, do I have a wrong idea that gettext should obey LC_MESSAGES...?
Note: Of course "de" is one example. This is same for other languages.
ii gettext 0.10.35-14 GNU Internationalization utilities
ii gettext-base 0.10.35-14 GNU Internationalization utilities for the b
ii libc6 2.1.3-10 GNU C Library: Shared libraries and Timezone
ii libc6-dev 2.1.3-10 GNU C Library: Development Libraries and Hea
ii locales 2.1.3-10 GNU C Library: National Language (locale) da
---
Tomohiro KUBOTA <kubota@debian.or.jp>
http://surfchem0.riken.go.jp/~kubota/
Reply to: