[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Fwd: Re: Add Chinese Locale in Debian?

On Mon, Jun 14, 1999 at 11:12:14AM +0800, hashao wrote:
> I guess this email was intended to this list. So I take the liberty to
> just forward it. :)

Sorry that in my previous reply I only press 'r' in mutt, so it only
goes to your mail box but does not go to the mailing list. Thank you
very much to forward it to the mailing list. :-))

> For English translation of your i18ntool page, Tung Han, I think it
> will be quite useful. Not only that we shall not assume everyone want
> to install a valid Chinese locale can read Chinese at the moment, but
> also the i18ntool is general enough to be used on system other than
> Linux. Although most commercial  UNIX come with better locale support,
> but I don't know if they always ship far east locale with their
> package. Just a thought that someone other than a Chinese might want
> to have a Chinese locale installed on a server. So please... ;)

I have done the translation:

http://xcin.linux.org.tw/files/i18n_tool.Big5.html	(In Big5 Chinese)
http://xcin.linux.org.tw/files/i18n_tool.En.html	(In English)

Since we should make it general and readable to all the people (especially
to the foreign :-)), so I modify the contents a little and add some
explainations. The English version is also attached in the end of this mail.

Since my English is not well, so if you find any mistake or un-readable
contents in the doc, please feel free to tell me, or just modify it directly.

Best Regards,


This package includes a zh_TW.Big5 and a zh_CN.GB2312 locale data, and
a fixed lcGen module. These can help to you establish the needed locale
environment in Linux and FreeBSD.

In the following I take Linux system as the example to explain briefly
how to establish the locale environment in your system. Besides the
libwcsmbs and the wcsmbs-locale espects which are only related to Linux,
the method to establish the locale environment in FreeBSD is the same.

A. zh_TW.Big5:

Assuming that your system is Linux with glibc-2.0.7, XFree86 3.3.2.X
or later releases, you can follow the steps below to establish the 
zh_TW.Big5 locale environment. Please note: Before you starting, you
should make sure that if all the packages or files mentioned in the steps
are already in your system or not. If yes, you can just bypass the 
corresponding step, or you have to finish them one after one.

If you are using glibc-2.1.X or later releases, then you can skip the
1st and 2nd steps and start from the 3rd step. If you are using CLE
(Chinese Linux Extension) distribution, then CLE should have prepared
all of these, so you don't have to do anything at all.

1. Install libwcsmbs. This lib is used to fix glibc-2.0.7 such that it 
   can support to zh_TW.Big5 and other Asian locales. You can find it in


   The steps to install it are

	tar -xvzf libwcsmbs-0.0.4.tar.gz
	cd libwcsmbs-0.0.4
	make DESTDIR=/usr/local install

2. Install wcsmbs-locale package. Please note that you have to install the
   version which is modified by Platin, the coordinator of CLE, since in
   that modification the zh_TW.Big5 locale data has been added. You can
   find it in


   The steps to install it are

	tar -xvzf wcsmbs-locale-0.4.7.tar.gz
	cd wcsmbs-locale-0.4.7
	make map
	make install

3. If in your system there already has a zh_TW.Big5/ or zh_TW.BIG5/
   directory in /usr/share/locale/, and there also has a LC_CTYPE file
   in that directory, then you can skip this step. If not, please go 
   to the directory i18n_tool/localedata/zh_TW.Big5/ and run the command:

        localedef -i zh_TW.Big5 -f BIG5 zh_TW.Big5

   Please note: If you are using glibc-2.1.X and the above command gives
   error messages, please use this command instead:

        localedef -i zh_TW.Big5 -f BIG5 -u charids.894 zh_TW.Big5

   After that, there will be a zh_TW.big5 directory in the /usr/share/locale/.
   But in the convention of CLE, the locale name is zh_TW.Big5; while in
   other conventiion (such as FreeBSD) the name is zh_TW.BIG5, so you can
   choose one of the convention to follow. Here we will follow the convention
   of CLE. So we should change the directory name "zh_TW.big5" into 

4. Please check the /usr/X11R6/lib/X11/locale/ directory to see if there
   exists the zh_TW.Big5/ directory (here you should use the convention
   you just choosed, see step 3 for details), and in that directory there
   is a file named XLC_LOCALE. If not, please put the file
   xcin-2.5/localedata/zh_TW.Big5/XLC_LOCALE into the directory


   (you might need to create this directory). Then please modify the file


   to add the line in the end of the file:

zh_TW.Big5/XLC_LOCALE   zh_TW.Big5

   Besides, please check the contents of 


   to see the following two lines

use_stdc_env            True
force_convert_to_mb     True

   Please make sure that their values are both "True".

