Language specific character sets, such as ISO8859-1,
ISO8859-15, KOI8-R, and CP437, are described in
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.

Note:

FreeBSD uses Xorg-compatible locale encodings.

The rest of this section describes the various methods for
configuring the locale on a FreeBSD system. The next section
will discuss the considerations for finding and compiling
applications with i18n support.

22.2.1.Â Setting Locale for Login Shell

Locale 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 locale

MM_CHARSET, which sets the
MIME character set used by
applications

In addition to the user's shell configuration, these
variables should also be set for specific application
configuration and Xorg
configuration.

Two 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.

22.2.1.1.Â Login Classes Method

This 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:

Here 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,LC_COLLATE=zh_TW.Big5,LC_CTYPE=zh_TW.Big5,LC_MESSAGES=zh_TW.Big5,LC_MONETARY=zh_TW.Big5,LC_NUMERIC=zh_TW.Big5,LC_TIME=zh_TW.Big5:\
:charset=big5:\
:xmodifiers="@im=gcin": #Set gcin as the XIM Input Server

Alternately, 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:

Whenever /etc/login.conf is edited,
remember to execute the following command to update the
capability database:

#cap_mkdb /etc/login.conf

22.2.1.1.1.Â Utilities Which Change Login Classes

In 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/sh

When 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:

#adduser -class language

If pw is used to add new users,
specify the locale as follows:

#pw useradd user_name -L language

22.2.1.2.Â Shell Startup File Method

This 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:

However, 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-1
setenv MM_CHARSET ISO-8859-1

To 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 LANG

setenv LANG de_DE.ISO8859-1

22.2.2.Â Console Setup

Several 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_name

The keymap and screenmap can be set by adding the
following to /etc/rc.conf:

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 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.

For languages with wide or multibyte characters, install a
console for that language from the FreeBSD Ports Collection. The
available ports are summarized in TableÂ 22.3, “Available Console from Ports Collection”. Once installed, refer to the
port's pkg-message or man pages for
configuration and usage instructions.

If moused is enabled in
/etc/rc.conf, additional configuration
may be required. By default, the mouse cursor of the
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=3

22.2.3.Â Xorg Setup

ChapterÂ 5, The X Window System describes how to install and
configure Xorg. When configuring
Xorg for localization, additional
fonts and input methods are available from the FreeBSD 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.

The X Input Method (XIM) protocol is an
Xorg standard for inputting
non-English characters. TableÂ 22.4, “Available Input Methods”
summarizes the input method applications which are available
in the FreeBSD Ports Collection. Additional Fcitx and Uim
applications are also available.