Version 7 of LANG

Updated 2012-10-15 10:05:27 by RLE

Purpose: discuss the Unix environment variable LANG - what its purpose is, what problems can be encountered when using it, etc.


MAKR attempts (2009-01-30): The environment variable LANG is part of the set of internationalization (sometimes abbreviated i18n) variables of POSIX. For a definition see there, e.g. at [L1 ], and for the localization topic in general see e.g. here [L2 ].

To set the default POSIX locale:

set env(LANG) C

Sometimes that is not enough, and LC_ALL must be set, too:

set env(LC_ALL) C

My environment is set to German. I have been using Tcl 8.4 and everything has been fine. Now I try to use 8.5 and setting the LANG environment variable has no effect any longer. See this example:

$ echo $LANG
de_DE.UTF-8
$ tclsh8.4
% puts [clock format [clock seconds]]
Do Mär 12 13:19:56 CET 2009
% exit
$ tclsh8.5
% puts [clock format [clock seconds]]
Thu Mar 12 13:20:06 CET 2009
% exit

Why does Tcl 8.5 behave differently? What can I do in order to get the old behaviour back? I would like to have German names for days, months and so on. HolgerJ, 2008-03-12

KBK 2008-03-12: [clock format [clock seconds] -locale system] should do it. Since far more uses of clock are for consumption by machines than by humans, 8.5 chooses a locale-neutral format as the default. -locale system says, "use whatever the OS thinks is the current locale;" -locale current says, "use whatever the msgcat system thinks is the current locale," or you could say, ''-locale de_DE' to say, "make it German irrespective of locale settings."


DKF: Tcl makes use of LANG during startup when guessing what encoding system should return.