A locale is a collection of files, data and sometimes code which contain the necessary information to adapt Solaris to a specific geographical market.
A locale is essentially a “bundle”, containing information such as:
1. the messages displayed to the user (localized messages)
3. date and time formatting conventions
4. monetary conventions decimal formatting conventions
5. collation (sort) order
6. fonts and/or other writing specific information.
The default naming convention for a locale is :
for example :
Note: In Solaris, there can be several locales for a single language.
For example, French is spoken in France and in Canada, but each country has different ways of displaying monetary and time information. Therefore, there is both the fr_FR locale (French – France) as well as the fr_CA locale (French – Canada) to accomodate these different cultural conventions.
Viewing locales and locale settings
To view the current locale settings:
# locale LANG= LC_CTYPE="C" LC_NUMERIC="C" LC_TIME="C" LC_COLLATE="C" LC_MONETARY="C" LC_MESSAGES="C" LC_ALL=
As you can see above currently all the locale categories are set to “C”.
To obtain the list of locales available in a system, run the following command:
# locale -a C POSIX iso_8859_1
Adding new locale
As seen above there are only 3 locales installed on the system (C, POSIX, iso_8859_1). In order to change the locale we must first get it installed from the Solaris 10 DVD. To install a new locale first find the local name you want to install from the below command :
# localeadm -lv Verbose mode Checking for installed packages. This could take a while. ..... (output ommitted for brevity) .... Checking for India region (india) (verbose mode) (c_solaris packages) package SUNWeuluf not found package SUNWinleu not found No packages found. ..... (output ommitted for brevity) ....
From the above command output, you can get all the available locale names. Suppose you want to install locale to have indian languages. First mount the Solaris ISO. and then install the locale named india using the localeadm command.
# mount -F hsfs -o ro `lofiadm -a /path/to/solaris_iso` /mnt
# localeadm -a india -d /mnt/Solaris_10/Product
To verify the newly installed locale :
# locale -a C POSIX bn_IN.UTF-8 en_IN.UTF-8 gu_IN.UTF-8 hi_IN.UTF-8 iso_8859_1 kn_IN.UTF-8 mr_IN.UTF-8 ta_IN.UTF-8 te_IN.UTF-8
Setting new locale
1. Changing locales gloablly for all users
So now if you want to set the date and time format in Inian language Hindi you can set LC_TIME locale category to hi_IN.UTF-8. This requires a reboot of the system. Edit the /etc/default/init file and set/add the LANG and LC_* variables.
# vi /etc/default/init LC_TIME=hi_IN.UTF-8
Reboot the system:
# shutdown -i6 -g0 -y
2. Setting user specific locales
Different locales can also be set for different users on the same system. To do this edit the profile of the individual user to export the specifi locales. For example,
# vi $HOME/.profile LC_TIME=hi_IN.UTF-8; export LANG
To verify the new locales set :
LANG= LC_CTYPE="C" LC_NUMERIC="C" LC_TIME=hi_IN.UTF-8 LC_COLLATE="C" LC_MONETARY="C" LC_MESSAGES="C" LC_ALL=
Check the current date, and you would see the the in the Hindi language.