You are not logged in.

#1 2009-10-22 12:18:25

irock
Member
From: Sweden
Registered: 2008-10-14
Posts: 12

System Locale [WORKAROUND SUPPLIED]

Hi!

I have two Arch Linux systems up and running, and they both suffer from the same issue: the system locale is not set upon boot.
Normally I don't need it to be set, as all users locales are working. However, some of my cronjobs and daemons require the system locale to be correct.
One possible solution to this issue would probably be to set LANG in /etc/rc.local, but I'm after a permanent solution.

/etc/rc.conf:

#
# /etc/rc.conf - Main Configuration for Arch Linux
#

# -----------------------------------------------------------------------
# LOCALIZATION
# -----------------------------------------------------------------------
#
# LOCALE: available languages can be listed with the 'locale -a' command
# HARDWARECLOCK: set to "UTC" or "localtime"
# USEDIRECTISA: use direct I/O requests instead of /dev/rtc for hwclock
# TIMEZONE: timezones are found in /usr/share/zoneinfo
# KEYMAP: keymaps are found in /usr/share/kbd/keymaps
# CONSOLEFONT: found in /usr/share/kbd/consolefonts (only needed for non-US)
# CONSOLEMAP: found in /usr/share/kbd/consoletrans
# USECOLOR: use ANSI color sequences in startup messages
#
LOCALE="sv_SE.UTF8"
HARDWARECLOCK="UTC"
USEDIRECTISA="no"
TIMEZONE="Europe/Stockholm"
KEYMAP="sv-latin1"
CONSOLEFONT="lat1-12"
CONSOLEMAP="8859-1"
USECOLOR="yes"

# -----------------------------------------------------------------------
# HARDWARE
# -----------------------------------------------------------------------
#
# MOD_AUTOLOAD: Allow autoloading of modules at boot and when needed
# MOD_BLACKLIST: Prevent udev from loading these modules
# MODULES: Modules to load at boot-up. Prefix with a ! to blacklist.
#
# NOTE: Use of 'MOD_BLACKLIST' is deprecated. Please use ! in the MODULES array.
#
MOD_AUTOLOAD="yes"
MODULES=(!pcspkr !snd-pcsp autofs4 acpi-cpufreq)

# Scan for LVM volume groups at startup, required if you use LVM
USELVM="yes"

# -----------------------------------------------------------------------
# NETWORKING
# -----------------------------------------------------------------------
#
# HOSTNAME: Hostname of machine. Should also be put in /etc/hosts
#
HOSTNAME="neo"

# Use 'ifconfig -a' or 'ls /sys/class/net/' to see all available interfaces.
#
# Interfaces to start at boot-up (in this order)
# Declare each interface then list in INTERFACES
#   - prefix an entry in INTERFACES with a ! to disable it
#   - no hyphens in your interface names - Bash doesn't like it
# 
# DHCP:     Set your interface to "dhcp" (eth0="dhcp")
# Wireless: See network profiles below
#

#Static IP example
#eth0="eth0 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255"
eth0="dhcp"
INTERFACES=(!eth0)

# Routes to start at boot-up (in this order)
# Declare each route then list in ROUTES
#   - prefix an entry in ROUTES with a ! to disable it
#
gateway="default gw 192.168.0.1"
ROUTES=(!gateway)
 
# Enable these network profiles at boot-up.  These are only useful
# if you happen to need multiple network configurations (ie, laptop users)
#   - set to 'menu' to present a menu during boot-up (dialog package required)
#   - prefix an entry with a ! to disable it
#
# Network profiles are found in /etc/network.d
#
# This now requires the netcfg package
#
NETWORKS=(home)

# -----------------------------------------------------------------------
# DAEMONS
# -----------------------------------------------------------------------
#
# Daemons to start at boot-up (in this order)
#   - prefix a daemon with a ! to disable it
#   - prefix a daemon with a @ to start it up in the background
#
DAEMONS=(syslog-ng @acpid @hal @network @net-profiles @crond @laptop-mode @fam @alsa @autofs @xinetd @sensors)

/etc/locale.gen:

sv_SE.UTF-8 UTF-8

Output from locale on system level after boot:

LANG=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=

Output from locale in my shell:

LANG=sv_SE.UTF8
LC_CTYPE="sv_SE.UTF8"
LC_NUMERIC="sv_SE.UTF8"
LC_TIME="sv_SE.UTF8"
LC_COLLATE=C
LC_MONETARY="sv_SE.UTF8"
LC_MESSAGES="sv_SE.UTF8"
LC_PAPER="sv_SE.UTF8"
LC_NAME="sv_SE.UTF8"
LC_ADDRESS="sv_SE.UTF8"
LC_TELEPHONE="sv_SE.UTF8"
LC_MEASUREMENT="sv_SE.UTF8"
LC_IDENTIFICATION="sv_SE.UTF8"
LC_ALL=

Any help is appreciated smile

Last edited by irock (2009-10-31 11:00:35)

