The ‘LANGUAGE’ locale variable – how to set English as primary language? A bug in gettext

environment-variableslocale

The "LANGUAGE" variable is supposed to set the default language and can be used to specify a set of languages, where the next language will be used if a message is not available in the first (previous) one.

For example (as from gettext example) with 'sv:de' variable's value programs will show messages in Swedish and if such text is not found then in German.

I want to use English language as my primary language and some other (let's say Russian language) as secondary:

export LANGUAGE=en:ru; blabla
blabla: команда не найдена
        ^^^^^^^^^^^^^^^^^^
**Russian error message used**

Ok. Let's try another order:

export LANGUAGE=ru:en; blabla
blabla: команда не найдена
        ^^^^^^^^^^^^^^^^^^
**Russian error message used again**

In the other words, it doesn't matter on which position English language was specified, it always has the lowest priority and a message will be shown at any other specified language if the message is defined for that language.

The question: how can I specify English language as primary and any other language as secondary? And what's going on with the LANGUAGE variable?

P.S. 'LC_MESSAGES' is set up to the English locale of course.

Best Answer

As it was discussed in this question most programs don't have 'English' locale but use default ('C') locale with English messages instead. So if I want to use some languages with preferred English then I have to add 'C' locale right after the English locale in the list. In my case the 'LANGUAGES' must be:

LANGUAGES=en:C:ru


Which means "Use English then Default and then Russian". So every program which doesn't have English locale (because of using English locale as its default locale) will fall back to its default locale.
Someone may think that there is no effect in specifying Russian locale after 'default' because the default locale is always present and the Russian locale will never be chosen. It's true. But some programs (like browsers and text-editors) use the 'LANGUAGES' variable to get a list of user-spoken languages (like languages to request HTML-pages on, or languages for spell-checking) and in such cases Russian language won't be superfluous in the language list.