Localization -
i18n/L10n Usage and
SetupAndreyChernovContributed
by Michael
C.WuRewritten
by Synopsis&os; is a distributed project with users and contributors
located all over the world. As such, &os; supports localization
into many languages, allowing users to view, input, or
process data in non-English languages. One can
choose from most of the major languages, including, but not
limited to: Chinese, German, Japanese, Korean, French, Russian,
and Vietnamese.internationalizationlocalizationlocalizationThe term internationalization has been shortened to
i18n, which represents the number of letters
between the first and the last letters of internationalization.
L10n uses the same naming scheme, but from
localization. The
i18n/L10n methods,
protocols, and applications allow users to use languages of
their choice.This chapter discusses the internationalization and
localization features of &os;. After reading this chapter, you
will know:How locale names are constructed.How to set the locale for a login shell.How to configure the console for non-English
languages.How to configure Xorg for
different languages.How to find i18n-compliant applications.Where to find more information for configuring specific
languages.Before reading this chapter, you should:Know how to install
additional third-party
applications.Using LocalizationlocaleLocalization settings are based on three components:
the language code, country code, and encoding. Locale names are
constructed from these parts as follows:LanguageCode_CountryCode.Encodinglanguage codescountry codesThe LanguageCode and
CountryCode are used to determine
the country and the specific language variation. provides some examples of
LanguageCode_CountryCode:
Common Language and Country CodesLanguageCode_Country CodeDescriptionen_USEnglish, United Statesru_RURussian, Russiazh_TWTraditional Chinese, Taiwan
A complete listing of available locales can be found by
typing:&prompt.user; locale -a | moreTo determine the current locale setting:&prompt.user; localeencodingsASCIILanguage specific character sets, such as
ISO8859-1, ISO8859-15, KOI8-R, and CP437, are
described in &man.multibyte.3;. The active list of character sets can be found at the IANA
Registry.Some languages, such as Chinese or Japanese, cannot be
represented using ASCII characters and require an extended
language encoding using either wide or multibyte characters.
Examples of wide or multibyte encodings include EUC and Big5.
Older applications may mistake these encodings for control
characters while newer applications usually recognize these
characters. Depending on the implementation, users may be
required to compile an application with wide or multibyte
character support, or to configure it correctly.&os; uses Xorg-compatible locale encodings.The rest of
this section describes the various methods for configuring the
locale on a &os; system. The next section will discuss the
considerations for finding and compiling applications with i18n
support.Setting Locale for Login ShellLocale settings are configured either in a user's
~/.login_conf
or in the startup file of the user's shell:
~/.profile,
~/.bashrc, or
~/.cshrc.Two environment
variables should be set:LANG, which sets the localePOSIXMIMEMM_CHARSET, which sets the MIME
character set used by applicationsIn addition to the user's shell configuration, these
variables should also be set for
specific application configuration and
Xorg configuration.localelogin classTwo methods are available for making the needed variable
assignments: the login
class method, which is the recommended method, and
the startup file method.
The next two sections demonstrate how to use both
methods.Login Classes MethodThis first method is the recommended method as it
assigns the required environment variables for locale name
and MIME character sets for every possible shell. This
setup can either be performed by each user or it can be
configured for all users by the superuser.This minimal example sets both variables for Latin-1
encoding in the .login_conf of an
individual user's home directory:me:\
:charset=ISO-8859-1:\
:lang=de_DE.ISO8859-1:Traditional ChineseBIG-5 encodingHere is an example of a user's
~/.login_conf that sets the variables
for Traditional Chinese in BIG-5 encoding. More variables
are needed because some applications do not correctly
respect locale variables for Chinese, Japanese, and
Korean:#Users who do not wish to use monetary units or time formats
#of Taiwan can manually change each variable
me:\
:lang=zh_TW.Big5:\
:setenv=LC_ALL=zh_TW.Big5:\
:setenv=LC_COLLATE=zh_TW.Big5:\
:setenv=LC_CTYPE=zh_TW.Big5:\
:setenv=LC_MESSAGES=zh_TW.Big5:\
:setenv=LC_MONETARY=zh_TW.Big5:\
:setenv=LC_NUMERIC=zh_TW.Big5:\
:setenv=LC_TIME=zh_TW.Big5:\
:charset=big5:\
:xmodifiers="@im=gcin": #Set gcin as the XIM Input ServerAlternately, the superuser can configure all users of
the system for localization. The following variables in
/etc/login.conf are used to set the
locale and MIME character set:language_name|Account Type Description:\
:charset=MIME_charset:\
:lang=locale_name:\
:tc=default:So, the previous Latin-1 example would look like
this:german|German Users Accounts:\
:charset=ISO-8859-1:\
:lang=de_DE.ISO8859-1:\
:tc=default:See &man.login.conf.5; for more details about these
variables.Whenever /etc/login.conf is edited,
remember to execute the following command to update the
capability database:&prompt.root; cap_mkdb /etc/login.confUtilities Which Change Login ClassesvipwIn addition to manually editing
/etc/login.conf, several utilities
are available for setting the locale for newly created
users.When using vipw to add new users,
specify the language to set the
locale:user:password:1111:11:language:0:0:User Name:/home/user:/bin/shadduserlogin classWhen using adduser to add new
users, the default language can be pre-configured for all
new users or specified for an individual user.If all new users use the same language, set
defaultclass = language in
/etc/adduser.conf.To override this setting when creating a user, either
input the required locale at this prompt:Enter login class: default []:or specify the locale to set when invoking
adduser:&prompt.root; adduser -class languagepwIf pw is used to add new users,
specify the locale as follows:&prompt.root; pw useradd user_name -L languageShell Startup File MethodThis second method is not recommended as each shell that is
used requires manual configuration, where each shell has a
different configuration file and differing syntax. As an
example, to set the German language for the
sh shell, these lines could be added to
~/.profile to set the shell for that
user only. These lines could also be added to
/etc/profile or
/usr/share/skel/dot.profile to set
that shell for all users:LANG=de_DE.ISO8859-1; export LANGMM_CHARSET=ISO-8859-1; export MM_CHARSETHowever, the name of the configuration file and the
syntax used differs for the csh shell.
These are the equivalent settings for
~/.csh.login,
/etc/csh.login, or
/usr/share/skel/dot.login:setenv LANG de_DE.ISO8859-1setenv MM_CHARSET ISO-8859-1To complicate matters, the syntax needed to configure
Xorg in
~/.xinitrc also depends upon the
shell. The first example is for the sh
shell and the second is for the csh
shell:LANG=de_DE.ISO8859-1; export LANGsetenv LANG de_DE.ISO8859-1Console SetupSeveral localized fonts are available for the console. To
see a listing of available fonts, type
ls /usr/share/syscons/fonts. To configure
the console font, specify the
font_name,
without the .fnt suffix, in
/etc/rc.conf:font8x16=font_name
font8x14=font_name
font8x8=font_namekeymapscreenmapThe keymap and screenmap can be set by adding the
following to /etc/rc.conf:scrnmap=screenmap_name
keymap=keymap_name
keychange="fkey_number sequence"To see the list of available screenmaps, type
ls /usr/share/syscons/scrnmaps. Do not
include the .scm suffix when specifying
screenmap_name. A screenmap with a
corresponding mapped font is usually needed as a workaround
for expanding bit 8 to bit 9 on a VGA adapter's font character
matrix so that letters are moved out of the pseudographics
area if the screen font uses a bit 8 column.To see the list of available keymaps, type
ls /usr/share/syscons/keymaps. When
specifying the keymap_name, do not
include the .kbd suffix. To test
keymaps without rebooting,
use &man.kbdmap.1;.The keychange entry is usually needed
to program function keys to match the selected terminal type
because function key sequences cannot be defined in the
keymap.Next, set the correct console terminal type in
/etc/ttys for all virtual terminal
entries. summarizes the
available terminal types.:
Defined Terminal Types for Character SetsCharacter SetTerminal TypeISO8859-1 or ISO8859-15cons25l1ISO8859-2cons25l2ISO8859-7cons25l7KOI8-Rcons25rKOI8-Ucons25uCP437 (VGA default)cons25US-ASCIIcons25w
mousedFor languages with wide or multibyte characters, install a
console for that language from the &os; Ports Collection. The
available ports are summarized in . Once installed, refer to the
port's pkg-message or man pages for
configuration and usage instructions.
Available Console From Ports CollectionLanguagePort LocationTraditional Chinese (BIG-5)chinese/big5conChinese/Japanese/Koreanchinese/cceChinese/Japanese/Koreanchinese/zhconJapanesechinese/kon2Japanesejapanese/kon2-14dotJapanesejapanese/kon2-16dot
If moused is enabled in
/etc/rc.conf, additional configuration
may be required. By default, the mouse cursor of the
&man.syscons.4; driver occupies the
0xd0-0xd3 range in the
character set. If the language uses this range, move the
cursor's range by adding the
following line to /etc/rc.conf:mousechar_start=3Xorg Setup describes how to install and
configure Xorg. When configuring
Xorg for localization, additional
fonts and input methods are available from the &os; Ports
Collection. Application specific i18n
settings such as fonts and menus can be tuned in
~/.Xresources and should allow users to
view their selected language in graphical application
menus.X Input Method (XIM)The X Input Method (XIM) protocol is an
Xorg standard for inputting
non-English characters.
summarizes the input method applications which are available
in the &os; Ports Collection. Additional Fcitx and Uim
applications are also available.
Available Input MethodsLanguageInput MethodChinesechinese/gcinChinesechinese/ibus-chewingChinesechinese/ibus-pinyinChinesechinese/oximChinesechinese/scim-fcitxChinesechinese/scim-pinyinChinesechinese/scim-tablesJapanesejapanese/ibus-anthyJapanesejapanese/ibus-mozcJapanesejapanese/ibus-skkJapanesejapanese/im-jaJapanesejapanese/kinput2Japanesejapanese/scim-anthyJapanesejapanese/scim-cannaJapanesejapanese/scim-honokaJapanesejapanese/scim-honoka-plugin-romkanJapanesejapanese/scim-honoka-plugin-wnnJapanesejapanese/scim-primeJapanesejapanese/scim-skkJapanesejapanese/scim-tablesJapanesejapanese/scim-tomoeJapanesejapanese/scim-uimJapanesejapanese/skkinputJapanesejapanese/skkinput3Japanesejapanese/uim-anthyKoreankorean/ibus-hangulKoreankorean/imhangulKoreankorean/nabiKoreankorean/scim-hangulKoreankorean/scim-tablesVietnamesevietnamese/xvnkbVietnamesevietnamese/x-unikey
Finding i18n Applicationsi18n applications are programmed using
i18n kits under libraries. These allow
developers to write a simple file and translate displayed menus
and texts to each language.The &os;
Ports Collection contains many
applications with built-in support for wide or multibyte characters for several
languages. Such applications include i18n in their names for
easy identification. However, they do not always support the
language needed.Some applications can be compiled
with the specific
charset. This is usually done in the port's
Makefile or by passing a value to
configure. Refer to the i18n documentation
in the respective &os; port's source for more information on how to
determine the needed configure value
or the port's Makefile to determine which
compile options to use when building the port.Locale Configuration for Specific LanguagesThis section provides configuration examples for localizing
a &os; system for the Russian language. It then provides some
additional resources for localizing other languages.Russian Language (KOI8-R Encoding)AndreyChernovOriginally
contributed by localizationRussianThis section shows the specific settings needed to
localize a &os; system for the Russian language. Refer to
Using Localization for
a more complete description of each type of setting.To set this locale for the login shell, add the following
lines to each user's
~/.login_conf:me:My Account:\
:charset=KOI8-R:\
:lang=ru_RU.KOI8-R:To configure the console, add the following lines to
/etc/rc.conf:keymap="ru.koi8-r"
scrnmap="koi8-r2cp866"
font8x16="cp866b-8x16"
font8x14="cp866-8x14"
font8x8="cp866-8x8"
mousechar_start=3For each ttyv entry in
/etc/ttys, use
cons25r as the terminal type.printersTo configure printing, a special output filter is needed
to convert from KOI8-R to CP866 since most printers with
Russian characters come with hardware code page CP866. &os;
includes a default filter for this purpose,
/usr/libexec/lpr/ru/koi2alt. To use this
filter, add this entry to
/etc/printcap:lp|Russian local line printer:\
:sh:of=/usr/libexec/lpr/ru/koi2alt:\
:lp=/dev/lpt0:sd=/var/spool/output/lpd:lf=/var/log/lpd-errs:Refer to &man.printcap.5; for a more detailed
explanation.To configure support for Russian filenames in mounted
&ms-dos; file systems, include and the
locale name when adding an entry to
/etc/fstab:/dev/ad0s2 /dos/c msdos rw,-Lru_RU.KOI8-R 0 0Refer to &man.mount.msdosfs.8; for more details.To configure Russian fonts for
&xorg;, install the
x11-fonts/xorg-fonts-cyrillic package.
Then, check the "Files" section in
/etc/X11/xorg.conf. The following line
must be added before any other
FontPath entries:FontPath "/usr/local/lib/X11/fonts/cyrillic"Additional Cyrillic fonts are available in the Ports
Collection.To activate a Russian keyboard, add the following to the
"Keyboard" section of
/etc/xorg.conf:Option "XkbLayout" "us,ru"
Option "XkbOptions" "grp:toggle"Make sure that XkbDisable is
commented out in that file.For grp:toggle use
Right Alt, for
grp:ctrl_shift_toggle use CtrlShift.
For grp:caps_toggle use
CapsLock. The old
CapsLock function is still available in LAT
mode only using ShiftCapsLock.
grp:caps_toggle does not work in
&xorg; for some unknown
reason.If the keyboard has &windows; keys, and
some non-alphabetical keys are mapped incorrectly, add the
following line to /etc/xorg.conf:Option "XkbVariant" ",winkeys"The Russian XKB keyboard may not work with
non-localized applications. Minimally localized applications should call a
XtSetLanguageProc (NULL, NULL, NULL);
function early in the program.See http://koi8.pp.ru/xwin.html
for more instructions on
localizing Xorg applications. For
more general information about KOI8-R encoding, refer to
http://koi8.pp.ru/.Additional Language-Specific ResourcesThis section lists some additional resources for
configuring other locales.localizationTraditional ChineselocalizationGermanlocalizationGreeklocalizationJapaneselocalizationKoreanTraditional Chinese for TaiwanThe &os;-Taiwan Project has a Chinese HOWTO for &os;
at http://netlab.cse.yzu.edu.tw/~statue/freebsd/zh-tut/.German Language Localization for All ISO 8859-1
LanguagesA
tutorial on using umlauts on &os; is
available in German at http://user.cs.tu-berlin.de/~eserte/FreeBSD/doc/umlaute/umlaute.html.Greek Language LocalizationA complete article on Greek support in &os;
is available here,
in Greek only, as part of the official &os; Greek
documentation.Japanese and Korean Language LocalizationFor Japanese, refer to http://www.jp.FreeBSD.org/,
and for Korean, refer to http://www.kr.FreeBSD.org/.Non-English &os; DocumentationSome &os; contributors have translated parts of the
&os; documentation to other languages. They are
available through links on the &os; web site or
in /usr/share/doc.