\HeaderA{locales}{Query or Set Aspects of the Locale}{locales}
\aliasA{Sys.getlocale}{locales}{Sys.getlocale}
\aliasA{Sys.setlocale}{locales}{Sys.setlocale}
\keyword{utilities}{locales}
\begin{Description}\relax
Get details of or set aspects of the locale for the \R{} process.
\end{Description}
\begin{Usage}
\begin{verbatim}
Sys.getlocale(category = "LC_ALL")
Sys.setlocale(category = "LC_ALL", locale = "")
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{category}] character string. Must be one of \code{"LC\_ALL"},
\code{"LC\_COLLATE"}, \code{"LC\_CTYPE"}, \code{"LC\_MONETARY"},
\code{"LC\_NUMERIC"} or \code{"LC\_TIME"}.
\item[\code{locale}] character string.  A valid locale name on the system in
use. Normally \code{""} (the default) will pick up the default
locale for the system.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The locale describes aspects of the internationalization of a program.
Initially most aspects of the locale of \R{} are set to \code{"C"} (which
is the default for the C language and reflects North-American usage).
\R{} sets \code{"LC\_CTYPE"} and \code{"LC\_COLLATE"}, which allow the
use of a different character set and alphabetic
comparisons in that character set (including the use of
\code{\LinkA{sort}{sort}}), \code{"LC\_MONETARY"} (for use by
\code{\LinkA{Sys.localeconv}{Sys.localeconv}}) and \code{"LC\_TIME"} may affect
the behaviour of \code{\LinkA{as.POSIXlt}{as.POSIXlt}} and \code{\LinkA{strptime}{strptime}}
and functions which use them (but not \code{\LinkA{date}{date}}).

\R{} can be built with no support for locales, but it is normally
available on Unix and is available on Windows.

Some systems will have other locale categories, but the six described
here are those specified by POSIX.

Note that setting \code{"LC\_ALL"} as from \R{} 2.1.0 sets only
\code{"LC\_COLLATE"}, \code{"LC\_CTYPE"}, \code{"LC\_MONETARY"} and
\code{"LC\_TIME"}.
\end{Details}
\begin{Value}
A character string of length one describing the locale in use (after
setting for \code{Sys.setlocale}), or an empty character string if the
locale is invalid (with a warning) or \code{NULL} if locale
information is unavailable.

For \code{category = "LC\_ALL"} the details of the string are
system-specific: it might be a single locale or a set of locales
separated by \code{"/"} (Solaris) or \code{";"} (Windows).  For
portability, it is best to query categories individually.  It is
guaranteed that the result of \code{foo <- Sys.getlocale()} can be
used in \code{Sys.setlocale("LC\_ALL", locale = foo)} on the same
machine.
\end{Value}
\begin{Section}{Warning}
Setting \code{"LC\_NUMERIC"} may cause \R{} to function
anomalously, so gives a warning.  (The known problems are with
input conversion in locales with \code{,} as the decimal point.)
Setting it temporarily to produce graphical or text output may work
well enough.
\end{Section}
\begin{SeeAlso}\relax
\code{\LinkA{strptime}{strptime}} for uses of \code{category = "LC\_TIME"}.
\code{\LinkA{Sys.localeconv}{Sys.localeconv}} for details of numerical and monetary
representations.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
Sys.getlocale()
Sys.getlocale("LC_TIME")
## Not run: 
Sys.setlocale("LC_TIME", "de")     # Solaris: details are OS-dependent
Sys.setlocale("LC_TIME", "German") # Windows
## End(Not run)

Sys.setlocale("LC_COLLATE", "C")  # turn off locale-specific sorting
\end{ExampleCode}
\end{Examples}

