Optimizing Ubuntu: Remove Useless Locales from Debian-based Distributions
How-to optimize Ubuntu, removing useless locales from the Debian-based operating system
I know, Ubuntu is a great Linux distribution, which comes with lots of useful pre-compiled packages… but sometimes there are just too many. I spent years in trying to get rid of useless features from the operating system and I’ll share my results here — as well as in a series of other stories. Being a Debian-based solution, you may be able to do the same elsewhere (on the official derivatives like Ubuntu Budgie that I love, for example). I’m Italian, so I don’t need the different English localizations, coming from a standard installation.
English is crucial for my job, but I don’t like to have a hybrid system that speaks two or more languages and Ubuntu supports Italian since its first releases: below, I’ll try to show how-to make it speak only your mother tongue. Although this short guide is based on version 20.04 LTS, most of the commands work on earlier versions yet. Of course, I’m going to use an
it suffix for packages, while you should change them accordingly in each code snippet. Let’s start removing useless dictionaries, locales, etc. from Linux.
$ sudo apt-get purge aspell-en language-pack-gnome-en-base language-pack-gnome-en language-pack-en-base language-pack-en wbritish
Some notes. First of, depending on your country, you may have
wamerican instead of
wbritish or both: I use to install a minimal system from the wizard, but a full installation provides even more localization packages (such as
en_ZA, and so on). Check your Ubuntu 20.04 LTS box to see if you should also remove them; don’t restart before installing your own locales or you may get in trouble! As you see, I’m stuck with
apt-get since I don’t like the “new”
apt command much. You can always choose whatever you prefer.
$ sudo apt-get install aspell-it language-pack-gnome-it-base language-pack-gnome-it language-pack-it-base language-pack-it witalian
Again, if you use a desktop environment different from GNOME, you should replace some mentioned packages with your own. I noticed that recently the Ubuntu team spent a big effort to reduce the localization issues I had several years ago. This means that you won’t have to change many configuration files as I used to do in the past. Installing and uninstalling these packages should be enough for most: we’ll see how-to remove unwanted non-latin fonts in the near future. Yet another thing for those who speak a very common language.
$ cd /var/lib/locales/supported.d/
$ sudo nano it it_IT.UTF-8
Italian, like Spanish, is spoken in many countries. That’s why I had to remove
it_CH.UTF-8 from the list: it’s about Swiss people. I don’t know if you have similar needs, but you’ll find every supported locales in that folder. Removing the English localization from Ubuntu also removes the longer
en file here; apparently, now you shouldn’t edit any other configuration document. Restart the system (or logout from the session, then login again) to see the changes. You could even stop here, if you don’t have the following programs installed!
$ sudo apt-get install localepurge
If you want to prevent future packages from generate unwanted locales, then you may install
localepurge. This utility let you select which languages to get on your system: in my example, just
it_IT.UTF-8. It works every time you add new software via either
dpkg on Bash; you’re not satisfied yet? Lastly, it’s possible to instruct
locale-gen for locales generation by hand. Remember to keep all the variants you need, although I go on showing a single one. Depending on your language, you could have additional special characters.
$ sudo echo "it_IT.UTF-8 UTF-8" > /etc/locale.gen
$ sudo locale-gen
That’s it. Below, I’ll show some advices for common programs pre-installed on Ubuntu: they have specific locale packages, while libraries on the other hand depend on
locale-gen. I know, this guide isn’t really helpful for those who used Linux for years… but newer users may be a bit confused at first. TBH, you should re-install all the available packages for these changes to take effect at 100%; it’s possible and doesn’t take too much time, although I don’t suggest you to do so. I did it in the past without significant improvements on any side.
I have mixed feelings for this browser, since it was the first I used to write code for, but now I’m spending more time on Chrome. BTW, it’s Ubuntu default choice and it comes with dedicated localization packages: as usual, check for your language to substitute mine — where needed. This has nothing to do with grammar checking; I remember that once you could correct spelling errors, installing custom dictionaries, but I can’t find the same option in newer versions. They were separated from Mozilla’s extensions though.
$ sudo apt-get purge firefox-locale-en && sudo apt-get install firefox-locale-en
Chrome, as well as other browsers, doesn’t need this. Your operating system language will be selected automatically: Thunderbird (if you are still using it) works like Firefox. Notice that custom locales are more important when you install software after the first Ubuntu setup. Choosing a standard installation, for example, gives you what you need along with the English language; so, you won’t have to manually add yours — but only to remove the previous one. That’s how localization works on Debian-based distributions… just saying.
If localizing Firefox is easy, LibreOffice needs more attention since you may want to add a dictionary to check for spelling errors. Linux has plenty and every project gets its favourite:
myspell had been removed from Ubuntu, for example, and replaced by
hunspell. But the suite needs two more equivalent locale packages to enable grammar checking! You can always add custom dictionaries from the web, if you like; anyway (as long as your language is supported) official repositories have all you need to install for working with.
$ sudo apt-get purge hunspell-en hyphen-en mythes-en libreoffice-help-en libreoffice-l10n-en && sudo apt-get install hunspell-it hyphen-it mythes-it libreoffice-help-it libreoffice-l10n-it
This ensures a full localization of all the programs included in LibreOffice. Honestly, I don’t know much about other productivity suites: I tried Apache OpenOffice once and I found it well-done, but I’ve never really adopted it on Ubuntu — as well as on Windows. I still have to learn how-to use these instead of Office 365… anyway, look no further. I spent hours in looking for grammar support in my language and it just needed those packages to work. The key was adding
aspell doesn’t comply).
OK, the last one requires some more words. I like The GIMP on all the platforms where it’s available, but you may want to keep it as-is: you can find several tutorials on the web, referencing menus and tools in English. I asked myself if localizing it would have reduced the possibilities of learning something new. It does, if you don’t get time to look for a good translation; BTW, apart from dedicated plugins (such as Resynthesizer) most of the Photoshop CC guides can be adapted. Let’s see how-to go on with this too.
$ sudo apt-get purge gimp-help-en && sudo apt-get install gimp-help-it
Yes, The GIMP requires a single package to obtain a localized documentation. GNOME itself supplies the interface translation! Notice that you can also get rid of both packages: offline help isn’t needed to work with it. Unfortunately, language supports in plugins can’t be provided by the desktop environment, so you may have a program that speaks your mother tongue only for its main functionalities — or you can start contributing to the locale support. Here’s why I don’t even know if getting The GIMP translated is actually a great idea.
As I’ve said before, programs follow mainly two directions: some include languages different from English in their own package, using tools like
gettext, some require one or more dedicated packages. I know people who keep Ubuntu as-is, without applying any translation, but this may conflicts with your keyboard; I have an English layout only for my Raspberry Pi 3 and my laptops lack support for many special characters. Luckilly, Linux lets you print backtick and tilde on any keyboard you own… and that’s what I need.
In the end, localizing Ubuntu and removing useless translation packages is now by far easier that it used to be. Another big topic is about font optimization: I don’t need non-latin characters on my Linux box, so I manually remove all those “exotic” fonts. I know that boosting performances need many more interventions, but working with pre-compiled packages requires a different approach from rolling releases — and every upgrade could change what you learned. I like to keep my tutorials up-to-date for myself too.