Linux change language console

Switch command output language from native language to english

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

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.

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).

@EliahKagan On the contrary, it is very important to post actual error messages, and highly preferable to post them in English because that’s what the main audience of this site can recognize and test. (And never, ever post a re-translated error message. Always copy-paste, because the exact wording, punctuation, even spacing can be significant.)

9 Answers 9

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

If you want to revert to the native language, unset the LC_ALL variable:

Thats is problematic if you may want have output in other language than english. I did not be able to use any accentued character after this setting. askubuntu.com/a/818241/227400 was better.

It stops working after you close Konsole and open a new one. The new Konsole is in the old (non-English) language

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=$case $ 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" "$: unknown 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" "$"; 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.

Читайте также:  Userspace linux долгая загрузка

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

Источник

How do I change the language of the console permanently?

Is there a way I can change the language of the console? I have seen things such as adding LANG=C in front of the commands but that is a temporary fix. I can live with the Turkish console but when it comes to man and help commands it drives me nuts. I do not understand the Turkish terms used.

@Pilot6 that is not my problem. I want English to be my permanent language for the terminal. I don’t want to switch my keyboard layout. So not a duplicate of (askubuntu.com/questions/637148/…)

@JacobVlijm Layout? I am talking about the language the terminal uses to output data to me. I am not talking about my keyboard layout. Just a Menu+Space fixes that(altough I am used to Alt+Shift from windows).

3 Answers 3

Run the following command to save it in your ~/.bashrc file so that every time you open an interactive non-login terminal your locale will be set accordingly:

echo 'export LANG=C' >> ~/.bashrc 

Note that the C locale uses an ASCII character set, if you want Unicode then use a locale that supports it e.g.:

echo 'export LANG=en_US.UTF-8' >> ~/.bashrc 

To make changes available from the running session, source the ~/.bashrc file:

@heemayl I think for most tasks that the user needs, ~/.bashrc will be sufficient. It works for be in both ttys and graphical terminal,so . . .

I wish it would have worked. It did not. I checked the non login terminal. It did work there. I might want to try @Serg ‘s answer for this.

Put that into your ~/.bashrc file, where you define the prompt. Example:

So, basically in your homefolder, you can create .bashrc file, which is read by bash every time you open terminal. For example, I use it to define my prompt as PS1=’ serg@ubuntu ‘ . If I want a command to be run there every time I open terminal or run something in terminal, I add $( command ) to that PS1=’serg@ubuntu’ line, just like i showed.

I have a file in my ~/bin folder to get gnome-terminal in English:

$ cat ~/bin/gnome-terminal #!/bin/sh export LANGUAGE=en_US exec /usr/bin/gnome-terminal $@ 

( ~/bin is the first item in $PATH if it exists)

Please note that since the LANGUAGE variable is set more often than not in Ubuntu, and since gnome-terminal uses gettext, it’s LANGUAGE which needs to be changed, not LANG.

Источник

How to Change System Language (Locale) in Ubuntu and Debian?

Locale settings determine the operating system language and regional settings used in the terminal and in the graphical interface (date and time format, currency symbols, available character sets, etc.). This article will look at how to check or set locale settings on Linux distros (Ubuntu, Debian, Mint, etc.).

Читайте также:  Linux tar unpack directory

You can list the current locale settings in Ubuntu and Debian using the command:

get locale in ubuntu linux

LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE=»en_US.UTF-8″
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE=»en_US.UTF-8″
LC_MONETARY=en_US.UTF-8
LC_MESSAGES=»en_US.UTF-8″
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=

List of available locales on the host:

list available system locales

To display detailed information about the locales installed on the current Linux host:

The C.UTF-8 system locale is always present in this list. Let’s try to add the German locale de_DE.UTF-8.

The list of locales available for installation is listed in the file:

To install the locale you need, run the command:

locale-gen - generate new locale fles

You can also enable locales you need by uncommenting the lines in the file /etc/locale.gen:

/etc/locale.gen

To set the default locale, use the command:

$ sudo update-locale LANG=de_DE.UTF-8
$ sudo localectl set-locale LANG=de_DE.UTF-8

