3

I'm trying to see localized error messages. However, I only seem to get the message from the default "C" locale. E.g.

$ cat /etc/shadow
cat: /etc/shadow: Permission denied

$ locale -a|grep fi
fi_FI.utf8

$ LC_MESSAGES=fi_FI.utf8 cat /etc/shadow
cat: /etc/shadow: Permission denied

Furthermore, looking at the ltrace output of cat it does call setlocale(LC_ALL, ""), and prints the error message with the glibc error() function (which prints the error message returned by strerror(), which should be a localized message).

Looking at the strace output of "LC_MESSAGES=fi_FI.utf8 cat /etc/shadow" one sees that it tries to open the libc message catalog, but for the english locale rather than fi_FI.utf8:

...
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
...

I do have a file /usr/share/locale-langpack/fi/LC_MESSAGES/libc.mo which contains the libc message catalog for the fi_FI.utf8 locale, however, it doesn't seem to be used. Packages language-pack-fi, language-pack-fi-base are both installed (as are the corresponding gnome and kde language packs, but I can't see them being relevant here).

What am I missing?

2

You are missing the LANGUAGE environment variable, which is set in Ubuntu more often than not, and overrides LC_MESSAGES for GNU compatible programs.

Try:

LANGUAGE=fi cat /etc/shadow

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.