The locale describes aspects of the internationalization of a program.
Initially most aspects of the locale of R are set to "C"
(which
is the default for the C language and reflects North-American usage).
R sets "LC_CTYPE"
and "LC_COLLATE"
, which allow the
use of a different character set and alphabetic
comparisons in that character set (including the use of
sort
), "LC_MONETARY"
(for use by
Sys.localeconv
) and "LC_TIME"
may affect
the behaviour of as.POSIXlt
and strptime
and functions which use them (but not date
).
The first seven categories described here are those specified by
POSIX. "LC_MESSAGES"
will be "C"
on systems that do not
support message translation, and is not supported on Windows. Trying
to use an unsupported category is an error for Sys.setlocale
.
Note that setting category "LC_ALL"
sets only categories
"LC_COLLATE"
, "LC_CTYPE"
, "LC_MONETARY"
and
"LC_TIME"
.
Attempts to set an invalid locale are ignored. There may or may not
be a warning, depending on the OS.
Attempts to change the character set (by
Sys.setlocale("LC_CTYPE", )
, if that implies a different
character set) during a session may not work and are likely to lead to
some confusion.
Note that the LANGUAGE
environment variable has precedence over
"LC_MESSAGES"
in selecting the language for message translation
on most R platforms.
On platforms where ICU is used for collation the locale used for
collation can be reset by icuSetCollate
). Except on
Windows, the initial setting is taken from the "LC_COLLATE"
category, and it is reset when this is changed by a call to
Sys.setlocale
.