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.

How can I switch the terminal output language from my native language to English, so I can post my Ask Ubuntu question with English terminal output (error messages)?

share|improve this question
4  
This is somewhat misleading. It is not actually necessary for people to do this. (If you think we should require OPs to burden themselves this way, please post on meta before instructing anyone to do so.) They can change LANG like this, and it might help, but we do not require copied error messages to be in English. We require what the author has written to be in English (though we usually translate it instead of closing questions). So a question written in English with Spanish terminal text is fine, while a question written in Spanish with English terminal text is not. –  Eliah Kagan Mar 5 '13 at 13:49
2  
@EliahKagan yes, you are right, but anyway I think it is useful. –  BuZZ-dEE Mar 5 '13 at 13:54
2  
I agree, it is useful for people to be able to do this, and good you've posted this question! However, it's important people know we don't require them to do this (but do require that questions and answers themselves be written in English). –  Eliah Kagan Mar 5 '13 at 13:56

3 Answers 3

up vote 5 down vote accepted

export LC_ALL=C is enough. All subsequent command output will be in english.

share|improve this answer

bash function for terminal

Here is my bash function to switch between DE and EN locales.

You may extend this code with your preferred languages. To use this, put it in your ~/.bashrc (or ~/.bash_profile)-

Call it with _configure_locale EN to switch to English.

function _configure_locale() { # [profile]
    local profile=${1:-EN}
    case ${profile} in
      DE|DE_DE|de_DE)
          LC_ALL="de_DE.UTF-8"
          LANG="de_DE.UTF-8"
          LANGUAGE="de_DE:de:en_US:en"
          ;;
      EN|EN_US|en|en_US)
          LC_ALL="en_US.UTF-8"
          LANG="en_US.UTF-8"
          LANGUAGE="en_US:en"
          ;;
      *)
          echo "ALERT" "${FUNCNAME}: unknown profile '${profile}'"
          ;;
      esac
      LC_PAPER="de_DE.UTF-8"; # independent from locale
      LESSCHARSET="utf-8";    # independent from locale
      MM_CHARSET="utf-8"      # independent from locale
      echo "locale settings" "${LANG}";
      export LC_ALL LANG LANGUAGE LC_PAPER LESSCHARSET MM_CHARSET
}

In general I suggest to change all 3 environment variables LC_ALL, LANG, LANGUAGE to avoid misbehaviours of some programs.

Adapting to your language

Extending the code to your native language is quite simple. You can find the needed values by invoking the following command

env |egrep -e 'LC_ALL|LANG'
share|improve this answer
    
The script needs changing for another language than German (DE)? I search for a solution independent from the native language. –  BuZZ-dEE Mar 5 '13 at 23:48
    
@BuZZ-dEE: You can (and probably should) easily adapt this by throwing out the case and specifying the input to conform to the <lang>_<country> format. Then you can just pass it through, assuming UTF-8. If you're really keen on a tidy solution, you should probably check the user input against locale -a to make sure the requested locale is actually installed. –  bitmask Mar 6 '13 at 0:30
    
@buzz-dee: see updated answer –  H.-Dirk Schmitt Mar 6 '13 at 16:27

Open a terminal Ctrl+Alt+T and type:

LANG=en_US.UTF-8 bash

or:

LC_ALL=C bash

Now the terminal output is in english language. You can check it with locale.

It is possible to make a command to do that with a permanent alias. Open the .bashrc file with your preferred editor and put the following code in there:

alias basheng='LANG=en_US.UTF-8 bash'

or:

alias basheng='LC_ALL=C bash'

Restart the Bash shell. Now you have the command basheng. Type it in the Bash to get an english Bash shell. To leave the english shell type exit.

Source:

share|improve this answer
    
Setting LANG is not sufficient to chance all output. –  bitmask Mar 5 '13 at 19:12
    
@bitmask is this: LANG=en_US.UTF-8 && LC_ALL=en_US.UTF-8 && LANGUAGE=en_US.UTF-8 bash better? –  BuZZ-dEE Mar 5 '13 at 23:46
2  
Actually, that should be LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LANGUAGE=en_US.UTF-8 $SHELL. –  bitmask Mar 6 '13 at 0:27

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.