How to get current or set wanted regional format in the terminal?
Regional Formats changes the following variables:
LC_NUMERIC
LC_TIME
LC_MONETARY
You can use locale
to check the current set format.
ron@ron:~$ locale
LANG=en_US
LANGUAGE=en_US
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=en_US.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=
If you want to see all the locale available in your system you can use:
ron@ron:~$ locale -a
C
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
To change, for example, the date format to US you can use:
LC_TIME=en_US.UTF-8
To change it permanently:
sudo update-locale LC_TIME=en_US.UTF-8
You can also manually edit the file /etc/default/locale
instead of update-locale
, if you wish so. Changes will be applied the next time you log-in.
Refer to Locale - Community Help Wiki for more details. man 5 locale
will you more options to find-tune any of the formats.
This command sets regional formats to en_US.UTF-8 in the same manner as Language Support:
dbus-send --print-reply --system --dest=org.freedesktop.Accounts /org/freedesktop/Accounts/User$UID org.freedesktop.Accounts.User.SetFormatsLocale string:'en_US.UTF-8'
It updates your user setting in accountsservice and the file ~/.pam_environment
.
/etc/default/locale
is updated by Language Support only if you click the Apply System-Wide button.
Haven't figured out the corresponding command to check the current format.
Can't help wondering why you want to do it. It's normally not a good idea to mess with these settings manually on an Ubuntu deskop. Language Support does the right thing.