Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
see also askubuntu.com/questions/246547/… –  Takkat Nov 28 '13 at 11:13

1 Answer 1

up vote 1 down vote accepted

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

Try:

$ LANGUAGE=fi cat /etc/shadow

share|improve this answer
    
Right, that was it. Thanks! –  janneb Nov 28 '13 at 10:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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