Changing the locale on the server

Commands for managing the locale on the Ubuntu server.

Many processes on the server depend on the locale. For example, locale affects basic displays on a site, such as seasons and days of the week. It can interfere with the import / export of databases (if the locales are different) or have a different collation in it. For example, PostgreSQL.

Adding a new locale to the server

List all installed locales on the server:

Reflect the current locale:

Add the desired locale:

sudo locale-gen en_US.UTF-8

Or Russian:

sudo locale-gen ru_RU.UTF-8

And update locales:

Changing the current locale

Change something specific in the locale (will be changed only during the current session):

export LC_ALL=“en_US.UTF-8”

export LC_TIME=“ru_RU.UTF-8”

For permanent changes, add here:

sudo nano /etc/default/locale

For example, add or edit:

LANG=“ru_RU.UTF-8”
LANGUAGE=“ru_RU.UTF-8”
LC_CTYPE=“C.UTF-8”
LC_NUMERIC=“ru_RU.UTF-8”
LC_TIME=“ru_RU.UTF-8”
LC_COLLATE=“C.UTF-8”
LC_MONETARY=“ru_RU.UTF-8”
LC_MESSAGES=“ru_RU.UTF-8”
LC_PAPER=“ru_RU.UTF-8”
LC_NAME=“ru_RU.UTF-8”
LC_ADDRESS=“ru_RU.UTF-8”
LC_TELEPHONE=“ru_RU.UTF-8”
LC_MEASUREMENT=“ru_RU.UTF-8”
LC_IDENTIFICATION=“ru_RU.UTF-8”

Or automatically add change some value in that file:

sudo localectl set-locale LANG= en_US.UTF-8
sudo localectl set-locale LANG= ru_RU.UTF-8

Update the changes made:

Similar Posts

Leave a Reply