Question regarding language setting in a command

Hi all, :wave:

I was just wondering how exactly the LANG environment variable works.

On my system (Linux Lite 6.2) the default is:

echo $LANG
de_DE.UTF-8

That´s o.k. so far. Now I want to get the output of a certain command in English. So I prepend the command thus
(as an example I´m using the command for a simulated installation of a package):

env LANG=en_GB:en apt-get -s install lowdown
NOTE: This is only a simulation!
      apt-get needs root privileges for real execution.
      Keep also in mind that locking is deactivated,
      so don't depend on the relevance to the real current situation!
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  lowdown
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Inst lowdown (0.10.0-1 Ubuntu:22.04/jammy [amd64])
Conf lowdown (0.10.0-1 Ubuntu:22.04/jammy [amd64])

That works as desired. It´s the British variant. It also works with the American variant. :+1:

However using the command env LANG=en_US.UTF-8 apt-get -s install lowdown , i.e. including “UTF-8”, the language setting is ignored and I still get the German output :thinking: :

env LANG=en_US.UTF-8 apt-get -s install lowdown
HINWEIS: Dies ist nur eine Simulation!
         apt-get benötigt root-Privilegien für die reale Ausführung.
         Behalten Sie ebenfalls in Hinterkopf, dass die Sperren deaktiviert
         sind, verlassen Sie sich also bezĂĽglich des reellen aktuellen
         Status der Sperre nicht darauf!
Paketlisten werden gelesen… Fertig
Abhängigkeitsbaum wird aufgebaut… Fertig
Statusinformationen werden eingelesen… Fertig
Die folgenden NEUEN Pakete werden installiert:
  lowdown
0 aktualisiert, 1 neu installiert, 0 zu entfernen und 1 nicht aktualisiert.
Inst lowdown (0.10.0-1 Ubuntu:22.04/jammy [amd64])
Conf lowdown (0.10.0-1 Ubuntu:22.04/jammy [amd64])

Does anyone know why that is :question:

Many thanks in advance and many greetings from Rosika. :slightly_smiling_face:

I don’t know, but have a suspition:

locale -a

Outputs a list of possible locales, which are available on your system.
If you set something in env to a possible value, it will be accepted.
If you set there something unvailable, I guess it does nothing and your system default will be used - hence the german output…

According to my quick lookup, you should run

sudo locale-gen en_US.UTF-8
sudo update-locale 

and then try again.

3 Likes

Hi László, :wave:

thanks for your reply.

On my system:

locale -a
C
C.utf8
de_DE.utf8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IL
en_IL.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
POSIX

So there is

en_GB.utf8

and

en_US.utf8

No idea, but wouldn´t the command sudo locale-gen en_US.UTF-8 try to create something that is already there :question:

Just asking…

Thanks again nad many greetings
Rosika :slightly_smiling_face:

1 Like

I have no idea. But it wont hurt.
If I make a change on my system, which may have a doubtful outcome, I take a snapshot, so I can do a full system restore.
So if you are afraid, locale-gen overwrites something, take a snapshot beforehand. I use Systemback script, others use Timemachine(?).

2 Likes

Thanks, László, for your suggestion. :+1:

You´re very right. Taking a snapshot is certainly a good idea.
As timeshift is installed by default on my system (and I have it running anyway) I think I´ll use it for that purpose.

Many greetings from Rosika :slightly_smiling_face:

2 Likes