LANG=en_US.UTF-8 not work

I am using KDE
Before I was using “LANG=en_US.UTF-8” to have the output in English in my terminal But now it’s not working.
What should I do to have the output in English?

**LC_ALL=C
****LANGUAGE=C
**LC_ALL=en_US.UTF-8

Basically use the YaST “System → Language” and “Hardware → System Keyboard Layout” to set up the System’s Locale (with secondary languages) and, the System Keyboard Layout.
But, this doesn’t always produce a workable solution for non-US_English systems and,

  • You have to be careful with “localectl” when tweaking the generated settings – more in a moment …

For a system wide Locale Language setting, we’re going to target an output like this:


 > locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
 > 

So, » How to set the Locale parameter LANG on a systemd system «:


 > localectl list-locales | grep -i 'en'
en_AU.UTF-8
en_BW.UTF-8
en_CA.UTF-8
en_DK.UTF-8
en_GB.UTF-8
en_HK.UTF-8
en_IE.UTF-8
en_NZ.UTF-8
en_PH.UTF-8
en_SC.UTF-8
en_SG.UTF-8
en_US.UTF-8
en_ZA.UTF-8
en_ZW.UTF-8
 > 

You want “en_US.UTF-8” – use:

 # localectl set-locale LANG=en_US.UTF-8
  • Systemd will be happy – ‘/etc/locale.conf’ will be written correctly but, you may well have an issue with your Keyboard … :frowning:

Check the output of “localectl” and, check the values of “VC Keymap”, “X11 Layout”, “X11 Model”, and “X11 Variant”.

  • The openSUSE default for “X11 Options
    ” is “terminate:ctrl_alt_bksp”.

Always use the following to setup the keyboards:


 > localectl list-keymaps
 > localectl list-x11-keymap-layouts
 > localectl list-x11-keymap-models 
 > localectl list-x11-keymap-variants *« your X11 keyboard layout »*


 # localectl --no-convert set-keymap *« your VC keymap »*
 # localectl --no-convert set-x11-keymap *« your X11 keymap layout » « your X11 keymap model » « your X11 keymap variant »* **terminate:ctrl_alt_bksp**

Be aware of legacy keymaps and legacy keymap options – check in ‘/usr/share/kbd/keymaps/’ and ‘/usr/share/X11/xkb/rules/’ and “man xkeyboard-config” …
[HR][/HR]Assuming that, your system doesn’t use the Locale “en_US.UTF-8” and, you have users who want to have US English language terminal sessions (with possibly a local keyboard layout), add the following line to each user’s ‘~/.profile’ file:

export LANG=en_US.UTF-8

If the user has a keyboard which doesn’t have the system’s keyboard layout then, within KDE Plasma “System Settings” → “Hardware” → “Input Devices” → “Keyboard” –

  • Each affected user will have to choose their
    Keyboard Layout.

You get what you configure: https://forums.opensuse.org/entry.php/241-Leap-Plasma-Locales-Configuration

I didn’t explain properly.
I have OpenSUSE in Portuguese
So, the output of commands in a terminal is in Portuguese
When I need to inform a result of a command here in this forum, it is better that the output is in English, right?
In the past, it was enough to put “LANG=en_US.UTF-8” before the command so that the output would be in English, even if my system was all in Portuguese. But that “LANG=en_US.UTF-8” doesn’t work anymore.
The question is: Is there a command that does the same thing as before?

You continue describing instead of showing facts. Provide output of

env | grep -E 'LANG|LC_'

followed by copy-paste of your full command invocation that outputs in the wrong language and its complete output.

Here’s the result:

sergio@psitivo:~> env | grep -E 'LANG|LC_' 
**LC_**MEASUREMENT=pt_BR.UTF-8 
**LC_**MONETARY=pt_BR.UTF-8 
**LANG**=pt_BR.UTF-8 
**LC_**COLLATE=pt_BR.UTF-8 
**LC_**NUMERIC=pt_BR.UTF-8 
**LANG**UAGE=en_US:pt_BR 
**LC_**TIME=pt_BR.UTF-8 
sergio@psitivo:~>  

And the current exit:

 
sergio@psitivo:~> LC_ALL=en_US.UTF-8 xxx                                                      
Se 'xxx' não for um erro de digitação, você pode usar o command-not-found para pesquisar o pacote que o contém, deste modo: 
    cnf xxx 
sergio@psitivo:~> xxx 
Se 'xxx' não for um erro de digitação, você pode usar o command-not-found para pesquisar o pacote que o contém, deste modo: 
    cnf xxx 
sergio@psitivo:~>  

It is just one half of what I requested.

What about

LC_ALL=en_US.UTF-8 LANGUAGE= xxx

In the past, it was, and still is, sufficient to type “LANG=C ” before the command.


 > man ls
