19

I am French and use my Debian system in French.

However, I would like to have error messages in terminal in English. It allows me to post them on English speaking websites.

How can I change my locale to do so? I precise I don't want to have all my system in English.

ppr
  • 1,907
  • 7
  • 23
  • 40

4 Answers4

18

You have to change LANG and LANGUAGE variable in current shell.

Put

export LANG=en_US.UTF-8
export LANGUAGE=en

in your shell rc file ( for bash it is ~/.bashrc ) and restart the terminal session ( or just source the rc file one more time with source ~/.bashrc or even just restart bash with exec bash )

Note, that you have to generate this locale before.

Also you can use export LANG=C.

Also there are other LANG variables (from man bash):

   LANG   Used to determine the  locale  category  for  any  category  not
          specifically selected with a variable starting with LC_.
   LANGUAGE
          Used   to   set   messages   languages  (as  LC_MESSAGES)  to  a  
          multi-valued value, e.g., setting it to fr:de:en will use French  
          messages  where they exist; if not, it will use German messages,  
          and  will  fall  back  to  English  if neither German nor French  
          messages are available.  
   LC_ALL This  variable  overrides  the  value  of LANG and any other LC_
          variable specifying a locale category.
   LC_COLLATE
          This variable determines the collation order used  when  sorting
          the  results  of pathname expansion, and determines the behavior
          of  range  expressions,  equivalence  classes,   and   collating
          sequences within pathname expansion and pattern matching.
   LC_CTYPE
          This  variable  determines  the interpretation of characters and
          the behavior of character classes within pathname expansion  and
          pattern matching.
   LC_MESSAGES
          This  variable  determines  the locale used to translate double-
          quoted strings preceded by a $.
   LC_NUMERIC
          This variable determines the locale  category  used  for  number
          formatting.
AdminBee
  • 22,803
rush
  • 27,403
9

You can call an application with the following syntax:

For example you want the English manpages (for just a single command):

user@host:~# LC_ALL=C man ls

Or you run into an error (my system is in German):

user@host:~$ ls -la /root/
ls: Öffnen von Verzeichnis /root/ nicht möglich: Keine Berechtigung

user@host:~$ LC_ALL=C ls -l /root/
ls: cannot open directory /root/: Permission denied
chaos
  • 48,171
  • Useful (but I accepted another answer because my question was about permanently doing this). – ppr Dec 17 '13 at 17:30
  • 2
    more "C" than "c", "c" doesn't work on my Debian 8. – Tristan May 10 '17 at 09:19
  • I suggested an edit for LC_ALL=C instead of LC_ALL=c which fails too for me with message bash: warning: setlocale: LC_ALL: cannot change locale (c) – el-teedee Sep 08 '18 at 19:01
0

If you just want the error messages and not the whole locale, you can use:

export LC_MESSAGES=C

Krackout
  • 2,642
  • 12
  • 26
-2

Try referencing this: 1) https://wiki.debian.org/ChangeLanguage

In short, you want to set your LOCALE (via LANG), preferrably in your .bashrc.

export LANG=en_US.UTF-8
Anthon
  • 79,293
C. Kelly
  • 109
  • ok but I don't want to change my system language. I just want to have some error message in English. Changing the system language has plenty of consequences. – ppr Dec 17 '13 at 17:26
  • I beleive putting it in your .bashrc will only affect your shell, as well as any commands that read the .bashrc. If you omit "export", it will not be propagated to commands you start from that shell. – C. Kelly Dec 17 '13 at 17:29
  • @ckelly That changes a bunch of things besides the error message language. For example, sort orders, number formatting, ... – derobert Dec 17 '13 at 17:30
  • @ppr ok, but I don't want to change my system language — Why then did you accept an answer which gives the same "solution"? – Piotr Dobrogost Feb 15 '17 at 17:52