brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: locale-gen nl_NL.UTF-8 builds a locale on Ubuntu, update-locale makes it the default

Ubuntu
~/tips/tip-ubuntu-locale-gen-update-locale

sudo locale-gen nl_NL.UTF-8

Compiles one locale and sets it as the system default without editing files by hand.

I live in the Netherlands, so Dutch date and number formats are something I’d want on a fresh Ubuntu install. A minimal install only ships a few locales, though, and setting LANG to one that doesn’t exist silently falls back to something else.

sudo locale-gen nl_NL.UTF-8
locale -a
sudo update-locale LANG=nl_NL.UTF-8

The man page explains that only templates are shipped, and that the locales you want are compiled on the machine by locale-gen, using the list in /etc/locale.gen. The page documents only that file-based route. On Ubuntu 24.04, giving the locale name as an argument also worked: it printed nl_NL.UTF-8... done and Generation complete., and the matching line in /etc/locale.gen had been uncommented afterwards. locale -a then listed nl_NL.utf8 next to C, C.utf8 and POSIX.

Compiling a locale doesn’t select it. update-locale LANG=nl_NL.UTF-8 does that: on the same machine it wrote LANG=nl_NL.UTF-8 into /etc/default/locale. Running LANG=nl_NL.UTF-8 locale shows the effect immediately for one command, and there LC_CTYPE came out as "nl_NL.UTF-8".

The names you can build are in /usr/share/i18n/SUPPORTED, which the man page describes as the list of all supported locales on the system. If you’d rather not compile anything, the man page also mentions the locales-all package, which has all supported locales in compiled form.

Caveats: locale-gen without arguments rebuilds everything listed in /etc/locale.gen, and the man page notes that --keep-existing avoids removing the existing locale archive.

Further reading: locale-gen(8), Ubuntu man page

Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more

More Ubuntu tips sudo ubuntu-drivers list --gpgpu sudo apt install ppa-purge grep ^Prompt /etc/update-manager/release-upgrades sudo tee /etc/update-motd.d/60-disk >/dev/null <<'EOF' ubuntu-bug openssh-server All Ubuntu tips (10) All topics

Link