How to setup the locales? [Solved]

Compiz, KDE, Gnome, Fluxbox, etc...

Moderator: Moderators

msdobrescu
Old Dear Hen
Posts: 867
Joined: Sun Aug 21, 2011 8:48

How to setup the locales? [Solved]

Post by msdobrescu » Thu Feb 27, 2020 16:47

Hello,

I have updated today and something has happened to the locales.
I have had already set in KDE Regional Settings Plasma translations American English (Default), and Romanian & French as alternatives.
The formats were ro_RO (Romanian/Romania).

Now, KDE (5.18.1) is in English, as expected. Also Firefox.

But Gnome apps are in Romanian, Rigo in Romanian, bash/sh are in Romanian.

This is on two computers.

A desktop:

Code: Select all

locale
LANG=ro_RO.UTF-8
LC_CTYPE="ro_RO.UTF-8"
LC_NUMERIC="ro_RO.UTF-8"
LC_TIME="ro_RO.UTF-8"
LC_COLLATE="ro_RO.UTF-8"
LC_MONETARY="ro_RO.UTF-8"
LC_MESSAGES="ro_RO.UTF-8"
LC_PAPER="ro_RO.UTF-8"
LC_NAME="ro_RO.UTF-8"
LC_ADDRESS="ro_RO.UTF-8"
LC_TELEPHONE="ro_RO.UTF-8"
LC_MEASUREMENT="ro_RO.UTF-8"
LC_IDENTIFICATION="ro_RO.UTF-8"
LC_ALL=
A laptop:

Code: Select all

locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=ro_RO.UTF-8
LC_CTYPE="ro_RO.UTF-8"
LC_NUMERIC="ro_RO.UTF-8"
LC_TIME="ro_RO.UTF-8"
LC_COLLATE="ro_RO.UTF-8"
LC_MONETARY="ro_RO.UTF-8"
LC_MESSAGES="ro_RO.UTF-8"
LC_PAPER="ro_RO.UTF-8"
LC_NAME="ro_RO.UTF-8"
LC_ADDRESS="ro_RO.UTF-8"
LC_TELEPHONE="ro_RO.UTF-8"
LC_MEASUREMENT="ro_RO.UTF-8"
LC_IDENTIFICATION="ro_RO.UTF-8"
LC_ALL=
Also, on the laptop, I see equo/rigo errors:

Code: Select all

/var/tmp/entropy/sys-power/bbswitch-0.8-r2#5.4.0-sabayon/v1g_pun5/portage/sys-power/bbswitch-0.8-r2/temp/environment: line 160: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
/var/tmp/entropy/sys-power/bbswitch-0.8-r2#5.4.0-sabayon/v1g_pun5/portage/sys-power/bbswitch-0.8-r2/temp/environment: line 163: warning: setlocale: LC_MESSAGES: cannot change locale (en_US.UTF-8): No such file or directory
/var/tmp/entropy/sys-power/bbswitch-0.8-r2#5.4.0-sabayon/v1g_pun5/portage/sys-power/bbswitch-0.8-r2/temp/environment: line 166: warning: setlocale: LC_NUMERIC: cannot change locale (en_US.UTF-8): No such file or directory
/var/tmp/entropy/sys-power/bbswitch-0.8-r2#5.4.0-sabayon/v1g_pun5/portage/sys-power/bbswitch-0.8-r2/temp/environment: line 169: warning: setlocale: LC_TIME: cannot change locale (en_US.UTF-8): No such file or directory
and

Code: Select all

/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
>>> Regenerating /etc/ld.so.cache...
sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
>>> Regenerating /etc/ld.so.cache...
sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
>>> Regenerating /etc/ld.so.cache...
sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
>>> Regenerating /etc/ld.so.cache...
sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
>>> Regenerating /etc/ld.so.cache...
sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
>>> Regenerating /etc/ld.so.cache...
sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
>>> Regenerating /etc/ld.so.cache...
sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
>>> Regenerating /etc/ld.so.cache...
sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
I'd prefer to have English in the UI and region as Romania (for the timezone) and numbers formats and currency as Romanian.

What are the right steps for that?

Thanks in advance!

msdobrescu
Old Dear Hen
Posts: 867
Joined: Sun Aug 21, 2011 8:48

Re: How to setup the locales?

Post by msdobrescu » Sat Feb 29, 2020 8:47

Hi, I have removed the UI translations for Romanian and French, because I've got random texts in several languages.
As I've set English for default, I would have expected to have English messages everywhere.
But no, KDE was in English only, but shell was once in Romanian, once in French, some messages in English. This is weird at least.
Gnome/GTK apps seems to fall to the region settings...
Too bad if some user needs a different locale than other...

Fitzcarraldo
Sagely Hen
Posts: 8217
Joined: Sat Mar 10, 2007 5:40
Location: United Kingdom
Contact:

Re: How to setup the locales?

Post by Fitzcarraldo » Sat May 09, 2020 23:25

Below is an example of how to configure the desired time zone, locales and keymaps in an SL installation.

For the sake of illustration, let's say I had previously configured SL only to use the en_GB and en_US locales, and I now want to switch to Swiss Italian:

Check if the desired time zone exists:

Code: Select all

# timedatectl list-timezones | grep Zurich
Europe/Zurich
Set the desired time zone:

Code: Select all

# timedatectl set-timezone Europe/Zurich
Check if Swiss Italian locale is present. If not, add it:

Code: Select all

# localectl list-locales
en_GB
en_GB.iso88591
en_GB.utf8
en_US
en_US.iso88591
en_US.utf8

Code: Select all

# nano /etc/locale.gen

Code: Select all

# cat /etc/locale.gen
en_US.UTF-8 UTF-8
en_US ISO-8859-1
en_GB.UTF-8 UTF-8
en_GB ISO-8859-1
it_CH.UTF-8 UTF-8
it_CH ISO-8859-1
Generate the locales:

Code: Select all

# locale-gen
 * Generating 6 locales (this might take a while) with 1 jobs
 *  (1/6) Generating en_GB.ISO-8859-1 ...                                 [ ok ]
 *  (2/6) Generating en_GB.UTF-8 ...                                      [ ok ]
 *  (3/6) Generating en_US.ISO-8859-1 ...                                 [ ok ]
 *  (4/6) Generating en_US.UTF-8 ...                                      [ ok ]
 *  (5/6) Generating it_CH.ISO-8859-1 ...                                 [ ok ]
 *  (6/6) Generating it_CH.UTF-8 ...                                      [ ok ]
 * Generation complete
 * Adding locales to archive ...                                          [ ok ]
Check the locales have been created:

Code: Select all

# localectl list-locales
en_GB
en_GB.iso88591
en_GB.utf8
en_US
en_US.iso88591
en_US.utf8
it_CH
it_CH.iso88591
it_CH.utf8
Set the desired locale:

Code: Select all

# localectl set-locale LANG=it_CH.UTF-8
Check what Italian keymaps are available:

Code: Select all

# localectl list-keymaps | grep it
it
it-ibm
it2
mac-it
Let's say I want to use a Swiss German keymap (sg) for the console instead. Check if that keymap exists:

Code: Select all

# localectl list-keymaps | grep sg
sg
sg-latin1
sg-latin1-lk450
Set the console keymap to Swiss German:

Code: Select all

# localectl set-keymap sg
Let's say I want to use a Swiss keymap in X Windows. Check if it exists:

Code: Select all

# localectl list-x11-keymap-layouts | grep ch
ch
Set the X11 keymap to Swiss:

Code: Select all

# localectl set-x11-keymap ch
Update the environment variables and profile:

Code: Select all

# env-update && source /etc/profile
>>> Regenerating /etc/ld.so.cache...
Edit /etc/default/grub and change the locale and keymap entries in GRUB_CMDLINE_LINUX_DEFAULT to be locale=it_CH and keymap=sg:

Code: Select all

# nano /etc/default/grub
Regenerate grub.cfg:

Code: Select all

# grub2-mkconfig -o /boot/grub/grub.cfg
Generazione file di configurazione GRUB...
Trovato sfondo: /boot/grub/default-splash.png
Trovata immagine linux: /boot/kernel-genkernel-x86_64-5.4.0-sabayon
Trovata immagine initrd: /boot/initramfs-genkernel-x86_64-5.4.0-sabayon
fatto
Reboot to check if everything works:

Code: Select all

# reboot
Check the locale list is as expected:

Code: Select all

# eselect locale list
Available targets for the LANG variable:
  [1]   C
  [2]   en_GB
  [3]   en_GB.iso88591
  [4]   en_GB.utf8
  [5]   en_US
  [6]   en_US.iso88591
  [7]   en_US.utf8
  [8]   it_CH
  [9]   it_CH.iso88591
  [10]  it_CH.utf8
  [11]  POSIX
  [12]  it_CH.UTF-8 *
  [ ]   (free form)
Check if the configuration in this installation is as expected:

Code: Select all

# localectl status
   System Locale: LANG=it_CH.UTF-8
       VC Keymap: sg
      X11 Layout: ch

msdobrescu
Old Dear Hen
Posts: 867
Joined: Sun Aug 21, 2011 8:48

Re: How to setup the locales?

Post by msdobrescu » Sun May 10, 2020 10:58

Hello, thank you to confirm my setup and for the thorough documentation!

I have described my problem also here: viewtopic.php?f=57&t=35759&sid=f2638a6a ... 09c46507f6

I want to have declared my region over my DE (KDE), but my UI language I try to set to English.

So far, the above setup changed the KDE login screen to English and the messages during the KDE starting to English too.

Besides that, I still see Romanian menus in KDE.

I also have a strange behaviour as I can't add a language to KDE - I was thinking that I would fix it by adding Romanian again and set to English again, then remove Romanian. But when I chose other language to add from the list in KDE Settings, it closes and does nothing. What can I do? What to reinstall to fix this? Is there a "force" option to reinstall as it was the first time, so it would set it up again?

Thank you.

msdobrescu
Old Dear Hen
Posts: 867
Joined: Sun Aug 21, 2011 8:48

Re: How to setup the locales?

Post by msdobrescu » Sun May 10, 2020 11:28


Fitzcarraldo
Sagely Hen
Posts: 8217
Joined: Sat Mar 10, 2007 5:40
Location: United Kingdom
Contact:

Re: How to setup the locales?

Post by Fitzcarraldo » Mon May 11, 2020 19:21

Don't use KDE to do it, then. Use the command line, as shown in my previous post.

Code: Select all

$ su
Password: 

Code: Select all

# timedatectl list-timezones | grep Bucharest
Europe/Bucharest

Code: Select all

# timedatectl set-timezone Europe/Bucharest

Code: Select all

# localectl set-locale LANG=en_GB.UTF-8

Code: Select all

# localectl set-keymap ro

Code: Select all

# localectl set-x11-keymap ro

Code: Select all

# env-update && source /etc/profile
>>> Regenerating /etc/ld.so.cache...

Code: Select all

# date
Mon 11 May 22:08:15 EEST 2020

Code: Select all

# localectl status
   System Locale: LANG=en_GB.UTF-8
       VC Keymap: ro-std
      X11 Layout: ro
Add 'keymap=ro' to GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub:

Code: Select all

# nano /etc/default/grub

Code: Select all

# grep GRUB_CMDLINE_LINUX_DEFAULT /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=5d3167e9-0621-4d26-82b8-4c3501b05272 keymap=ro"
Edit lvm.conf to change 'use_lvmetad = 1' to 'use_lvmetad = 0' in order to avoid 'Failed to connect to lvmetad. Falling back to device scanning.' message from grub2-mkconfig:

Code: Select all

# nano /etc/lvm/lvm.conf

Code: Select all

# grep use_lvmetad /etc/lvm/lvm.conf | grep -v "#"
        use_lvmetad = 0
Regenerate grub.cfg:

Code: Select all

# grub2-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found background: /boot/grub/default-splash.png
Found linux image: /boot/kernel-genkernel-x86_64-5.4.0-sabayon
Found initrd image: /boot/initramfs-genkernel-x86_64-5.4.0-sabayon
done

Code: Select all

# reboot

msdobrescu
Old Dear Hen
Posts: 867
Joined: Sun Aug 21, 2011 8:48

Re: How to setup the locales?

Post by msdobrescu » Mon May 11, 2020 19:34

I did, didn't work, this is why I have tried to do that.

Fitzcarraldo
Sagely Hen
Posts: 8217
Joined: Sat Mar 10, 2007 5:40
Location: United Kingdom
Contact:

Re: How to setup the locales?

Post by Fitzcarraldo » Mon May 11, 2020 21:08

Re-install the SL KDE spin and specify to the SL Installer that English is the language, with either the British or American keymap, as you wish. Then, once the installation has completed, change the time zone and keymaps (console & X11) to Romanian from the command line as shown above. The KDE GUI will be in English; the time zone will be Europe/Bucharest and the keymaps will be Romanian.

msdobrescu
Old Dear Hen
Posts: 867
Joined: Sun Aug 21, 2011 8:48

Re: How to setup the locales?

Post by msdobrescu » Tue May 12, 2020 0:41

What is "the SL KDE spin"? ("SL" = "Sabayon Linux")

Fitzcarraldo
Sagely Hen
Posts: 8217
Joined: Sat Mar 10, 2007 5:40
Location: United Kingdom
Contact:

Re: How to setup the locales?

Post by Fitzcarraldo » Tue May 12, 2020 1:00

The KDE edition of SL (Sabayon Linux).

If you want to have the currency in Romanian format and the number format in Romanian format, you can additionally do the following:

Code: Select all

# localectl set-locale LC_MONETARY=ro_RO.UTF-8
# localectl set-locale LC_NUMERIC=ro_RO.UTF-8
# env-update && source /etc/profile

Code: Select all

# localectl status
   System Locale: LANG=en_GB.UTF-8
                  LC_NUMERIC=ro_RO.UTF-8
                  LC_MONETARY=ro_RO.UTF-8
       VC Keymap: ro-std
      X11 Layout: ro

Code: Select all

# locale
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="ro_RO.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="ro_RO.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=

Code: Select all

# date
Tue 12 May 04:02:29 EEST 2020
^Also, as you can see above, the command to set the time zone to Europe/Bucharest that I listed in a previous post did change the time zone.


EDIT: By the way, if you try and change one of the variables back from ro_RO.UTF-8 to en_GB.UTF-8, the change does not show in the output of the locale command. For example, let's say you want to change LC_NUMERIC back to en_GB.UTF-8:

Code: Select all

# localectl status
   System Locale: LANG=en_GB.UTF-8
                  LC_NUMERIC=ro_RO.UTF-8
                  LC_MONETARY=ro_RO.UTF-8
       VC Keymap: ro-std
      X11 Layout: ro
# localectl set-locale LC_NUMERIC=en_GB.UTF-8
# cat /etc/locale.conf   
LANG=en_GB.UTF-8
LC_MONETARY=ro_RO.UTF-8
# cat /etc/env.d/02locale
LANG=en_GB.UTF-8
LC_MONETARY=ro_RO.UTF-8
# localectl status
   System Locale: LANG=en_GB.UTF-8
                  LC_MONETARY=ro_RO.UTF-8
       VC Keymap: ro-std
      X11 Layout: ro
# locale
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC=ro_RO.UTF-8  <-- Notice it didn't change
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY=ro_RO.UTF-8
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=
# env-update && source /etc/profile
>>> Regenerating /etc/ld.so.cache...
# locale
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC=ro_RO.UTF-8 <-- Notice it still didn't change
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY=ro_RO.UTF-8
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=
This is one of the reasons I'm not keen on the layer of abstraction added by systemd. The way to get LC_NUMERIC back to en_GB.UTF-8 is:

Code: Select all

# localectl set-locale LANG=ro_RO.UTF-8
# env-update && source /etc/profile
# localectl set-locale LANG=en_GB.UTF-8
# env-update && source /etc/profile
# reboot
After rebooting, the change will have been applied:

Code: Select all

# locale
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"  <-- Notice it has now changed
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"  <-- Notice this also changed
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=
# localectl status
   System Locale: LANG=en_GB.UTF-8
       VC Keymap: ro-std
      X11 Layout: ro
Notice that LC_MONETARY also changed back to en_GB.UTF-8, so you'd have to re-do the ' localectl set-locale LC_MONETARY=ro_RO.UTF-8' if you wanted that to still be Romanian.

Post Reply