Skip to content

Install locales and change a server's locale

A server’s locale settings determine the language used in the output of some programs.

Installing additional locales enables the use of PHP’s setlocale() function so other functions such as localeconv() will return text formatted for a specific language or region.

List installed locales

To list a server’s installed locales, SSH into the server and run the following command.

Terminal window
locale -a

Example output of the command is shown below.

C
C.UTF-8
en_US.utf8
fr_BE.utf8
fr_CA.utf8
fr_FR.utf8
nl_BE.utf8
nl_NL.utf8
POSIX

List available locales

List all locales that are available for installation.

Terminal window
apt-cache search language-pack- | grep -v -E -- '-kde|-base|-gnome'

Install a locale

Locales can be installed through the server’s package manager. For example:

Terminal window
sudo apt-get install language-pack-de

If you installed a locale for use in a PHP app, restart the PHP version the app is using after installing a new locales.

Terminal window
sudo service php8.4-fpm-sp restart

Change the server’s locale

Use the update-locale command to change the server’s default locale. For example:

Terminal window
sudo update-locale LANG=de_DE.UTF-8 LC_MESSAGES=POSIX

There are many environment variables that control different aspects of locale settings. Learn more about changing a server’s locale.