Need tutoring: 'locale'

Kurt Wall kwall
Mon May 17 11:56:13 PDT 2004


Consuming 0.5K bytes, Michael Hipp blathered:
> Could someone give me a leg-up in understanding how the 'locale' stuff 
> works. Googling turned up either way too much or nothing at all.
> 
> I just need to know where to start from to understand what file(s) 
> determine my locale settings, how to change it or edit the existing one, 
> etc.

I take it you're having a specific problem?  Meanwhile, use the command
`locale -v' to view the current locale settings:

$ locale -v
LANG=en_US
LC_CTYPE="en_US"
LC_NUMERIC="en_US"
LC_TIME="en_US"
LC_COLLATE="en_US"
LC_MONETARY="en_US"
LC_MESSAGES="en_US"
LC_PAPER="en_US"
LC_NAME="en_US"
LC_ADDRESS="en_US"
LC_TELEPHONE="en_US"
LC_MEASUREMENT="en_US"
LC_IDENTIFICATION="en_US"

The locale settings control how and, in some case, what information
that is sensitive to language and location differences are displayed.
It controls character sets, the language used for error messages,
sort orders, and so on. See `man 7 locale' (works here, YMMV) for
a nice explanation.

I'm not going to go into all the gory details here, and you should be
able to deciper some of the locale settings based on their names. However,
LC_ALL can be used to set all of the LC_* variables. The simplest way
to change locale is to modify the LANG variable. So, if I say `LANG=en_UK',
then I get:

$ LANG=en_GB locale -v
LANG=en_GB
LC_CTYPE="en_GB"
LC_NUMERIC="en_GB"
LC_TIME="en_GB"
LC_COLLATE="en_GB"
LC_MONETARY="en_GB"
LC_MESSAGES="en_GB"
LC_PAPER="en_GB"
LC_NAME="en_GB"
LC_ADDRESS="en_GB"
LC_TELEPHONE="en_GB"
LC_MEASUREMENT="en_GB"
LC_IDENTIFICATION="en_GB"

If you only want to change the way monetary values are displayed,
try `LC_MONETARY=en_GB':

$ LC_MONETARY=en_GB locale -v
LANG=en_US
LC_CTYPE="en_US"
LC_NUMERIC="en_US"
LC_TIME="en_US"
LC_COLLATE="en_US"
LC_MONETARY=en_GB
LC_MESSAGES="en_US"
LC_PAPER="en_US"
LC_NAME="en_US"
LC_ADDRESS="en_US"
LC_TELEPHONE="en_US"
LC_MEASUREMENT="en_US"
LC_IDENTIFICATION="en_US"

Put aside any dislike you have for GNU's Texinfo system and read the
info file for locale stuff, which lives in the libc documentation:

$ info libc locale


Kurt
-- 
Toilet Toup'ee, n.:
	Any shag carpet that causes the lid to become top-heavy, thus
creating endless annoyance to male users.
		-- Rich Hall, "Sniglets"


More information about the Linux-users mailing list