5. You have to prepare suitable Chinese (Big5) fonts. From the definition
   of XLC_LOCALE in step 4, the font to display Chinese in zh_TW.Big5 locale
   is named BIG5-0. Therefore your system should have these fonts (or, you
   can modify the contents of XLC_LOCALE such that the corresponding font
   name matches those in your system). Take my system as an example, since
   I have installed the twmoe fonts (you can get them from:
	ftp://linux.cis.nctu.edu.tw/packages/chinese ftp site), which has
   the font name ended with "big5-1", so I have to alias these font names
   to ended with "big5-0":

THH:thhpc $ xlsfonts | grep big5

THH:thhpc $ more /usr/X11R6/lib/X11/fonts/chinese/fonts.alias 
-twmoe-kai-medium-r-normal-fs-16-160-75-75-c-160-big5-0 -twmoe-kai-medium-r-normal--16-160-75-75-c-160-big5-1
-twmoe-kai-medium-r-normal-fs-24-240-75-75-c-240-big5-0 -twmoe-kai-medium-r-normal--24-240-75-75-c-240-big5-1

6. In most releases of XFree86, there is a problem in Xlib such that it 
   cannot handle Big5 encoding correctly. In some systems (such as CLE)
   this problem has been fixed, but others do not. You can do the following

   a. Please install xcin-2.5 and rxvt-2.6.X packages, which can be
      found at


      (please see the documents in xcin-2.5 for detailed installation 
       instructions), and try to see if you can input Chinese characters
      from xcin into rxvt or not? If yes, then your Xlib is OK and you 
      don't need to fix it. If you even cannot start up xcin, or if you type
      ctrl+alt+0 in rxvt but cannot switch xcin into Chinese input mode, 
      it means that you have made mistakes when establishing the locale
      environment, or you does not setup xcin correctly. Please check again.

   b. A simpler method: Please add the following lines into your

xtDefaultFontSet: -*-big5-0,-adobe-*-iso8859-1
xedit*international: True
xedit*fontSet: -*-big5-0,-adobe-*-iso8859-1

      and run the commands

	xrdb merge $HOME/.Xdefaults
	export LC_CTYPE=zh_TW.Big5
	xedit &

      Now you can try to use mouse to cut & copy the following Big5 Chinese
      texts into xedit:

	您好,這是一段 Big5 編碼的文字。

      If you can see Chinese characters in xedit, then your Xlib is OK,
      otherwise you should fix your Xlib.

   There are two methods to fix this problem:

   a. patch Xlib, rebuild Xlib:

      This might be a terrible work, but it is also the most completed
      way. Please download XFree86 source code first (it would be better
      to get the version of 3.3.2 or above), then apply the 
      i18n_tool/lcGen/lcGenConv.c.patch patch into lib/X11/lcGenConv.c
      of XFree86's source tree:

	cd <path_of_XFree86>/lib/X11
	patch -p0 < <path_of_i18n_tool>/lcGen/lcGenConv.c.patch

      Finally you can follow the documents of XFree86 to rebuild libX11.
      Please note that the patch described above comes from the modification
      of XFree86-, but it should be applicable to XFree86-3.3.2 and
      its later releases. If there are error messages when you applying
      this patch, you probably have to modify the code by yourself. It 
      should not be difficult :-))

   b. You can also go to i18n_tool/lcGen directory and run make. After that
      you will get a lcGen.so shared library. Every time when you want to 
      run Xi18n related programs (such as rxvt), please use this command
      (take rxvt as the example):

	LD_PRELOAD=<path_of>/lcGen.so <path_of>/rxvt <other_options>

      That is, we use lcGen.so to replace the problem function of Xlib.

B. zh_CN.GB2312:

The method to establish this locale is very similar to that of zh_TW.Big5. 
The steps are also the same. Hence I only mention the difference of them
in detail:

1. If you are using glibc-2.0.7, please install the libwcsmbs-0.0.4.tar.gz

2. If you are using glibc-2.0.7, please install the wcsmbs-locale-0.4.7.tar.gz

3. If there is already a directory zh_CN.GB2312 in /usr/share/locale/ of
   your system and in that directory there is a LC_CTYPE file, then you
   can skip this step. Otherwise, please go to the directory
   i18n_tool/localedata/zh_CN.GB2312/ and run

        localedef -i zh_CN.GB2312 -f GB2312 zh_CN.GB2312

   Please note, if you are using glibc-2.1.X and the above command gives
   error messages, please use this command instead:

        localedef -i zh_CN.GB2312 -f GB2312 -u charids.894 zh_CN.GB2312

   After that, there will be a directory zh_CN.gb2312 appeared in
   /usr/share/locale/ diretory. Please change its name to be zh_CN.GB2312.

   If you are using glibc-2.1.X, please check the contents of
   /usr/lib/gconv/gconv-modules to search for the word "EUC-CN". Probably
   in line 880, you will see the following contents:

#       from                    to                      module          cost
alias   EUCCN//                 EUC-CN//
alias   GB2312//                EUC-CN//
module  EUC-CN//                INTERNAL                EUC-CN          1
module  INTERNAL                EUC-CN//                EUC-CN          1

   Please note the line 3 above: "alias GB2312//    EUC-CN//". If in your
   file there does not have this line, please add it by yourself.

4. XFree86 already has the XLC_LOCALE file for GB encoding, so you don't
   need to install it. However, it is placed in


   Therefore you have to modify the file locale.dir to add this line:

	zh/XLC_LOCALE   zh_CN.GB2312

5. You should install the GB fonts, with the font names ended with
   "GB2312.1980-0". You can try to find the GB font tar file in XFree86
   packages, or search for them in the ftp sites.

6. There is no problem in Xlib to handle the GB encoding like the problem
   in Big5 encoding, so you don't need to do any fixes in Xlib.

Author: Tung-Han Hsieh
Email:  thhsieh@linux.org.tw

Reply to: