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?

janneb
  • 133
  • 1
  • 5
  • see also http://askubuntu.com/questions/246547/is-it-possible-to-change-language-for-user-interface-temporarily – Takkat Nov 28 '13 at 11:13

1 Answers1

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
David Foerster
  • 36,264
  • 56
  • 94
  • 147
Gunnar Hjalmarsson
  • 33,540
  • 3
  • 64
  • 94