[Rd] R and LANGUAGE
Martin Maechler
maechler at stat.math.ethz.ch
Thu Feb 27 19:45:00 CET 2014
>>>>> Martin Maechler <maechler at stat.math.ethz.ch>
>>>>> on Thu, 27 Feb 2014 11:50:04 +0100 writes:
> Diverted from ESS-help.
> It is really about R's LANGUAGE, locales and
> then a wish for sessionInfo() :
>>>>> Sparapani, Rodney <rsparapa at mcw.edu>
>>>>> on Thu, 20 Feb 2014 19:39:33 +0000 writes:
>>> Just guessing: perhaps this is something that is set when
>>> R is initialized and not queried every time something is
>>> printed?
>>>
>>> Kasper
>> Hi Kasper:
>> Good guess, but wrong ;o) Actually, the problem is in
>> Sys.getlocale() Recent versions of R have this in its
>> help...
>> Note that the ‘LANGUAGE’ environment variable has
>> precedence over ‘"LC_MESSAGES"’ in selecting the language
>> for message translation on most R platforms.
>> However, the function itself just ignores LANGUAGE. I
>> searched bugzilla, but did not find anything related to
>> LANGUAGE or Sys.getlocale() I guess this is a feature :o)
> Note that 'locale' is general OS / system term,
> which R cannot define.
> On a Unix alike (e.g., here, Fedora Linux), if you have defined the
> LC_* plus LANG plus LANGUAGE
> variables,
> locale
> only prints the LC_* stuff and LANG, but not LANGUAGE.
> I did not dig, but I'm pretty sure LANGUAGE is R's own way to specify
> the messages language *in addition* to locale settings,
> and with higher precedence, as you've mentioned above.
> Hence Sys.getlocale() should clearly *not* report LANGUAGE.
> OTOH,
>> Sys.getlocale()
> [1] "LC_CTYPE=de_CH.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=de_CH.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=de_CH.UTF-8;LC_PAPER=de_CH.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=de_CH.UTF-8;LC_IDENTIFICATION=C"
>> Sys.getenv("LANG")
> [1] "de_CH.UTF-8"
>> Sys.getenv("LANGUAGE")
> [1] "en"
>>
> So, Sys.getlocale() also does not report LANG,
> even though, 'locale' does report that for me.
I've been partly wrong and incomplete in what I said above.
Two kind fellow R corers pointed me to
the 'R-admin' manual
and to
<http://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html#The-LANGUAGE-variable>
<http://www.gnu.org/software/gettext/manual/html_node/Locale-Environment-Variables.html#Locale-Environment-Variables>
for an explanation of LANGUAGE and other locale env vars.
and note that LANGUAGE is specific to GNU gettext, which is why we describe
it as 'on many systems' .......
and also note that not installations / OSes are using the glibc
library for gettext which is also assumed in parts of the GNU
manuals above.
If (and how if) sessionInfo() should be improved, by having it
report more about the LANG/LANGUAGE/LC_* is a different topic,
that we will hopefully settle as well...
Martin.
More information about the R-devel
mailing list