lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Fri, Nov 04, 2005 at 11:31:40AM -0300, Walter Cruz wrote:
> Look out: I've made a little script to print all the locale environment.
> ----getenv.lua--------
> print(os.getenv("LANG"))
> print(os.getenv("LC_MEASUREMENT"))
> print(os.getenv("LC_IDENTIFICATION"))
> print(os.getenv("LC_ALL"))
> -------getenv.lua ---------
> and now:
> MCid299a:~/lua$ locale
> LANG=pt_BR
> MCid299a:~/lua$ lua getenv.lua
> pt_BR
> nil
> nil
> nil

I believe this is normal.  The "LC_*" values that "locale" is
reporting are the locale categories themselves (as reported by
setlocale()), not environment variables.  Environment variables can be
used to influence the category values, but this is optional.

For example when a program is determining the initial value for the
LC_MEASUREMENT category, it will first look for an LC_MEASUREMENT
environment variable.  If none is set, it tries the LC_ALL environment
variable as a default.  If that isn't set, it looks for LANG as a
further default.  If all of your categories are the same, the LANG
environment variable is sufficient to initialize them.

For details, See section 8.2 of the POSIX/UNIX specification:

Note that this behavior is POSIX-specific.  Standard C doesn't specify
any relationship between environment variables and the locale, so
portable scripts shouldn't rely on those variables.

                                                  -Dave Dodge