Man: alle übereinstimmenden Handbuchseiten finden (set MAN_POSIXLY_CORRECT to avoid this)
 * ls (1)
   ls (1+2)
   ls (1p)
Man: Welche Handbuchseiten möchten Sie haben?
Man:  
 > 
 > LANG=C man ls
Man: find all matching manual pages (set MAN_POSIXLY_CORRECT to avoid this)
 * ls (1)
   ls (1p)
Man: What manual page do you want?
Man: 
 > 

Yep.

From https://www.gnu.org/software/gettext/manual/html_node/Locale-Environment-Variables.html

2.3.2 Locale Environment Variables

A locale is composed of several locale categories, see Aspects in Native Language Support. When a program looks up locale dependent values, it does this according to the following environment variables, in priority order:

  1. LANGUAGE
  2. LC_ALL
  3. LC_xxx, according to selected locale category: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES, …
  4. LANG

Variables whose value is set but is empty are ignored in this lookup.

When I need to inform a result of a command here in this forum, it is better that the output is in English, right?

Yep.

In the past, it was enough to put “LANG=en_US.UTF-8” before the command so that the output would be in English, even if my system was all in Portuguese. But that “LANG=en_US.UTF-8” doesn’t work any more.

Nope. Nothing has changed. LANGUAGE has highest, LANG has lowest priority. Presumably you tinkered with LANGUAGE.

Is that the another half?
[COTE]
sergio@psitivo:~> LC_ALL=en_US.UTF-8 LANGUAGE= xxx
Se ‘xxx’ não for um erro de digitação, você pode usar o command-not-found para pesquisar o pacote que o contém, deste modo:
cnf xxx
sergio@psitivo:~> [/COTE]

sergio@psitivo:~> env | grep -E 'LANG|LC_' 
**LC_**MEASUREMENT=pt_BR.UTF-8 
**LC_**MONETARY=pt_BR.UTF-8 
**LANG**=pt_BR.UTF-8 
**LC_**COLLATE=pt_BR.UTF-8 
**LC_**NUMERIC=pt_BR.UTF-8 
**LANG**UAGE=en_US:pt_BR 
**LC_**TIME=pt_BR.UTF-8 
sergio@psitivo:~> 


If “LANG-C” is enough, something is wrong
Look at the output:

sergio@psitivo:~> LANG=C xxx 
Se 'xxx' não for um erro de digitação, você pode usar o command-not-found para pesquisar o pacote que o contém, deste modo: 
    cnf xxx 
sergio@psitivo:~> 

Nothing is wrong. Variable assignment at the beginning of a command affects this command only. In this case no command is executed at all - the message is printed by your shell itself. Your shell has already set locale when it started and is not affected by those temporary variable assignments.

If nothing is wrong then why is the output still in Portuguese instead of English.
In the past when I typed “LANG=en_US.UTF-8 xxx”, the result came out in English even though my system is all in Portuguese
But now it doesn’t matter whether you use this command or not, the output is always in Portuguese

If you do not listen to explanation why do you ask?

bor@leap15:~> LANG=C man ls
Man: alle ?bereinstimmenden Handbuchseiten finden (set MAN_POSIXLY_CORRECT to avoid this)
 * ls (1)
   ls (1p)
Man: Welche Handbuchseiten m?chten Sie haben?
Man: 

I too have some strange effects on a system.

As user henk:

henk@boven:~> echo $LANG
nl_NL.UTF-8
henk@boven:~> aap
Als 'aap' geen typefout is dan kunt u command-not-found gebruiken om het pakket op te sporen dat het bevat, zoals deze:
    cnf aap
henk@boven:~> ls -l aap
ls: cannot access 'aap': No such file or directory
henk@boven:~> LANG=nl_NL.UTF-8 ls -l aap
ls: cannot access 'aap': No such file or directory
henk@boven:~> LANG=C ls -l aap
ls: cannot access 'aap': No such file or directory
henk@boven:~>

‘bash’ follows the LANG, but ‘ls’ refuses to interpret the LANG environment variable, neither when inherited from the bash parent, nor when set explicitly.

As user mgi:

mgi@boven:~> echo $LANG
en_US.UTF-8
mgi@boven:~> aap
If 'aap' is not a typo you can use command-not-found to lookup the package that contains it, like this:
    cnf aap
mgi@boven:~> ls -l aap
ls: cannot access 'aap': No such file or directory
mgi@boven:~> LANG=nl_NL.UTF-8 ls -l aap
ls: kan geen toegang krijgen tot 'aap': Bestand of map bestaat niet
mgi@boven:~> 

Here ‘ls’ interprets the explicit LANG.

I do not understand why henk has this problem.

Show output of

env | grep -E 'LC_|LANG'
type -a ls

both as henk and mgi.