Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Change locale language on OS X Mavericks

Hi to all,


I am from Portugal and I use English as my main system language. When i try to change the region to Portugal the format language remain in English. However, if I change the format language to Portuguese automatically change the region to Portuguese (Brasil). If I try to change the region again to Portugal I saw a dash in Portugal and if I select it the format language change again to English. If I make "echo $LANG" in terminal I have an empty return. I can change the locale language using terminal, but in Mountain Lion I could change the locale language by that way. Any idea why this is happening? Thanks to all.

Posted on Oct 25, 2013 2:02 AM

Reply
Question marked as Best reply

Posted on Oct 25, 2013 9:31 AM

I found the solution here:


http://apple.stackexchange.com/questions/21096/where-does-lang-variable-gets-set -in-mac-os-x


By default, Terminal sets the locale environment variables to match the currently selected language and time/date/number formats that Terminal is using, which is selected via

System Preferences > Language and Text

(That's the name on Lion. On earlier systems the exact name of the preference panel may vary.)

A temporary solution is to drag English to the top of the list of languages, then open Terminal, then move Lithuanian back to the top. Then only Terminal will be in English. However, it will reset to Lithuanian if you Quit and restart Terminal.

A persistent approach is to tell Terminal to not set the locale environment variables, by turning off

Terminal > Preferences > Settings > [profile] > Advanced > Set locale environment variables on startup

Then the locale will default to "C" with no language specified, and most programs will then default to English.

Note that turning this off means that some programs won't be aware of which character encoding Terminal is using and will assume that it's ASCII or ISO-Latin-1 only. So if Terminal is using UTF-8 (the default), those programs may or may not behave as desired.

If this is mostly about

wget
, I recommend that you make a copy of the default settings profile, turn off the locale setting in your custom profile, and only use that profile when using
wget
, so that you can continue to use UTF-8 with full support when using other programs, using the default settings.

As others have mentioned, you can also override the initial locale settings supplied by Terminal in a shell startup script. For zsh, put it in ~/.zshrc. For bash, use ~/.bashrc (and if you don't already have one, create a ~/.bash_profile that runs ~/.bashrc).

See x-man-page://1/locale for more information about each of the locale environment values.

However, if you were to merely

unset LANG
or set it to "C", that would normally apply to all of your shells and programs, whereas most of the time you probably want to use UTF-8 and have Terminal set the locale variables to match, to get the highest degree of cooperation, fidelity and functionality.

Therefore, if you're going to go that route, I suggest you write code to edit, rather than replace, the initial values, so that you preserve the encoding information ("UTF-8") and merely force the language to English, rather than setting the variables to "C".

For example, this works in zsh and bash:

# Replace Lithuanian with English export LANG=${LANG/lt_LT/en_US}

When

LANG="lt_LT.UTF-8"
, this will change it to
LANG="en_US.UTF-8"
. I don't have
wget
available to test this, but this should suffice.

Doing it this way means that if you change the character encoding preference in Terminal, you won't override that in your shell startup script.

1 reply
Question marked as Best reply

Oct 25, 2013 9:31 AM in response to fmiguel

I found the solution here:


http://apple.stackexchange.com/questions/21096/where-does-lang-variable-gets-set -in-mac-os-x


By default, Terminal sets the locale environment variables to match the currently selected language and time/date/number formats that Terminal is using, which is selected via

System Preferences > Language and Text

(That's the name on Lion. On earlier systems the exact name of the preference panel may vary.)

A temporary solution is to drag English to the top of the list of languages, then open Terminal, then move Lithuanian back to the top. Then only Terminal will be in English. However, it will reset to Lithuanian if you Quit and restart Terminal.

A persistent approach is to tell Terminal to not set the locale environment variables, by turning off

Terminal > Preferences > Settings > [profile] > Advanced > Set locale environment variables on startup

Then the locale will default to "C" with no language specified, and most programs will then default to English.

Note that turning this off means that some programs won't be aware of which character encoding Terminal is using and will assume that it's ASCII or ISO-Latin-1 only. So if Terminal is using UTF-8 (the default), those programs may or may not behave as desired.

If this is mostly about

wget
, I recommend that you make a copy of the default settings profile, turn off the locale setting in your custom profile, and only use that profile when using
wget
, so that you can continue to use UTF-8 with full support when using other programs, using the default settings.

As others have mentioned, you can also override the initial locale settings supplied by Terminal in a shell startup script. For zsh, put it in ~/.zshrc. For bash, use ~/.bashrc (and if you don't already have one, create a ~/.bash_profile that runs ~/.bashrc).

See x-man-page://1/locale for more information about each of the locale environment values.

However, if you were to merely

unset LANG
or set it to "C", that would normally apply to all of your shells and programs, whereas most of the time you probably want to use UTF-8 and have Terminal set the locale variables to match, to get the highest degree of cooperation, fidelity and functionality.

Therefore, if you're going to go that route, I suggest you write code to edit, rather than replace, the initial values, so that you preserve the encoding information ("UTF-8") and merely force the language to English, rather than setting the variables to "C".

For example, this works in zsh and bash:

# Replace Lithuanian with English export LANG=${LANG/lt_LT/en_US}

When

LANG="lt_LT.UTF-8"
, this will change it to
LANG="en_US.UTF-8"
. I don't have
wget
available to test this, but this should suffice.

Doing it this way means that if you change the character encoding preference in Terminal, you won't override that in your shell startup script.

Change locale language on OS X Mavericks

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.