Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 9 down vote accepted

There are several environment variables available for changing language setting. You can view your current locale settings by executing the locale command. To change all locale settings, use LANG=C. The locale as used in C is English and always available without installing additional language packs. 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=
share|improve this answer
2  
For other users having issues getting this to work - setting LANG or LANG_ALL isn't working for me, yet LANGUAGE is. See Why is overriding the LANG environment variable not changing the language for me? –  gertvdijk Jun 23 '13 at 16:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.