12.2 Language-Specific Locale Configuration
This section describes various methods for configuring locale settings on a FreeBSD system.
Using Localization
Localization settings are based on three components: language code, region code, and encoding. The locale name is composed of these parts as follows:
language_code (lowercase)_region_code (uppercase).encodingThe language code and region code are used to determine the region and specific language variant. The following are some examples of language_code_region_code:
Common Language and Region Codes
en_US.UTF-8
United States (English)
zh_CN.UTF-8
China (Simplified Chinese)
zh_TW.UTF-8
Taiwan, China (Traditional Chinese)
zh_HK.UTF-8
Hong Kong, China (Traditional Chinese)
Type the following command to view the complete list of available locales:
$ locale -a | more
C
C.UTF-8
POSIX
af_ZA.ISO8859-1
af_ZA.ISO8859-15
af_ZA.UTF-8
am_ET.UTF-8
ar_AE.UTF-8
ar_EG.UTF-8
ar_JO.UTF-8
ar_MA.UTF-8
ar_QA.UTF-8
ar_SA.UTF-8
be_BY.CP1131
be_BY.CP1251
be_BY.ISO8859-5
be_BY.UTF-8
bg_BG.CP1251
bg_BG.UTF-8
ca_AD.ISO8859-1
ca_AD.ISO8859-15
ca_AD.UTF-8
ca_ES.ISO8859-1
ca_ES.ISO8859-15
ca_ES.UTF-8
--More--(byte 314) # Press Enter to continue browsing, press q to exitUse the locale command to view the current system localization settings:
Languages such as Chinese or Japanese cannot be represented with ASCII characters and require extended language encodings using wide or multibyte characters. It is recommended to use UTF-8.
Note
The locale encoding used by FreeBSD is compatible with Xorg.
Setting the Locale for the Login Shell
The locale can be configured in the user's ~/.login_conf file or in the user's shell startup files: ~/.profile, ~/.bashrc, or ~/.cshrc.
Two environment variables need to be set:
LANG: sets the localeMM_CHARSET: sets the MIME character set used by applications
In addition to the user's shell configuration, these variables also need to be set in the configuration of specific applications and Xorg.
There are two methods to set the required variables: the recommended method is through the login class, and the other is through startup files.
Login Class Method
This is the recommended method, which sets the required locale and MIME character set environment variables for each shell. This configuration can be done individually by each user, or uniformly by the superuser for all users.
The following is a minimal example that sets two variables for Simplified Chinese (UTF-8 encoding) in a personal user's ~/.login_conf:
The following is an example of a user's ~/.login_conf that sets variables for Simplified Chinese UTF-8 encoding. Some applications do not correctly handle the locale variables for Chinese, Japanese, and Korean, so more variables are needed to ensure proper operation:
Note
This
setenvis unrelated to csh.
Additionally, the superuser can configure localization settings for all users on the system. The following variables can be configured in /etc/login.conf to set the locale and MIME character set:
For example, the previously mentioned Simplified Chinese example can be configured in /etc/login.conf as follows:
Tip
This file contains a predefined russian class.
After each edit of /etc/login.conf, the following command must be executed to rebuild the login capability database:
Note
End users need to run the
cap_mkdbcommand on ~/.login_conf for the changes to take effect.
Tools for Changing the Login Class
In addition to manually editing /etc/login.conf, some tools can be used to set locale settings for newly created users.
When using vipw to add a new user, the chinese class can be specified to set the locale to Simplified Chinese (UTF-8 encoding):
For example, to assign the chinese class to user ykla, where no custom user class is currently assigned:
After assignment, it becomes:
When using adduser to add new users, a default language can be preconfigured for all new users, or a language can be specified for individual users.
If all new users use the same language (assuming Simplified Chinese), defaultclass=chinese can be set in /etc/adduser.conf.
To override this setting when creating a user, enter the desired login class at the following prompt:
Or specify the locale when invoking adduser:
If using pw to add a new user test, specify the locale as follows:
To change the login class of an existing user, chpass or pw usermod can be used. Invoke as root and provide the username to edit as an argument:
Verify the modification result:
Shell Startup File Method
This method is not recommended because each shell requires manual configuration, and each shell's configuration file and syntax differ. For example, to set Simplified Chinese for the sh shell, the following lines can be added to the ~/.profile file to set the shell for that user only. These lines can also be added to /etc/profile or /usr/share/skel/dot.profile to set the shell for all users:
However, the csh shell's configuration file name and syntax are different. The equivalent settings in ~/.login, /etc/csh.login, or /usr/share/skel/dot.login are:
The syntax for configuring Xorg also depends on the shell being used, making the situation more complex. In ~/.xinitrc, the configuration examples for sh shell and csh shell are as follows:
Console Settings
The VT console uses xterm as the default terminal type.
Fonts
The FreeBSD VT console natively supports CJK character sets (CJK Unified Ideographs), and Chinese can be displayed by loading fonts. The required font format is .fnt: this is a binary font file, not a collection of code tables and PNG images.
Use the following command to switch the console font to test.fnt (effective only for the current session; reverts to the default font after reboot):
FreeBSD's base system provides a tool to convert bdf or hex format to fnt files, where -o is a required parameter:
Chinese font example:

Tip
If the above link is unavailable, please visit https://github.com/FreeBSD-Ask/fnt-fonts to download the font.

The above commands only take effect temporarily. To make them permanent, add the following to the /etc/rc.conf file:
Keyboard Layout
Keyboard layout files are located in /usr/share/vt/keymaps/:
For example, to change the current layout to the international US keyboard, add the following to the /etc/rc.conf file:
Tip
When specifying a keyboard layout, do not include the .kbd suffix.
This takes effect after reboot.
To test the keyboard layout without rebooting, the kbdmap command can be used to interactively select a keyboard layout:

Input Methods
Available Input Methods summarizes the input method applications available in FreeBSD Ports.
Fcitx 5 Available Input Methods
Simplified Chinese (Pinyin)
Traditional Chinese (Bopomofo)
Traditional Chinese (Bopomofo)
Chinese (RIME)
Chinese (Shape-based input method)
Japanese (Anthy)
Japanese (SKK)
Japanese (SKK)
Korean
Non-Chinese input method tables
IBus Available Input Methods
Simplified Chinese (Pinyin)
Traditional Chinese (Bopomofo)
Chinese (RIME)
Japanese (Anthy)
Japanese (Mozc)
Japanese (SKK)
Korean
Troubleshooting and Outstanding Issues
How to Manually Generate fnt Files for Chinese Fonts
The method provided by https://github.com/usonianhorizon/vt-fnt is relatively complex and can generate bdf files, but will produce the same error messages as described in the text. This project explores methods for generating FreeBSD console fonts. The FontForge software mentioned in the text provides a Windows version, available for download at https://fontforge.org/en-US/downloads/windows-dl/.
References
FreeBSD Project. rc.conf[EB/OL]. [2026-03-25]. https://man.freebsd.org/cgi/man.cgi?query=rc.conf&sektion=5. This manual page provides detailed information about the syntax and options of the rc.conf system configuration file.
Mariusz. vidcontrol font and color via /etc/rc.conf problem[EB/OL]. [2026-03-25]. https://forums.freebsd.org/threads/vidcontrol-font-and-color-via-etc-rc-conf-problem.81696/. This discussion thread explores issues related to console font and color configuration.
Last updated