How to Set Locales (i18n) On a Linux or Unix

How to Set Locales (i18n) On a Linux or Unix

To set the locales (internationalization or i18n) on a Linux or Unix system, follow these steps:

  1. Determine which locales are available on the system. You can do this by listing the files in the /usr/share/i18n/locales directory:
refer to:‮‬lautturi.com
ls /usr/share/i18n/locales

This will show a list of all available locales, such as en_US.utf8 and fr_FR.utf8.

  1. Generate the locales that you want to use. You can do this by running the locale-gen command with the names of the locales as arguments. For example, to generate the en_US.utf8 and fr_FR.utf8 locales:
locale-gen en_US.utf8 fr_FR.utf8
  1. Set the default locale for the system by modifying the /etc/locale.conf file. Open the file in a text editor and add the following line:
LANG=en_US.utf8

Replace en_US.utf8 with the name of the desired default locale.

  1. Set the default locale for the current user by modifying the ~/.bashrc file. Open the file in a text editor and add the following line:
export LANG=en_US.utf8

Replace en_US.utf8 with the name of the desired default locale.

  1. Log out and log back in to apply the changes.

You can verify that the locale has been set by running

locale -a
Created Time:2017-10-29 22:08:35  Author:lautturi