LANG and LANGUAGE environment variable in Debian based systems

23

6

It seems both the LANG and LANGUAGE environment variable are used by some programs to determine their user interface language.

What are the exact semantics of these variables and where can I read about their correct usage? The manpage for locale(1) only mentions the LC_* family of environment variables. Additionally there is also an LC_ALL variable commonly in place which isn't described there either.

aef

Posted 2012-02-21T17:34:18.770

Reputation: 1 052

Answers

24

LANG contain the setting for all categories that are not directly set by a LC_* variable.

LC_ALL is used to override every LC_* and LANG and LANGUAGE. It should not be set in a normal user environment, but can be useful when you are writing a script that depend on the precise output of an internationalized command.

LANGUAGE is used to set messages languages (as LC_MESSAGES) to a multi-valued value, e.g., setting it to fr:de:en will use French messages where they exist; if not, it will use German messages, and will fall back to English if neither German nor French messages are available.

Rémi

Posted 2012-02-21T17:34:18.770

Reputation: 1 300

1@Rémi can you elaborate on why LC_ALL should not be used? – Édouard Lopez – 2016-02-02T12:21:34.833

1Not much to say. You have more flexibility if you set LANG than if you set LC_ALL: you can set LANG to something and LC_COLLATE to some other thing. If you set LC_ALL, every other configuration are hidden. – Rémi – 2016-02-03T22:35:15.560

2I don't think LC_ALL overrides LANGUAGE:

  1. they have different meanings (order [e.g.: fr:de:en] vs. characteristics[e.g.: fr_FR])
  2. < – Murmel – 2018-06-06T15:11:49.787

6

start="2">

  • The GNU getText documentation's chapter Specifying a Priority List of Languages states: gettext gives preference to LANGUAGE over LC_ALL and LANG. Additionally, the chapter Locale Environment Variables states: 1. LANGUAGE 2. LC_ALL [...]
  • – Murmel – 2018-06-13T12:25:28.383

    1Where can I find documentation about LANGUAGE? Is it mutually exclusive to LC_MESSAGES? – aef – 2012-02-22T00:44:29.797

    Everything is in the locale(7) manpage. LC_MESSAGES changes the language messages are displayed in and what an affirmative or negative answer looks like. The GNU C-library contains the gettext(3), ngettext(3), and rpmatch(3) functions to ease the use of these information. The GNU gettext family of functions also obey the environment variable LANGUAGE (containing a colon-separated list of locales) if the category is set to a valid locale other than "C". – Rémi – 2012-02-24T15:08:40.907

    10

    Have a look at the manpage locale(7): it describes that LANG is a fallback setting, while LC_ALL overrides all separate LC_* settings.

    Jaap Eldering

    Posted 2012-02-21T17:34:18.770

    Reputation: 7 596

    3man 7 locale is the command – Smile4ever – 2017-01-08T15:52:35.577

    2

    For reference, the locale system is GNU GetText, which has its full documentation available in the gettext-doc package (Debian/Ubuntu).

    Alternatively, there is an online manual with authoritative and elaborate documentation of the LANG and LANGUAGE environment variables.

    mikini

    Posted 2012-02-21T17:34:18.770

    Reputation: 41