How to install and change locale in Solaris 11

In the default installation of Oracle Solaris 11, ten core locales are available. In this article I describe how to use pkg utility to add support for additional languages.

The following table lists Oracle Solaris 11 core locales:

Table 1 — Langauges and Core locales
LanguageCore locale
Chinese - Simplified zh_CN.UTF-8
Chinese - Traditional zh_TW.UTF-8
English en_US.UTF-8
French fr_FR.UTF-8
German de_DE.UTF-8
Italian it_IT.UTF-8
Japanese ja_JP.UTF-8
Korean ko_KR.UTF-8
Portuguese - Brazilian pt_BR.UTF-8
Spanish es_ES.UTF-8

To add language support, we set the pertinent locale facet with the pkg change-facet command. For example, you can use the following command to install and add support for English as spoken in the United Kingdom.

  • To install files common for locales specific to English in the United Kingdom:
    # pkg change-facet locale.en_GB=True
  • To install files common for all English locales and all of the English variants:
    # pkg change-facet locale.en_*=True

To remove locales, specify False or None instead of True.

  • False — explicitly deselects applicable files.
  • None removes the specific locale configuration and causes applicable files to get deselected implicitly because locale.*=False is configured in default installations.

To confirm the locale has been installed, we can issues the locale command. For example:

# locale -a | grep en_
en_GB.ISO8859-1
en_GB.ISO8859-15
en_GB.UTF-8
en_US.ISO8859-1
en_US.ISO8859-15
en_US.UTF-8

To set the the default system local to be en_GB, we can execute the following commands:

# svccfg -s svc:/system/environment:init setprop environment/LC_ALL = astring: "en_GB.UTF.8"
# svccfg -s svc:/system/environment:init setprop environment/LC_COLLATE = astring: "en_GB.UTF.8"
# svccfg -s svc:/system/environment:init setprop environment/LC_CTYPE = astring: "en_GB.UTF.8"
# svccfg -s svc:/system/environment:init setprop environment/LC_NUMERIC = astring: "en_GB.UTF.8"
# svccfg -s svc:/system/environment:init setprop environment/LC_TIME = astring: "en_GB.UTF.8"
# svccfg -s svc:/system/environment:init setprop environment/LC_MONETARY = astring: "en_GB.UTF.8"
# svcadm refresh svc:/system/environment

To list the information changed, we can execute the following:

# svccfg -s svc:/system/environment:init
svc:/system/environment:init> listprop
umask                            application
umask/umask                      astring     022
umask/value_authorization        astring     solaris.smf.value.environment
environment                      application
environment/TZ                   astring     localtime
environment/value_authorization  astring     solaris.smf.value.environment
environment/LC_CTYPE             astring     en_GB.UTF8
environment/LC_COLLATE           astring     en_GB.UTF8
environment/LC_MESSAGES          astring     C
environment/LC_MONETARY          astring     en_GB.UTF8
environment/LC_NUMERIC           astring     en_GB.UTF8
environment/LC_TIME              astring     en_GB.UTF8
environment/LC_ALL               astring
environment/LC_LANG              astring
environment/LANG                 astring
startd                           framework
startd/duration                  astring     transient
general                          framework
general/action_authorization     astring     solaris.smf.manage.environment
general/complete                 astring
general/enabled                  boolean     true
sysconfig                        sysconfig
sysconfig/config_properties      astring     "sc_all:environment/LC_ALL" "sc_lang:environment/LANG" "sc_ctype:environment/LC_CTYPE" "sc_numeric:environment/LC_NUMERIC" "sc_time:environment/LC_TIME" "sc_collate:environment/LC_COLLATE" "sc_monetary:environment/LC_MONETARY" "sc_messages:environment/LC_MESSAGES" "sc_tz:environment/TZ"
sysconfig/group                  astring     location
sysconfig/reconfigurable         boolean     false
sysconfig/value_authorization    astring     solaris.smf.value.environment

Optional, reboot the server

# init 6