Difficulty: ★☆☆☆☆
Locale Errors
Locale errors are not always obvious and some applications simply stop working without any hints at all - e.g. Gnome Terminal is very sensitive to incorrect configuration of locale.
TL:DR
- As root edit the file
/etc/locale.gen
- Enable the needed locales - including en_US.UTF-8 UTF-8 as fallback.
- Rebuild the locale database using the
locale-gen
script
Calamares installer
The Calamares installer adds the locales chosen to the end of /etc/locale.gen
so check the last lines of the file before editing - it looks something like this
###
#
# Locales enabled by Calamares
en_US.UTF-8 UTF-8
en_DK.UTF-8 UTF-8
da_DK.UTF-8 UTF-8
General locale configuration
From time to time an update may install locale.gen
as locale.gen.pacnew
- do not blindly overwrite your existing locale.gen. Before applying the new file - check the locales in use and reapply the configuration after applying the .pacnew file.
If you have been modifying locale and are having locale trouble ( KDE/Plasma ) it can be difficult to locate the offending setting because scripts and rc configurations can change locale outside the obvious locations.
The first place to look when dealing with KDE/Plasma is usually ~/.config/plasma-localerc.
Locale error message
When you get errors like these examples - it is not obvious what causes it
$ rofi
(process:1628): Rofi-WARNING **: 07:34:43.942: Failed to set locale.
$ sterminal
couldn't read from shell: Input/output error
child exited with status 1
tmux: invalid LC_ALL, LC_CTYPE or LANG
Check your settings
Obviously you need to replace the locale with something relevant for your system. I have written this using my system’s locale - en_DK for messages and da_DK for the rest of the system.
Check locale settings
$ localectl
System Locale: LANG=en_DK.UTF-8
LC_NUMERIC=da_DK.UTF-8
LC_TIME=da_DK.UTF-8
LC_MONETARY=da_DK.UTF-8
LC_PAPER=da_DK.UTF-8
LC_NAME=da_DK.UTF-8
LC_ADDRESS=da_DK.UTF-8
LC_TELEPHONE=da_DK.UTF-8
LC_MEASUREMENT=da_DK.UTF-8
LC_IDENTIFICATION=da_DK.UTF-8
VC Keymap: dk-latin1
X11 Layout: dk
X11 Model: pc105
Check installed locales
$ locale -a
C
en_DK.utf8
en_US.utf8
POSIX
The installed locales does not match the settings listed by localectl
- as you can see the da_DK part is missing.
Fix locale error
It is recommended to use the utf8 version unless you have compelling reasons to select otherwise.
Method 1
Edit /etc/locale.gen
and ensure that all in-use locales has been uncommented. For fallback messages enable en_US as well
$ sudo nano /etc/locale.gen
...
#cy_GB ISO-8859-14
da_DK.UTF-8 UTF-8
#da_DK ISO-8859-1
....
#en_CA ISO-8859-1
en_DK.UTF-8 UTF-8
#en_DK ISO-8859-1
...
#en_SG ISO-8859-1
en_US.UTF-8 UTF-8
#en_US ISO-8859-1
...
Method 2
Based on the comment by @nam1962 (see below).
Check if the locale you want to use is available in the locale list (/etc/locale.gen)
$ cat /etc/locale.gen | grep 'da_DK'
#da_DK.UTF-8 UTF-8
#da_DK ISO-8859-1
Use sed
command
-
To enable a locale (uncommenting the line)
$ sudo sed -i '/en_DK.UTF-8/s/^#//g' /etc/locale.gen $ sudo sed -i '/en_US.UTF-8/s/^#//g' /etc/locale.gen
-
To disable a locale (aka commenting the locale)
$ sudo sed -i '/en_DK.UTF-8/s/^/#/g' /etc/locale.gen
Rebuild locales
$ sudo locale-gen
Generating locales...
da_DK.UTF-8... done
en_DK.UTF-8... done
en_US.UTF-8... done
Generation complete.
Recheck your locales
$ locale -a
C
da_DK.utf8
en_DK.utf8
en_US.utf8
POSIX
Verify it works
➜ ~ rofi -r
Rofi is unsure what to show.
Please specify the mode you want to show.
rofi -show {mode}
The following modi are enabled:
* window
* run
* ssh
The following can be enabled:
* windowcd
* drun
* combi
* keys
To activate a mode, add it to the list of modi in the modi setting.