Как поменять locale ubuntu

Обновлено: 04.07.2024

This wiki page is a work in progress. There is precious little documentation covering locales, either in books or on the web. It will take either a) a bit of time, or b) a professional, to make this page a good reference. Three question marks are a placeholder for information that is lacking.

Locales customize programs to your language and country. When you installed Ubuntu, you answered some simple questions such as specifying your country and language. Ubuntu used the answers to those questions, in part, to choose a suitable locale for your installation.

The basic functionality is provided by the locales package, which is installed by default. Actual locales are installed separately via the language-pack-* packages.

Most users want a single locale to be used for all aspects of their session. In this case, the GUI provided by System Settings -> Language Support does the right thing.

This page is about more fine-grained, non-GUI customization.

The command 'locale -a' will show which locales are available on your system:

A piece of software is expected to utilize one or more of the installed locales, depending on a couple of environment variables, each covering a different aspect (a locale category). To list those variables and see their current value, use:

In the output of the above query, you will see entries for: LANG Provides default value for LC_* variables that have not been explicitly set. LC_ADDRESS How addresses are formatted (country first or last, where zip code goes etc.). LC_ALL Overrides individual LC_* settings: if LC_ALL is set, none of the below have any effect. LC_COLLATE How strings (file names. ) are alphabetically sorted. Using the "C" or "POSIX" locale here results in a strcmp()-like sort order, which may be preferable to language-specific locales. LC_CTYPE How characters are classified as letters, numbers etc. This determines things like how characters are converted between upper and lower case. LC_IDENTIFICATION Metadata about the locale information. LC_MEASUREMENT What units of measurement are used (feet, meters, pounds, kilos etc.). LC_MESSAGES What language should be used for system messages. LC_MONETARY What currency you use, its name, and its symbol. LC_NAME How names are represented (surname first or last, etc.). LC_NUMERIC How you format your numbers. For example, in many countries a period (.) is used as a decimal separator, while others use a comma (,). LC_PAPER Paper sizes: 11 x 17 inches, A4, etc. LC_RESPONSE Determines how responses (such as Yes and No) appear in the local language LC_TELEPHONE What your telephone numbers look like. LC_TIME How your time and date are formatted. Use for example "en_DK.UTF-8" to get a 24-hour-clock in some programs.

Any environment variable may be set on the command line for the current process:

If you want more fine-grained control, you may manually change your system's locale entries by modifying the file /etc/default/locale (or the user-specific $HOME/.pam_environment, which can be set by gnome-language-selector as well).

For example on a German system, to prevent system messages from being translated, you may use:

Note: changes take effect only after a fresh login.

Older releases, at least before Lucid (when did this change?), required modifying the file /etc/environment.

As an alternative to editing these files by hand update-locale may be used (this applies to older releases as well, at least before Raring):

If none of the above worked for you there is an option to change the actual definition of a locale. You need to edit a file with your locale, for instance:

and then recompile locale definition files by:

Read the man page for more information.

Installing a language-pack usually implies the creation of a file under /var/lib/locales/supported.d, named by language code (i.e. 'fr' for French), listing all locales that shall be generated.

Generation of locales is then automatically triggered as part of the installation process.

In order to trigger generation manually, do:

You may also generate new locales by issuing:

This will also append the specified locale to /var/lib/locales/supported.d/local for future regenerations.

The gnome display manager (GDM) has its own settings, including GDM_LANG for example, and is known to change locale settings when running /etc/gdm/Xsession. You may want to examine GDM's cache (/var/cache/gdm/$USER/dmrc) and restart GDM.


Для того, чтобы эти логи нормально отображались нам и нужно явно указать locale в Debian, Ubuntu или какой Linux-дистрибутив Вы используете.

Проблемы отображения кириллических символов в Linux не существует. Есть проблема у русской версии Windows. Весь мир и Linux в том числе, работает в кодировке UTF -8, когда русская версия Microsoft использует CP1251. Такая ситуация сложилось исторически благодаря компании «Парус», которая взяла на себя обязательства по локализации всех операционных систем Windows. Выбрали они почему-то кодировку CP1251, которая применяется до сих пор. Использование этой «неправильной» кодировки в наши дни обусловлено сохранением совместимости всех версий ОС.

Чтобы добавить кириллицу, чтобы Linux сервер нормально отображал русские буквы, нужно объяснить ему, что необходимо работать в той же кодировке, что и Windows.

Для того, чтобы управлять локалью в Linux, необходим пакет locales, который должен быть у Вас установлен. В большинстве случаев пакет locales уже будет у Вас установлен, поэтому для проформы просто проверяем этот факт.

Посмотреть установленную locale linux можно командой:

Для ручного указания кодировке в Linux Mint, Debian или ubuntu нужно отредактировать конфигурационный файл /etc/locale.gen :

Команду sudo не нужна, если Вы зашли как суперпользователь. Это относится к Linux Mint и Ubuntu, так как Debian ничего не знает о команде sudo.

В этом файле необходимо найти строчку и расскомментировать с той locale, которая Вам нужна. Для добавления кириллицы нужно раскомментировать строчки с UTF-8 или CP1251 .

  • если хотим указать, чтобы ОС работала в UTF -8, раскомментирум:
  • если хотим указать, чтобы ОС работала в CP1251, раскомментирум:

Стоит обратить внимание, что первые 2 символа (в нашем примере это ru) говорят нам о языке локализации (кириллица).

После этого переопределяем настройки locales командой:

Команда locale-gen позволяет запустить скрипт /etc/locale.gen и перечитывает все кодировки для консоли.

Чтобы увидеть кириллицу в консоли Linux, остается только перелогиниться.

Комментарии

Попробую применить ваши методы, не знаю, что из этого выйдет, но просмотрим.

Читайте также: