Kubuntu: Changing country-region-language leads to invalid locale

From FVue
Jump to: navigation, search

Problem

After changing the KDE System Settings, Country/Region & Language to:

  • Country: Netherlands
  • Languages: American English

console commands are giving me these errors:

$ man bash
man: can't set the locale; make sure $LC_* and $LANG are correct

It appears System Setting is generating a file ~/.kde/env/setlocale.sh containing illegal locales - there is no local for english language in the Netherlands (en_NL):

export LANG=en_NL.UTF-8
export LANGUAGE=en:nl:en
export LC_NUMERIC=en_NL.UTF-8
export LC_TIME=en_NL.UTF-8
export LC_MONETARY=en_NL.UTF-8
export LC_PAPER=en_NL.UTF-8
export LC_IDENTIFICATION=en_NL.UTF-8
export LC_NAME=en_NL.UTF-8
export LC_ADDRESS=en_NL.UTF-8
export LC_TELEPHONE=en_NL.UTF-8
export LC_MEASUREMENT=en_NL.UTF-8

What should've been generated is this:

export LANG=en_US.UTF-8
export LANGUAGE=en:nl:en
export LC_NUMERIC=nl_NL.UTF-8
export LC_TIME=nl_NL.UTF-8
export LC_MONETARY=nl_NL.UTF-8
export LC_PAPER=nl_NL.UTF-8
export LC_IDENTIFICATION=nl_NL.UTF-8
export LC_NAME=nl_NL.UTF-8
export LC_ADDRESS=nl_NL.UTF-8
export LC_TELEPHONE=nl_NL.UTF-8
export LC_MEASUREMENT=nl_NL.UTF-8

or generate nothing at all, since this is already in my /etc/default/locale (which is read by /etc/pam.d/login):

LANG=en_US.UTF-8
LANGUAGE=en:nl:en
LC_NUMERIC=nl_NL.UTF-8
LC_TIME=nl_NL.UTF-8
LC_MONETARY=nl_NL.UTF-8
LC_PAPER=nl_NL.UTF-8
LC_IDENTIFICATION=nl_NL.UTF-8
LC_NAME=nl_NL.UTF-8
LC_ADDRESS=nl_NL.UTF-8
LC_TELEPHONE=nl_NL.UTF-8
LC_MEASUREMENT=nl_NL.UTF-8

Environment

  • Kubuntu-14.04

Workaround 1: Edit ~/.kde/env/setlocale.sh

Manually edit ~/.kde/env/setlocale.sh after having changed Country/Region & Language settings.

If the settings are the same as /etc/default/locale (which is read by /etc/pam.d/login), you can also delete the file and make the directory read-only to prevent Kubuntu from generating ~/.kde/env/setlocale.sh:

$ cd ~/.kde/env
$ > setlocale.sh # Empty file
$ chmod 444 setlocale.sh

Or as Ansible command:

- name: Ensure empty, read-only ~/.kde/env/setlocale.sh exists
  copy: dest=/home/myname/.kde/env mode=444 owner=myname
    src=root/home/myname/.kde/env/setlocale.sh

Workaround 2: British - not American - English

This seems not to generate illegal LC_* variables, but the chosen country isn't reflected in them.

See also

Bug #1322968 “Changing country leads to invalid locale” : Bugs : “kde-runtime” package : Ubuntu
Bug #1204182 “setlocale.sh can break user-chosen locales and enc...” : Bugs : “kde-runtime” package : Ubuntu