1

On my somewhat creaky MBP running Yosemite, I find that the POSIX environment variables for controlling the locale (LANG and LC_*) are properly set inside Terminal windows...

$ printenv | grep -E '^(LANG|LC_)'
LANG=en_US.UTF-8
$ locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL=

... but they are not properly set in the environment provided to GUI applications; for instance, inside an Emacs shell window, the above commands print

$ printenv | grep -E '^(LANG|LC_)'

$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

How do I ensure that every process running on the computer, regardless of how it was started sees the proper LANG= environment setting? Bonus points for an answer that doesn't need manual action to stay in sync with the language settings in System Preferences.

(Related questions: Where does $LANG variable gets set in Mac OS X? indicates that it is Terminal.app that reflects the language settings from System Preferences to the shell's environment. Where are system environment variables set in Mountain Lion? suggests that the proper way to make manual global environment settings keeps getting changed with each new version of the operating system, yuck.)

  • What happens when you start Emacs from the shell? - open -a Emacs – fd0 Jun 22 '16 at 20:16
  • @fd0 That's interesting, the settings are correct if I do it that way. But I want them to be correct if opened from the Dock or whereever. Also, Emacs is just an example; this potentially affects several other GUI applications I have. – zwol Jun 22 '16 at 20:19
  • Then you will need to hack the OS with one of the solutions that fits your current operating systems. If you are willing to change your workflow, the solution I proposed has worked for at least seven versions of the OS. – fd0 Jun 22 '16 at 20:50

You must log in to answer this question.

Browse other questions tagged .