Sys.setlocale
Set or Get Locale-Specific Information

Description

Set or get aspects of the locale for the engine process. Find details of the numerical and monetary representations in the current locale.

Usage

Sys.setlocale(category="LC_ALL", locale="")
Sys.getlocale(category="LC_ALL")
Sys.localeconv()

Arguments

category character string. Must be one of "LC_ALL", "LC_CTYPE", "LC_NUMERIC", "LC_TIME", "LC_COLLATE", "LC_MONETARY", "LC_MESSAGES", "LC_PAPER", "LC_NAME", "LC_ADDRESS", "LC_TELEPHONE", "LC_MEASUREMENT", or "LC_IDENTIFICATION". "LC_ALL" means the collection of all the others.
locale character string. A valid locale name. The default, "", means the default locale for your system and "C" means the locale used by the C language. Other valid values are system specific.

Details

The current engine locale determines which characters are considered printable or alphabetic, the format of numerals and dates, and the collating sequence of characters. Most output and input functions respect the locale setting.
One exception is the parse and deparse functions for reading and writing the language syntax, which is independent of the locale. Also, object serialization does not depend on the locale, in an effort to produce files that may be read on any system.
The engine initially sets each locale category by reading the following environment variables in order, and using the first variable that is set: First, "LC_ALL". Second, the category name (such as "LC_COLLATE"). Third, "LANG". If none of these environment variables are set, the locale value is "en_US". The same logic is used to set the default locale value when Sys.setlocale is called with locale="".
One exception to the above is the "LC_NUMERIC" locale category, which is initially set to "C". This category can only be changed by explicitly calling Sys.setlocale is called with category="LC_NUMERIC".
Spotfire Enterprise Runtime for R accepts locales such as "en_US" (for the English-language locale in the Unites States) or "fr_FR" (for the French-language locale in France). These locales have a two-letter lowercase language code (using the ISO-639 standard), and a two-letter uppercase country code (using the ISO-3166 standard). On Windows, the engine also accepts longer locale names such as "English_United States.1252" or "French_France.1252". Unknown locale names may be accepted, but the engine will interpret them the same as the default locale.
Spotfire Enterprise Runtime for R uses the current "LC_TIME" locale when parsing or writing dates (see format.Date), to determine the appropriate words for the days of the weeks and the months.
Sys.localeconv currently returns a fixed list of values, regardless of the locale values.
Value
Sys.setlocale returns a string describing the current locale after setting it to what you asked for.
Sys.getlocale returns a string describing the current locale. If the category argument is "LC_ALL", it returns a string describing the locales for each of the categories. If the category argument is not "LC_ALL", it returns the single locale string for that category, which is suitable for input as the locale argument to Sys.setlocale().
Sys.localeconv returns a character vector with names describing various aspects of how to format numbers and money in the current locale. E.g., the "decimal_point" element tells whether the decimal point symbol is a period or comma and the "int_curr_symbol" gives the international currency abbreviation for the local currency.
Examples
## Get current locale information for all categories
Sys.getlocale()

## Get current locale for the LC_CTYPE category Sys.getlocale("LC_CTYPE")

## Not run: ## Set default locale from the operating system Sys.setlocale(locale="")

## Set locale for all categories to "C" Sys.setlocale(locale="C")

## turn off locale-specific sorting Sys.setlocale(cat = "LC_COLLATE", locale = "C") ## End(Not run)

## Find details of the numerical and monetary representations in ## the current locale Sys.localeconv()

Package base version 6.1.1-7
Package Index