Ubuntu – Why is overriding the LANG environment variable not changing the language for me

environment-variableslanguagetranslation

I'm trying to run an application in another language as my current environment. To start out simple, I wanted to change the language of ls.

Here's what I read all over the place (see below for related questions): set LANG to one of the supported locales, e.g.:

LANG=nl_NL.UTF-8 ls /nonexistent

to have it show Dutch (NL) output.

However, I still get English output:

$ LANG=nl_NL.UTF-8 ls -al /nonexistent
ls: cannot access /nonexistent: No such file or directory

My current environment:

$ locale
LANG=en_GB.UTF-8
LANGUAGE=en_GB:en
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=

To be sure, I've checked:

  • The locale is supported:

    $ grep nl_NL /usr/share/i18n/SUPPORTED 
    nl_NL.UTF-8 UTF-8
    nl_NL ISO-8859-1
    nl_NL@euro ISO-8859-15
    
  • The locale is generated:

    sudo locale-gen nl_NL.UTF-8
    

    and sudo dpkg-reconfigure locales also shows it's generated.

  • Installed the Dutch language pack (already installed):

    sudo apt-get install language-pack-nl
    

What else have I tried?

  • Using export to set both LANG and LANGUAGE instead of prepending the command.
  • Setting also LC_ALL.

Ironically, some (only some!) GUI applications are actually in Dutch, but I haven't configured that at all!

enter image description here

I'm on Kubuntu 12.04(.2), as far as that matters.

Similar questions (to no avail):

What's wrong on my system? Where to debug this further?

Best Answer

Because LANGUAGE, which takes precedence over LANG, is set and unchanged.

$ LANGUAGE=nl ls /nonexistent
ls: kan geen toegang krijgen tot /nonexistent: Bestand of map bestaat niet

More info is in the GNU gettext documentation:

GNU gettext gives preference to LANGUAGE over LC_ALL and LANG for the purpose of message handling, but you still need to have LANG (or LC_ALL) set to the primary language; this is required by other parts of the system libraries.