Monday, April 29, 2024
27
rated 0 times [  27] [ 0]  / answers: 1 / hits: 15424  / 2 Years ago, tue, april 19, 2022, 8:17:34

Messages in my terminal are displayed using Russian language by default, which is my native one.



For just a moment I want them to be in English (eg. to paste in forums), then switch back to the default language.



How can I do the switch and switch back using bash?


More From » command-line

 Answers
1

There are several environment variables available for changing language settings. You can view your current locale settings by executing the locale command. To change all locale settings to English, use LANG=C. This C locale is always available without installing additional language packs. (In order to temporarily change to non-English locales, see @mklement0's post.)



Examples:



Executing a command with the default language settings and print the current locale settings:



$ /nonexistent
bash: /nonexistent: Bestand of map bestaat niet
$ locale
LANG=nl_NL.UTF-8
LANGUAGE=
LC_CTYPE="nl_NL.UTF-8"
LC_NUMERIC="nl_NL.UTF-8"
LC_TIME="nl_NL.UTF-8"
LC_COLLATE="nl_NL.UTF-8"
LC_MONETARY="nl_NL.UTF-8"
LC_MESSAGES="nl_NL.UTF-8"
LC_PAPER="nl_NL.UTF-8"
LC_NAME="nl_NL.UTF-8"
LC_ADDRESS="nl_NL.UTF-8"
LC_TELEPHONE="nl_NL.UTF-8"
LC_MEASUREMENT="nl_NL.UTF-8"
LC_IDENTIFICATION="nl_NL.UTF-8"
LC_ALL=


Temporarily override the language for one program and show that it is really temporary:



$ LANG=C ls /nonexistent
ls: cannot access /nonexistent: No such file or directory
$ ls /nonexistent
ls: kan geen toegang krijgen tot /nonexistent: Bestand of map bestaat niet


Change the locale for all commands executed in the current shell and include proofs again:



$ LANG=C
$ ls /nonexistent
ls: cannot access /nonexistent: No such file or directory
$ locale
LANG=C
LANGUAGE=
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=

[#38087] Wednesday, April 20, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
whoppinolo

Total Points: 93
Total Questions: 113
Total Answers: 107

Location: Cyprus
Member since Mon, Oct 24, 2022
2 Years ago
whoppinolo questions
Tue, Feb 14, 23, 08:30, 1 Year ago
Wed, Sep 28, 22, 06:56, 2 Years ago
Fri, May 27, 22, 01:55, 2 Years ago
Tue, Oct 12, 21, 09:33, 3 Years ago
;