character string. The following categories should
always be supported: "LC_ALL", "LC_COLLATE",
"LC_CTYPE", "LC_MONETARY", "LC_NUMERIC" and
"LC_TIME". Some systems (not Windows) will also support
"LC_MESSAGES", "LC_PAPER" and "LC_MEASUREMENT".
locale
character string. A valid locale name on the system in
use. Normally "" (the default) will pick up the default
locale for the system.
Details
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
"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.
Value
A character string of length one describing the locale in use (after
setting for Sys.setlocale), or an empty character string if the
current locale settings are invalid or NULL if locale
information is unavailable.
For category = "LC_ALL" the details of the string are
system-specific: it might be a single locale name or a set of locale
names separated by "/" (Solaris, OS X) or ";"
(Windows, Linux). For portability, it is best to query categories
individually: it is not necessarily the case that the result of
foo <- Sys.getlocale() can be used in
Sys.setlocale("LC_ALL", locale = foo).
Warning
Setting "LC_NUMERIC" may cause R to function
anomalously, so gives a warning. Input conversions
in R itself are unaffected, but the reading and writing of ASCII
save files will be, as may packages.
Setting it temporarily on a Unix-alike to produce graphical or text
output may work well enough, but options(OutDec) is
often preferable.
Almost all the output routines used by R itself under Windows ignore
the setting of "LC_NUMERIC" since they make use of the Trio
library which is not internationalized.
Note
Changing the values of locale categories whilst R is running ought
to be noticed by the OS services, and usually is but exceptions have
been seen (usually in collation services).
See Also
strptime for uses of category = "LC_TIME".
Sys.localeconv for details of numerical and monetary
representations.
l10n_info gives some summary facts about the locale and
its encoding.
The ‘R Installation and Administration’ manual for background
on locales and how to find out locale names on your system.
Examples
Sys.getlocale()
Sys.getlocale("LC_TIME")
## Not run:
Sys.setlocale("LC_TIME", "de") # Solaris: details are OS-dependent
Sys.setlocale("LC_TIME", "de_DE.utf8") # Modern Linux etc.
Sys.setlocale("LC_TIME", "de_DE.UTF-8") # ditto
Sys.setlocale("LC_TIME", "de_DE") # OS X, in UTF-8
Sys.setlocale("LC_TIME", "German") # Windows
## End(Not run)
Sys.getlocale("LC_PAPER") # may or may not be set
## Not run:
Sys.setlocale("LC_COLLATE", "C") # turn off locale-specific sorting,
# usually, but not on all platforms
## End(Not run)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(base)
> png(filename="/home/ddbj/snapshot/RGM3/R_rel/result/base/locales.Rd_%03d_medium.png", width=480, height=480)
> ### Name: locales
> ### Title: Query or Set Aspects of the Locale
> ### Aliases: locales Sys.getlocale Sys.setlocale LC_ALL LC_COLLATE LC_CTYPE
> ### LC_MONETARY LC_NUMERIC LC_TIME LC_MESSAGES LC_PAPER LC_MEASUREMENT
> ### Keywords: utilities
>
> ### ** Examples
>
> Sys.getlocale()
[1] "C"
> Sys.getlocale("LC_TIME")
[1] "C"
> ## Not run:
> ##D Sys.setlocale("LC_TIME", "de") # Solaris: details are OS-dependent
> ##D Sys.setlocale("LC_TIME", "de_DE.utf8") # Modern Linux etc.
> ##D Sys.setlocale("LC_TIME", "de_DE.UTF-8") # ditto
> ##D Sys.setlocale("LC_TIME", "de_DE") # OS X, in UTF-8
> ##D Sys.setlocale("LC_TIME", "German") # Windows
> ## End(Not run)
> Sys.getlocale("LC_PAPER") # may or may not be set
[1] "C"
>
> ## Not run:
> ##D Sys.setlocale("LC_COLLATE", "C") # turn off locale-specific sorting,
> ##D # usually, but not on all platforms
> ## End(Not run)
>
>
>
>
>
> dev.off()
null device
1
>