ovhaag
ovhaag

Reputation: 1278

Changed locale in R. Reset failes

OS X 10.9.2 + R 3.0.2 and R 3.1.0

I have set the locale in R with

Sys.setlocale(category = "LC_TIME", locale = "C") 

because I wanted English weekday names in my plots. (LC_TIME locale was "de_DE.UTF-8") This worked, but the change has become permanent. Restarting R gives:

During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C"
..
5: Setting LC_MONETARY failed, using "C" 

I tried to reset the locale with these commands:

Sys.setlocale(category = "LC_TIME", locale = "")
Sys.setlocale(category = "LC_ALL", locale = "")

In both cases I got a warning:

..
OS reports request to set locale to "" cannot be honored

I also did reinstall R (in combination with an upgrade from R 3.0.2 to R 3.1.0 Nothing changed. May be the locale settings are stored in a dot-file, which is kept when upgrading, but I can't find where.

So if nobody knows a working reset command, an idea in which file the locale setting is stored may suffice.

Upvotes: 1

Views: 2052

Answers (2)

ovhaag
ovhaag

Reputation: 1278

Enforcing the language setting with

system("defaults write org.R-project.R force.LANG de_DE.UTF-8")

or

system("defaults write org.R-project.R force.LANG en_US.UTF-8")

plus restart fixed R on my computer. (I tested both settings.)

  • R starts now without error
  • The setting is permanent. I.e. I can quit and restart R and the setting "survives".
  • The Sys.setlocale(..) command sets the locale temporarily
  • The reset with Sys.setlocale(.., locale = "") works now!

Information on enforcing the language setting can be found in R -- Help -- R for Mac OS X FAQ -- 7 Internationalization of the R.app: If you use a non-standard setup .. you can override the auto-detection ...

Unclear is if it really was the Sys.setlocale() command that corrupted my system, or if it was something I did later. And unclear is if there is a way to reset the system to the original state. That would be in my eyes a more natural solution than enforcing the language setting.

Upvotes: 2

IRTFM
IRTFM

Reputation: 263342

The OP has promised to post a more complete answer but it should be noted that it was in the R-for-MAC-FAQ

 7 Internationalization of the R.app

Upvotes: 0

Related Questions