top
Home
About me
Mathematics
Linux
Debian
SPS
LaTeX
Vim
Links
Email
bottom
Google

The Universal Operating System


Chinese Input in Debian

Many thanks to Eugene Teo. I first managed to enable Chinese input by following the instructions on his website. He listed the most essential steps for inputting Chinese using chinput in Debian, without much detailed explanations, though.

It took me some time to figure out exactly what each step does, with great help from Debian HK. If (and only if) you are still interested, read on:

1. Install Chinese fonts

First of all, install essential xfonts packages
  $ apt-get install xfonts-intl-chinese xfonts-base unifont

Then, these four nice Chinese TrueType fonts donated by Arphic Tech.
  $ apt-get install ttf-arphic-bkai00mp ttf-arphic-bsmi00lp
  $ apt-get install ttf-arphic-gbsn00lp ttf-arphic-gkai00mp

Or you can use KDE font installer (optional)
  Control Center -> System Administration -> Font Installer
then click on the "Add fonts" button and open a .ttf file.

2. Install input method editor and X terminal emulators

  $ apt-get install chinput rxvt-ml

You need special X terminal emulators, such as crxvt-big5 and crxvt-gb, to view and edit Chinese characters. These two X terminal emulators are included in the package rxvt-ml. But the commands to open them are crxvt-big5 and crxvt-gb respectively, not "rxvt-ml".

3. Setup the right locale and XIM (X Input Method)

  $ apt-get install locales localeconf
  $ dpkg-reconfigure locales

Then, select the locale zh_CN.GB2312 (not necessarily to set it as default).

Now it is time to set your environment variables. The simplest way is to copy the following lines in your ~/.bashrc
  export LANG=zh_CN.GB2312
  export LC_ALL=zh_CN.GB2312
  export XIM_PROGRAM=Chinput
  export XIM=Chinput
  export XMODIFIERS="@im=Chinput"

You should be able to use chinput by now. However, other system information such as error messages will also be displayed in Chinese (or some strange square characters). If that is not what you wish to see, fine-tuning of the environment variables is required.

The following are copied from my ~/.bashrc
  export LANGUAGE=POSIX
  export LANG=zh_CN.GB2312

  export LC_CTYPE=zh_CN.GB2312
  export LC_COLLATE=POSIX
  export LC_TIME=POSIX
  export LC_NUMERIC=POSIX
  export LC_MONETARY=POSIX
  export LC_MESSAGES=POSIX
  export LC_PAPER=POSIX
  export LC_NAME=POSIX
  export LC_ADDRESS=POSIX
  export LC_TELEPHONE=POSIX
  export LC_MEASUREMENT=POSIX
  export LC_IDENTIFICATION=POSIX

  export XIM_PROGRAM=Chinput
  export XIM=Chinput
  export XMODIFIERS="@im=Chinput"

I have given a brief description to each variable here . For more detailed explanation on the environment variables, please refer to "Debian Reference" Section 9.7.5 Activating a particular locale.

Now test your locale setting using command locale, you should see the following
  hostname:/home/username~$ locale
  LANG=zh_CN.GB2312
  LC_CTYPE=zh_CN.GB2312
  LC_NUMERIC=...

4. Tips on typing Chinese using chinput

Try
  chinput & mozilla &
  chinput & gaim &
  chinput & crxvt -bg black -fg white &

  • Ctrl+space to switch between between English and Chinese input locales
  • Ctrl+. to toggle between the two punctuation modes (,)
  • Learning more by reading your /etc/xsimrc file.

5. Troubleshooting

When chinput is start up for the first time, this error message appeared:
Couldn't load /home/username/.pyinput/usrphrase.tab. Please fix it. size or load error

I solved this problem by simply removing the entire ~/.pyinput directory. It is no longer needed for later version of chinput.

6. Advanced Setup

  1. Another Chinese Debian Mini Howto by a PhD candidate from NUS.
  2. Want start chinput automatically when X-server is loaded? Want to switch between chinput and xcin conveniently? Read more from Debian HK.
  3. Enabling Chinese input seems to be somewhat easier in ubuntu. Have a look at the Ubuntu CJK Chinese Japanese Korean Input Guide.

back to Debian

Template provided by WEBalley