Offline

#2 2009-10-23 15:55:02

brendan
Member
From: UK
Registered: 2009-05-16
Posts: 130
Website

Re: System Locale [WORKAROUND SUPPLIED]

I would also like an answer to this. I have the same problem on one of two arch systems. My netbook installed about a year ago has the same configs in locale's configs but my desktop installed with the latest install image has this problem.

Offline

#3 2009-10-23 16:53:49

Misfit138
Misfit Emeritus
From: USA
Registered: 2006-11-27
Posts: 4,189

Re: System Locale [WORKAROUND SUPPLIED]

Silly question: Have you run locale-gen as root?
I notice you failed to mention whether you have or not..

Offline

#4 2009-10-24 11:40:25

irock
Member
From: Sweden
Registered: 2008-10-14
Posts: 12

Re: System Locale [WORKAROUND SUPPLIED]

Yes, I have run locale-gen. I can also mention that the first computer runs 32-bit Arch and the other one runs 64-bit.

Out of pure curiousity: when and where are locales set on boot. As far as I can see, the file /etc/rc.sysinit does not do anything locale related more than generate a valid locale.sh in /etc/profile.d. The output from `locale` is all POSIX so not even LC_COLLATE="C" from /etc/profile is sourced.

How to find out if your installation suffers from the same issue: Add this line to /etc/rc.local, reboot and check the contents of /tmp/syslocale.

locale > /tmp/syslocale

Offline

#5 2009-10-26 20:10:41

brendan
Member
From: UK
Registered: 2009-05-16
Posts: 130
Website

Re: System Locale [WORKAROUND SUPPLIED]

I have run locale-gen too as root.
This is really annoying and is crashing Netbeans (the svn plugin causes a full crash).

Offline

#6 2009-10-30 23:32:40

irock
Member
From: Sweden
Registered: 2008-10-14
Posts: 12

Re: System Locale [WORKAROUND SUPPLIED]

I'm still looking for a solution to this problem. Is there a way to set environment variables prior to invocation of daemons?

Thanks for all help.

Last edited by irock (2009-10-30 23:40:36)

Offline

#7 2009-10-31 10:57:42

irock
Member
From: Sweden
Registered: 2008-10-14
Posts: 12

Re: System Locale [WORKAROUND SUPPLIED]

I've found a simple but ugly workaround for this issue now. Add the following lines to /etc/rc.conf and everything will work as expected.

export LC_COLLATE="C"
export LANG="${LOCALE}"

My /etc/rc.conf now looks like this:

#
# /etc/rc.conf - Main Configuration for Arch Linux
#

# -----------------------------------------------------------------------
# LOCALIZATION
# -----------------------------------------------------------------------
#
# LOCALE: available languages can be listed with the 'locale -a' command
# HARDWARECLOCK: set to "UTC" or "localtime"
# USEDIRECTISA: use direct I/O requests instead of /dev/rtc for hwclock
# TIMEZONE: timezones are found in /usr/share/zoneinfo
# KEYMAP: keymaps are found in /usr/share/kbd/keymaps
# CONSOLEFONT: found in /usr/share/kbd/consolefonts (only needed for non-US)
# CONSOLEMAP: found in /usr/share/kbd/consoletrans
# USECOLOR: use ANSI color sequences in startup messages
#
LOCALE="sv_SE.UTF8"
HARDWARECLOCK="UTC"
USEDIRECTISA="no"
TIMEZONE="Europe/Stockholm"
KEYMAP="sv-latin1"
CONSOLEFONT="lat1-12"
CONSOLEMAP="8859-1"
USECOLOR="yes"

export LC_COLLATE="C"
export LANG="${LOCALE}"

# -----------------------------------------------------------------------
# HARDWARE
# -----------------------------------------------------------------------
#
# MOD_AUTOLOAD: Allow autoloading of modules at boot and when needed
# MOD_BLACKLIST: Prevent udev from loading these modules
# MODULES: Modules to load at boot-up. Prefix with a ! to blacklist.
#
# NOTE: Use of 'MOD_BLACKLIST' is deprecated. Please use ! in the MODULES array.
#
MOD_AUTOLOAD="yes"
MODULES=(!pcspkr !snd-pcsp autofs4 acpi-cpufreq)

# Scan for LVM volume groups at startup, required if you use LVM
USELVM="yes"

# -----------------------------------------------------------------------
# NETWORKING
# -----------------------------------------------------------------------
#
# HOSTNAME: Hostname of machine. Should also be put in /etc/hosts
#
HOSTNAME="neo"

# Use 'ifconfig -a' or 'ls /sys/class/net/' to see all available interfaces.
#
# Interfaces to start at boot-up (in this order)
# Declare each interface then list in INTERFACES
#   - prefix an entry in INTERFACES with a ! to disable it
#   - no hyphens in your interface names - Bash doesn't like it
# 
# DHCP:     Set your interface to "dhcp" (eth0="dhcp")
# Wireless: See network profiles below
#

