How do I change the default locale in Ubuntu Server?

Run the command locale - it should show your current locale.

Generate the locales for french:

sudo locale-gen fr_FR
sudo locale-gen fr_FR.UTF-8

Also, try regenerating the supported locale list by running:

sudo dpkg-reconfigure locales

And update/change the current default locale:

sudo update-locale LANG=fr_FR.UTF-8

Update

Extra steps to try:

  1. Try:

    sudo update-locale LANG="fr_FR.UTF-8" LANGUAGE="fr_FR"
    sudo dpkg-reconfigure locales
    
  2. Perhaps adding LANG and LANGUAGE in /etc/environment could force a change. Try logout/login or rebooting.

  3. locale will show your current locale for the current user. Perhaps it's worth checking out these files just to be sure no local language variables are set: ~/.profile ~/.bashrc ~/.bash_profile

More info:

  • https://help.ubuntu.com/community/Locale
  • https://serverfault.com/questions/228474/correctly-changing-default-locale-in-ubuntu-server-10-04-lts

I tried everything from sudo locale-gen and sudo update-locale to sudo update-locale, and manually making entries in /etc/default/locale and /etc/environment with and without restarting.

Nothing seemed to work and my Python code was still throwing a Unicode error on Ubuntu 18.04l. Finally modifying the environment variable in ~/.bashrc worked.

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

Of course don't forget to source ~/.bashrc

I know it's not the recommended way, but nothing else worked for me.


You also have to edit /etc/profile:

export LANG="en_US.utf8"
export LANGUAGE="en_US.utf8"
export LC_ALL="en_US.utf8"