This command will write the following line to the /etc/default/locale:

Reboot the Linux host to apply the new locale settings.

You can set a separate locale for different parts of Linux, for example:

$ sudo update-locale LC_NUMERIC=en_US.UTF-8 LC_TIME=en_US.UTF-8 LC_MONETARY=en_US.UTF-8

If you specify a locale that has not yet been generated, the locale command will return errors:

locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=fr_FR.utf8

In some cases, you must first set the required locale:

$sudo apt-get install language-pack-fr

If the locale is not set on Linux and the locale -a command returns only three entries:

    You need to generate new locale settings:

sudo update-locale LANG=de_DE.UTF-8

For easier locale management on Debian and Ubuntu, you can use the dpkg-reconfigure tool.

With the following command you can generate, set, or remove locales on Linux:

$ sudo dpkg-reconfigure locales

The utility provides a simple pseudo-graphical interface. Select the locales to install.

dpkg-reconfigure locales

Then set the default locale (default locale for the system environment).

dpkg-reconfigure set default locale for the system environment

To change the encoding in the console (terminal), run the command:

$ sudo dpkg-reconfigure console-setup

Select UTF-8 encoding for the console, then choose which character set support to add.

dpkg-reconfigure console-setup

These settings are stored in:

$ cat /etc/default/console-setup

Then configure the keyboard:

$ sudo dpkg-reconfigure keyboard-configuration

The default recommended keyboard model is Generic 105-key PC. Then add the keyboard mappings (keymaps) for the desired country.

Keyboard settings are specified in the file:

It remains to set the time zone:

$ sudo dpkg-reconfigure tzdata

You can remove locales you don’t use. The list of installed locales is in /usr/lib/locale/locale-archive.

Читайте также:  Flutter install on linux

List the locales in the archive:

delete locales in linux with localedef

$ sudo localedef --delete-from-archive en_IN.utf8

Источник

How can I change language but only for the terminal?

How do I change the language of the terminal to English? I am familiar with using vi . If the terminal language is controlled by etc/default/locale , what am I supposed to change there?

LANG="el_GR.UTF-8" LANGUAGE="el:en" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" 

2 Answers 2

Tl; dr

since you want to set everything to English (assuming that programs using GNU gettext should use Greek as a fallback language):

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

Or if some LC_* variables are defined already in your shell’s environment and you wish to override them:

export LC_ALL=en_US.UTF-8 export LANGUAGE=en:el 

To make the settings stick, add the export s at the end of ~/.bashrc .

Changing /etc/default/locale will affect the whole system’s locale and consequently the locale of all users who didn’t set a specific locale, so you shouldn’t change it if you want to change only the language of the command running in your user’s terminal / console.

The locale of the commands running in your user’s terminal / console can be changed by exporting the following environment variables:

LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME 

LANG defines the value to be used for each non-explicitly defined LC_* variable; so if none of the LC_* variables is currently defined in your shell’s environment (that is the default behavior, if env | grep ‘^LC_’ doesn’t output anything it means that’s the case) and you wish to set the value of all the categories to en_US.UTF-8 , simply export LANG :

Otherwise you’ll have to either also override each previously defined LC_* variable or (alternatively, more easily) just export LC_ALL , which overrides any previously defined LC_* variable:

However programs using GNU gettext will rely on LANGUAGE rather than LANG / LC_ALL (unless LANG / LC_ALL is set to C ) and will set the language based on its content. LANGUAGE should define a list of colon-separated languages. If a translation for the first colon-separated language listed is not available, the program will try to use to the second colon-separated language listed etc; for example, to set English as the preferred language and Greek as a fallback language:

So in your case, since you want to set everything to English (assuming that programs using GNU gettext should use Greek as a fallback language):

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

Or if some LC_* variables are defined already in your shell’s environment and you wish to override them:

export LC_ALL=en_US.UTF-8 export LANGUAGE=en:el 

To make the settings stick, add the export s at the end of ~/.bashrc .

Источник

Оцените статью
Adblock
detector