#Static IP example
#eth0="eth0 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255"
eth0="dhcp"
INTERFACES=(!eth0)

# Routes to start at boot-up (in this order)
# Declare each route then list in ROUTES
#   - prefix an entry in ROUTES with a ! to disable it
#
gateway="default gw 192.168.0.1"
ROUTES=(!gateway)
 
# Enable these network profiles at boot-up.  These are only useful
# if you happen to need multiple network configurations (ie, laptop users)
#   - set to 'menu' to present a menu during boot-up (dialog package required)
#   - prefix an entry with a ! to disable it
#
# Network profiles are found in /etc/network.d
#
# This now requires the netcfg package
#
NETWORKS=(home)

# -----------------------------------------------------------------------
# DAEMONS
# -----------------------------------------------------------------------
#
# Daemons to start at boot-up (in this order)
#   - prefix a daemon with a ! to disable it
#   - prefix a daemon with a @ to start it up in the background
#
DAEMONS=(syslog-ng @acpid @hal @network @net-profiles @crond @laptop-mode @fam
    @alsa @autofs @xinetd @sensors @iptables)

As a side note, all info and warning messages during boot, after rc.sysinit invocation, is now properly translated into swedish (i.e when partitions are to be checked on the next reboot).
I now also remember I've had problems with file dialogs not showing åäö properly (i.e when saving a web page in ff), which no longer seems to be an issue.

Thing is that I've been running Arch Linux for the last 2 years, and now I realize that the system locale setting might have never worked. I still can't figure out where locales are set during boot... The /etc/rc.sysinit script says that it sets locale (and so does http://wiki.archlinux.org/index.php/Boot), but in fact it does not! It just fixes /etc/profile* so login shells will have the proper locale set, while the system continue to run with no explicitly set locale.

Offline

#8 2010-03-29 22:31:10

pecenac
Member
Registered: 2009-09-27
Posts: 14

Re: System Locale [WORKAROUND SUPPLIED]

I have a similar problem, ecept the workaround doesnt work. If I follow it, all the messages are in czech (Ive put in cs_CZ.utf8), but when I run locale, I get:

[pecenac@pecenac-laptop ~]$ locale
LANG=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
[pecenac@pecenac-laptop ~]$

exactly the same thing as before the workaround. Also I can not write non english characters (ěčřžýáíé) in xfce-terminal. I can, however, write them if I run uxterm. When I try to download files with non english characters from svn it causes problems as the checkout operation stops with and error.

I did succesfully run locale-gen both as sudo and as a user
I do have my locales uncommented in locale.gen
Please help... its really annoying

Last edited by pecenac (2010-03-29 22:33:52)

Offline

#9 2010-03-30 06:49:30

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: System Locale [WORKAROUND SUPPLIED]

pecenac wrote:

I did succesfully run locale-gen both as sudo and as a user
I do have my locales uncommented in locale.gen
Please help... its really annoying

You shouldn't run local-gen as sudo, because this retains the user's environment (using root privileges in this environment to run the application).
In order to use the proper root environment, log in as root, using: su - (don't forget the dash), then run locale-gen again.


To know or not to know ...
... the questions remain forever.

Offline

#10 2010-03-31 23:15:19

pecenac
Member
Registered: 2009-09-27
Posts: 14

Re: System Locale [WORKAROUND SUPPLIED]

Hi. Thanks a lot for the answer. Running locale-gen as root (not sudo) worked. i get:

LANG=en_US.utf8
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE="en_US.utf8"
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER="en_US.utf8"
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=

I still however can not write non english characters. Aslo if I close the console window and open a new one Im back to "POSIX". The locale-gen results get lost somehow. It all seems so confusing. Im running XFCE if it makes any difference.

Last edited by pecenac (2010-03-31 23:16:45)

Offline

#11 2010-11-21 21:31:49

youarefunny
Member
From: Toronto, Canada
Registered: 2010-11-13
Posts: 42

Re: System Locale [WORKAROUND SUPPLIED]

Thank you so much this worked for me.

I just took the value from 'LOCALE="EN_US.UTF8"' and added after it 'export LANG="EN_US.UTF8"'

now it works like a charm.

EDIT:
Actually, not when I boot my shell locale says UTF-8 but my gnome terminal (after starting X) says POSIX.  Unless I call locale in my terminal before starting X in which case it works and gives UTF-8.

Last edited by youarefunny (2010-11-24 13:14:46)

Offline

#12 2010-11-24 13:21:03

youarefunny
Member
From: Toronto, Canada
Registered: 2010-11-13
Posts: 42

Re: System Locale [WORKAROUND SUPPLIED]

I have found a second workarround if the first one it not working for you.

Just do the same thing but insted of in /etc/rc.conf do it in /etc/profile (or put in in a file in /etc/profile.d)

export LANG="en_US.UTF8"

Hope this works for you!

Offline

Board footer

Powered by FluxBB