Chinese Debian Mini Howto
时间:2005-11-26 来源:gaussanderson
Chinese Debian Mini Howto
Version 0.2. Last update: April 14, 2005. Copyright (c) 2005 Qiming LI (Qiming.Li AT IEEE dot ORG).Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".
0. Introduction
The purpose of this mini howto is to help users of Debian GNU/Linux to build a minimum Chinese environment, so that they can read and input Chinese in their systems. To support Chinese language display and input under Debian GNU/Linux, you will need to do the following basic steps.- Generate relevant locales
- Install Chinese fonts
- Install an input method (IM) engine
- Set locale
- Adjust application settings (if necessary)
In the rest of this text, I will explain these steps one by one. Most of the commands below need to be run in a terminal with root privilege.
Chinese Debian Mini Howto
Version 0.2. Last update: April 14, 2005. Copyright (c) 2005 Qiming LI (Qiming.Li AT IEEE dot ORG).Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".
0. Introduction
The purpose of this mini howto is to help users of Debian GNU/Linux to build a minimum Chinese environment, so that they can read and input Chinese in their systems. To support Chinese language display and input under Debian GNU/Linux, you will need to do the following basic steps.- Generate relevant locales
- Install Chinese fonts
- Install an input method (IM) engine
- Set locale
- Adjust application settings (if necessary)
In the rest of this text, I will explain these steps one by one. Most of the commands below need to be run in a terminal with root privilege.
1. Generating Locales
Run dpkg-reconfigure locales, and choose the following items. Some of these are optional. For example, if you are using simplified Chinese only, you would not need the last two items. Then it will prompt you for the default locale you want to use.2. Installing Chinese Fonts
Install at least the following free fonts. Each entry below is of the form package_name (font_name).- ttf-arphic-gbsn00lp (AR PL SungtiL GB)
- ttf-arphic-gkai00mp (AR PL KaitiM GB)
- ttf-arphic-bsmi00lp (AR PL Mingti2L Big5)
- ttf-arphic-bkai00mp (AR PL KaitiM Big5)
These packages can be installed by running
apt-get install ttf-arphic-bkai00mp ttf-arphic-bsmi00lp ttf-arphic-gbsn00lp ttf-arphic-gbsn00lp
There are other fonts available. You can find them by searching for "xfonts" using dselect
3. Installing Input Method (IM) Engine(s)
You will need an IM engine to input Chinese characters under X. There are a few IMs around, including xcin, chinput, scim, etc. Personally I found scim a good tool.There are several packages related to scim. The easiest way to install it is by running
apt-get install scim scim-chinese scim-tables-zh
You can also search for packages beginning with "scim" using dselect and choose them individually.
After that, create a new file /etc/X11/Xsession.d/95xinput with the following content.
/usr/bin/scim -d
XMODIFIERS="@im=SCIM"
export XMODIFIERS
case "$LANG" inTo use scim, simply press "Control-Space", and a small window will appear at the lower right corner of the desktop.
zh_TW*)
/usr/bin/scim -d
XMODIFIERS="@im=SCIM"
;;
zh_CN*)
/usr/bin/scim -d
XMODIFIERS="@im=SCIM"
;;
esac
export XMODIFIERS
4. Setting Locale
It is highly recommended that you use gdm or kdm as your X display manager, because then you will be able to select your language settings at the login window, which can be different from system default, and can be different for different login.ENCODING="en_US"Then I got English display of menu, time and date, etc. You should comment/uncomment these items according to your needs.
#export LC_ALL=$ENCODING
export LC_MESSAGES=$ENCODING
#export LC_COLLATE=$ENCODING
#export LC_CTYPE=$ENCODING
export LC_TIME=$ENCODING
export LC_NUMERIC=$ENCODING
#export LC_MONETARY=$ENCODING
#export LC_PAPER=$ENCODING
#export LC_NAME=$ENCODING
export LC_ADDRESS=$ENCODING
export LC_TELEPHONE=$ENCODING
export LC_MEASUREMENT=$ENCODING
export LC_IDENTIFICATION=$ENCODING
Note that "scim" works fine no matter what locale you choose.
5. Application Settings
5.1 Web Browsers
For applications such as Mozilla (1.7) and/or other browsers, usually you do not have to change much. If a Chinese webpage does not display correctly, try to check if the character encoding is correct, and make sure that you have installed the corresponding fonts.5.2 Editors
My favorite text editor is VIM with GTK support, or simply gvim. For gvim to display Chinese characters correctly, just add the following lines to $HOME/.gvimrc.set enc=euc-cn
set tenc=euc-cn
set fileencoding=euc-cn
set guifont=AR PL KaitiM GB 12
Firstly, you need to create a file with the content something like the following.
#!/bin/shLet us call this file enstart.sh, and put the file in a directory that is in your $PATH, e.g., /usr/local/bin. Make sure that it is executable by running chmod +x /usr/local/bin/chstart.sh in a terminal.
# Start application $1 with English environment
if [ -z "$1" ]; then
echo "Usage: $0 app arg1 arg2 ... "
exit 1
fi
export LANG=en_US
PROG=$1
shift
exec $PROG $*
5.3 Terminal Emulators
RXVT (www.rxvt.org) is a nice terminal-emulator that intends to replace xterm. It has a variant rxvt-ml which supports display of Chinese and Japanese characters.5.4 Display of Chinese File Names in FAT Partitions
You will need kernel support for this. To be able to mount a FAT (either 16 or 32 bit), you will need the following module.fatTo display Chinese characters properly, you will need at least one of the following modules:
vfat
nls_cp936 (for simplified Chinese)
nls_cp950 (for traditional Chinese)
nls_utf8 (for Unicode characters)
Then in the file /etc/fstab, add another line like the following
/dev/hda5 /mnt/dos vfat noauto,user,codepage=936,iocharset=cp936 0 0
5.5 XMMS
Unfortunately, unlike other programs, my XMMS does not display Chinese file/song names correctly, even when I set both the system locale and the language option of gdm to be zh_CN.gb2312, which is quite weird. My guess is that this has to do with the locale I set when I first install the system.#!/bin/sh
# Start application $1 with Chinese environment
if [ -z "$1" ]; then
echo "Usage: $0 app arg1 arg2 ... "
exit 1
fi
export LANG=zh_CN.gb2312
PROG=$1
shift
exec $PROG $*
5.6 Instant Messengers
It was actually amazing to find out that popular instant messengers such as AMSN and Yahoo Messenger do not support Chinese. It is possible to input Chinese in YM, but difficult to make it displayed properly. AMSN simply stops taking any keyboard input when the locale is set to Chinese.GAIM is another cute IM that was reported to work with Chinese.