locale-gen generates not selected locales

I found, that on my home server, running Ubuntu Server 18.04, I've selected quite a few locales, I actually don't need. I only want en_US.UTF-8 and de_DE.UTF-8, since the whole system is configured to use only these.

So, first, I tried the "Debian way" by running dpkg-reconfigure locales and then deselected all besides the two I actually wanted. After that the system automatically regenerates the locales, but, unfortunately, more than I selected:

Generating locales (this might take a while)...
de_DE.UTF-8... done
en_AG.UTF-8... done
en_AU.UTF-8... done
en_BW.UTF-8... done
en_CA.UTF-8... done
en_DK.UTF-8... done
en_GB.UTF-8... done
en_HK.UTF-8... done
en_IE.UTF-8... done
en_IL.UTF-8... done
en_IN.UTF-8... done
en_NG.UTF-8... done
en_NZ.UTF-8... done
en_PH.UTF-8... done
en_SG.UTF-8... done
en_US.UTF-8... done
en_ZA.UTF-8... done
en_ZM.UTF-8... done
en_ZW.UTF-8... done

Then I tried directly editing /etc/locale.gen, but it's all fine in there, since only the two I actually want are not commented out, so it should work. I've checked the file multiple times from top to bottom.

Still, running locale-gen manually, yields the same result as above.

So I wonder if this is a bug or a feature? Is the file maybe cached somewhere or is there another configuration file I'm not aware of? I've already tried restarting the system, but as expected, this didn't change anything.


The many English locales are probably there because you installed the English language packs. You should see them by running:

cat /var/lib/locales/supported.d/en

So a way to make the list shorter is to remove the English language packs:

sudo apt purge language-pack-en language-pack-en-base language-pack-gnome-en language-pack-gnome-en-base