Chinese input under RedHat 

Enable 

To enable Chinese input capability under RedHat, as far as the mini-chinput is concerned, you have to install the RedHat with the Chinese language set as the default language. Otherwise, the ^-SPACE won't pop it up. Tested with the same set of RPM, and the only difference is the default language.

Once installed, you can change the system language setting back to English.

Change system language setting 

The GUI calls the redhat-config-language program, which uses /usr/share/redhat-config-language/redhat-config-language.py. It is only several lines long, using the /usr/share/redhat-config-language/languageBackend.py as the back end.

In the languageBackend.py, only /etc/sysconfig/i18n file is changed. Nothing more. It is changed according to /usr/share/redhat-config-language/locale-list.

Chinese Input test 

Usage 

alias gbgt='LANG=zh_CN.GB18030 XMODIFIERS=@im=Chinput gnome-terminal &'

Start from anywhere (be it gnome-terminal or xterm)

gbgt

Chinese desktop 

Start 

When system language is set to English, start Chinese gnome like this:

LANG=zh_CN.GB2312 GDM_LANG=zh_CN.GB2312 XMODIFIERS=@im=Chinput startx -- :1

as myself:

LANG=zh_CN.GB2312 GDM_LANG=zh_CN.GB2312 XMODIFIERS=@im=Chinput WMSTYLE=gnome startx -- :1

to start gnome, or use next command to start my default fluxbox

LANG=zh_CN.GB2312 GDM_LANG=zh_CN.GB2312 XMODIFIERS=@im=Chinput startx -- :1

Note, in both gnome & fluxbox, chinput is automatically started. Chenqiao Chinese works fine.

Start English Xwin 

Start English Xwin, then manually start chinput, then gbgt, will show and input AOK.

NB,

If no LANG=zh is specified, minichinput will 'segmentation fault':

$ minichinput &
[6] 2873
Chinput Version 3.0.2 -- XIM Server
Distributed under the terms of the GNU General Public License (GPL)
Following charsets:
[6]+  Segmentation fault      minichinput

At least this is true under my fluxbox.

documented on: 2003.10.27 Mon

Env var 

$ env | grep LAN
LANGUAGE=zh_CN.GB18030:zh_CN.GB2312:zh_CN
LANG=zh_CN.GB2312
GDM_LANG=zh_CN.GB2312
$ env | grep zh_
LANGUAGE=zh_CN.GB18030:zh_CN.GB2312:zh_CN
LANG=zh_CN.GB2312
GDM_LANG=zh_CN.GB2312
ps -eaf | grep -Ev '/tong/|bash|gnome-terminal|emacs|(xterm|aspell|ps|cut) ' | cut -c1-9,49- | sort

Chinput invocation 

There is no magic behind invocation chinput.

chinput &

then

LANG=zh_CN.GB18030 XMODIFIERS=@im=Chinput gnome-terminal &

That's it. It can also be killed and started again, like above.

RH9 invocation 

Symptom 

$ gbinputm
[1] 2844
Chinput Version 3.0.2 -- XIM Server
Distributed under the terms of the GNU General Public License (GPL)
Basic: Cannot open font -misc-zysong18030-medium-r-normal--0-0-0-0-c-0-gb2312.1980-0
[1]+  Exit 255                LANG=zh_CN minichinput
$ aliasf gbinputm
alias gbinputm='LANG=zh_CN minichinput &'

Solution / Conclusion 

Specify GB18030!

$ LANG=zh_CN.GB18030 minichinput &
Chinput Version 3.0.2 -- XIM Server
Distributed under the terms of the GNU General Public License (GPL)
Following charsets:
0: -Sony-Fixed-Medium-R-Normal--16-120-100-100-C-80-ISO8859-1
1: -Sony-Fixed-Medium-R-Normal--16-120-100-100-C-80-ISO8859-1
2: -misc-zysong18030-medium-r-normal--0-0-0-0-c-0-iso10646-1
Chinput ................................................[OK]
[6]+  Done                    LANG=zh_CN.GB18030 minichinput

RH8 Test, history 

system language set to Chinese

Retry and confirm the above results at least twise.

Conclusion.

RH8 chinput history 

root & crewbase are able to input Chinese.

From my account, chinput report some font problems, because of my .chinput.

Right chinput prompt 

Chinput Version 3.0.2 -- XIM Server
Distributed under the terms of the GNU General Public License (GPL)
Following charsets:
0: -Sony-Fixed-Medium-R-Normal--16-120-100-100-C-80-ISO8859-1
1: -Sony-Fixed-Medium-R-Normal--16-120-100-100-C-80-ISO8859-1
2: -misc-zysong18030-medium-r-normal--0-0-0-0-c-0-iso10646-1
Chinput ................................................[OK]

My wrong chinput prompt 

cat: /home/tong/.Xauthority: Permission denied
Chinput Version 3.0.2 -- XIM Server
Distributed under the terms of the GNU General Public License (GPL)
Basic: Cannot open font ccs16_1
SESSION_MANAGER=local/xpt:/tmp/.ICE-unix/13514

Ahh! because of my left over .chinput file!

Remove it and everything works fine!!!

RH73 Test 

Settings 

set

GDM_LANG=C

in ~/.profile

and restart Gnome w/ Language = Chinese.

Change run level from 5 to 3 

Have to

export GDM_LANG=C

For the following to work. Otherwise, Gnome started in Chinese.

gnome-terminal 

 $ LANG=zh_CN.GB18030 XMODIFIERS=@im=Chinput gnome-terminal &
 font "-misc-fixed-medium-r-normal--14-*-*-*-*-*-*-1" does not support all the required character sets for the current locale "zh_CN.GB18030"
  (Missing character set "GB2312.1980-0")
The font "-misc-fixed-bold-r-normal--14-*-*-*-*-*-*-1" does not support all the required character sets for the current locale "zh_CN.GB18030"
  (Missing character set "GB2312.1980-0")

— LANG presetting doesn't work. Have to set again in newly launched gnome-terminal in order for date to show Chinese.

LANG=zh_CN.GB18030; GDM_LANG=zh_CN.GB18030
date

— Yes! Chinese

^-Space

YES! chinput input bar!!!

Chinese input question 

Newsgroups:  comp.os.linux.misc
Date:        31 Jan 2004 12:49:35 -0800

Sun Tong, thank you for your reply…

Do some native speakers prefer to use some other methods perhaps or is Hanyu Pinyin the most common input method among most native speakers as well? AFAIK GB (Guojia Biaozhun) and Big5 are character sets both of which have been superseded by Unicode. But you are talking about input methods? How do the GB and Big5 input methods work, if different from Hanyu Pinyin? I would have expected that Big5 has at least one other input method, since the Cantonese pronounciation is very different from the Mandarin pronounciation, but most Chinese people speak Mandarin so perhaps Cantonese speakers will still not mind if they have to use Hanyu Pinyin. Are there other forms of Pinyin or other input methods preferred by Cantonese, Taiwanese, or Mandarin speakers?

> I've been always using miniChinput, maybe since RH7.2. Very simple, switch
> system language into GB Chinese, fire up emacs, or gnome-terminal, or
> gedit, or mozilla, then Ctr-Space and off you go!

I tried this. It seems to work very nicely. I simply logged in with the default language settings into Fedora Core 1 Linux and issued the following commands:

$ export LANG=zh_CN.UTF-8
$ export XMODIFIERS=@im=Chinput
$ /usr/bin/chinput
Chinput Version 3.0.2 -- XIM Server
Distributed under the terms of the GNU General Public License (GPL)
Following charsets:
0: -Sony-Fixed-Medium-R-Normal--16-120-100-100-C-80-ISO8859-1
1: -Sony-Fixed-Medium-R-Normal--16-120-100-100-C-80-ISO8859-1
2: -isas-fangsong ti-medium-r-normal--0-0-0-0-c-0-gb2312.1980-0
3: -jis-fixed-medium-r-normal--0-0-0-0-c-0-jisx0208.1983-0
4: -baekmuk-batangbdf-bold-r-normal--0-0-0-0-m-0-ksc5601.1987-0
5: -taipei-fixed-medium-r-normal--0-0-0-0-c-0-big5-0
6: -arabic-newspaper-medium-r-normal--0-0-0-0-p-0-iso10646-1
/home/nzanella/.pyinput/usrphrase.tab is not a valid pinyin phrase file.
Chinput ................................................[OK]

and then, just as you mentioned, I can start up an application from the same window so that the child application will inherit the parent application's state including environment variables.

I am not sure what the complaint about the invalid pinyin phrase file is all about, but I just deleted that file and the complaint went away. Any ideas?

> You should be able to see an Chinese input box, type in "nihao"!

Cool! I type CTRL-SPACE to turn Chinese input on in the child process, then type ni, and press 1 to select the character corresponding to the word you, then type hao and press 1 to select the character corresponding to the word good, and then I can press CTRL-SPACE again to switch back to English.

I notice that miniChinput does not come with a man page. Basically I was just wondering whether there is some way to stop the server sometime after it is started.

I also find that the server is activated globally, not only for the children of the window from which it is launched. This is true so long as the LANG and XMODIFIERS environment variables are set correctly. So for instance after doing what I describe I can also open up a new gnome-terminal from a popup menu and manually set:

$ export LANG=zh_CN.UTF-8
$ export XMODIFIERS=@im=Chinput

and then launch gvim. After pressing the i key in gvim to enter insert mode I can then do the same trick: I press CTRL-SPACE to toggle chinese input and off I go. For some reason I was not able to get this to work from console mode vim so I am not sure if this is also possible or not. Has anyone been able to get this to work as well?

Thanks a lot!!!

Neil

gnome-terminal fonts 

Symptom 

gnome-terminal fonts will be extremely small in fluxbox.

Solution 

gnome-settings-daemon --oaf-activate-iid=OAFIID:GNOME_SettingsDaemon --oaf-ior-fd=13

Analysis 

However, I found that the moment I launch gnome-font-properties, it changes to normal. What puzzles me is that how it works, because the gnome-font-properties is started somewhere else, either from menu, or commmand line.

env | sort > env.0
gnome-font-properties
env | sort > env.1
comm -3 env.0 env.1

— no difference

NB, gnome-font-properties also changes the window background as a side effect. Ahh…

ps -eaf | cut -c1-29,48- | sort > ps.0
gnome-font-properties
ps -eaf | cut -c1-29,48- | sort > ps.1
$ comm -3 ps.0 ps.1
        root     10245 10037 12 12:36 gnome-terminal
root     10245 10037 13 12:36 gnome-terminal
root     10355 10320  0 12:37 ps -eaf
root     10356 10320  0 12:37 sort
        root     10359     1  4 12:37 gnome-settings-daemon --oaf-acti
        root     10361   567  0 12:37 fam
        root     10371 10320  0 12:37 ps -eaf
        root      9998  9997 35 12:36 /usr/X11R6/bin/X :1
root      9998  9997 36 12:36 /usr/X11R6/bin/X :1

Aha, the gnome-settings-daemon!

cm:rxvt 

cmd:rxvt in RH9 

Usage 

LANG=zh_TW rxvt &
alias gbrxvt='LANG=zh_CN.GB2312 rxvt -sl 1500 -bg black -fg gray78 -fn 8x16 -fm '\''"-isas-fangsong ti-*-16-*-gb2312.1980-0"'\'' -km gb >/dev/null &'

Installation 

rpmih /export/linux/mustH_rh9/RPMS/rxvt-2.7.10-4mdk.i586.rpm

Working History 

WARNING 
$ LANG=zh_TW rxvt &
WARNING!!
rxvt is unable to display in BIG5 encoding
you should use xterm instead

— Ignore it, rxvt shows BIG5 well

zh_CN need twisting 
LANG=zh_CN.GB2312 rxvt and previous gbrxvt (using M$ fonts) not OK.
gb-input 
LANG=zh_CN.GB18030 XMODIFIERS=@im=Chinput rxvt -sl 1500 -bg black -fg gray78 -fn 8x16 -fm '"-isas-fangsong ti-*-16-*-gb2312.1980-0"' -km gb >/dev/null &

— Ok to show CC. But input Nok, while gbgt works fine.

cmd:rxvt in RH8 

Conclusion 

Under RH8, when TrueType fonts are rendered through freetype, rxvt can only use bitmap fonts. Both native Chinese TrueType font and mine will not work. Thirdly, rxvt is only good for showing Chinese, not input them, because it will 'segmentation fault' on trying to do both showing & inputing.

Test result 

$ aliasf gbrx
alias gbrxvt='do_bg LANG=zh_CN rxvt -sl 1500 -bg black -fg gray70 -fn fixed -fb 6x13bold -km gb -fm -microsoft-simsun-medium-r-normal--0-0-0-0-c-0-gb2312.1980-0'
alias gbrxvt0='do_bg LANG=zh_CN rxvt -sl 1500 -bg black -fg gray70 -fn 8x16 -fm '\''"-isas-fangsong ti-*-16-*-gb2312.1980-0"'\'' -km gb'
gbrxvt0

— ok to show CC

gbrxvt

— nok, no CC shonw, even menu is in Chinese, font size smaller than previous cd mlterm-2.8.0

$ patch -p0 < ../mlterm-2.8.0pl1/mlterm-2.8.0pl1.patch
patching file xwindow/x_font_cache.c
patching file xwindow/version.h.in
./configure --with-x --with-imagelib=imlib --with-gnu-ld --disable-rpath --disable-scrollbars
LANG=zh_CN rxvt -sl 1500 -bg black -fg gray70 -fn fixed -fb 6x13bold -km gb -fm -misc-zysong18030-medium-r-normal--0-0-0-0-c-0-gb2312.1980-0

— still nok, no CC shonw. Menu in Chinese, font size same as previous

$ LANG=zh_CN XMODIFIERS=@im=Chinput rxvt -sl 1500 -bg black -fg gray70 -fn 8x16 -fm '"-isas-fangsong ti-*-16-*-gb2312.1980-0"' -km gb
Segmentation fault
rxvt: could not obtain control of tty
XIO:  fatal IO error 9 (Bad file descriptor) on X server ":0.0"
      after 218 requests (215 known processed) with 10 events remaining.

cmd:rxvt in RH7.3 

Strange, I had been able to run rxvt in rh7, even with both LANG & XMODIFIERS envars set. Just that it couldn't input Chinese. And now, strangly, I can't start it any more.

rxvt from Chinese gnome-terminal 

Go on start rxvt:

$ LANG=zh_CN.GB18030 XMODIFIERS=@im=Chinput rxvt &
rxvt: could not obtain control of tty
XIO:  fatal IO error 9 (Bad file descriptor) on X server ":0.0"
      after 207 requests (204 known processed) with 29 events remaining.
[1]+  Segmentation fault      LANG=zh_CN.GB18030 XMODIFIERS=@im=Chinput rxvt
rxvt &

— same error as above

start from xterm, same error as above.

rxvt from English gnome-terminal 

Starting 'LANG=zh_CN.GB18030 XMODIFIERS=@im=Chinput rxvt' from English gnome-terminal result the same as above. So does 'LANG=zh_CN.GB18030 rxvt & '

However, it is possible to start:

XMODIFIERS=@im=Chinput rxvt
LANG=zh_CN.GB18030; GDM_LANG=zh_CN.GB18030
date

— Chinese in 'luanma'.

This is the same result as Starting 'XMODIFIERS=@im=Chinput gnome-terminal' from English gnome-terminal (w/o LANG=zh_CN.GB18030)

suse-cjk 

http://www.suse.de/~mfabian/suse-cjk/node1.html

Automatic starting of an XIM server with the X11 session 

The default scripts used on SuSE Linux to start an X11 session will automatically attempt to start a suitable XIM server for the language7 used to start the X11 session.

The starting of the XIM server is done by the script ~/.xim, which is sourced by ~/.xinitrc or ~/.xsession. You can find the default SuSE versions of these scripts in /etc/skel. During the creation of a new user with YaST2, the files from /etc/skel will automatically be copied to the users home directory Thus, a newly created user will automatically have these files. Note that the user root is an exception, root will not have these files by default. Actually, root will not get any dot-files by default. If you are missing these files, copy the default versions from /etc/skel to your home directory.

Basically, the script ~/.xim checks the LC_CTYPE locale and tries to start the ``best''available XIM server for this locale.

A suitable XIM server will be started automatically, if any such server is installed (and, if necessary, a suitable conversion backend is installed and running).

For example, if kinput2 and Canna are installed and the cannaserver is running and there is no “better” Japanese input system for XIM installed, kinput2 will automatically start when you start an X11 session with

~$ LANG=ja_JP startx

If you don't start your X11 session with startx but rather use one of the display managers xdm, kdm, or wdm, you cannot choose the language anymore before starting your X11 session. The display managers run as user root and the X11 session started by them inherits the locale from the user root. Therefore, if you are using one of these display managers and want an XIM server to start automatically, you have to set the default language for the user root to the appropriate language. This is done by setting the variables RC_LANG and ROOT_USES_LANG in /etc/rc.config, for example

RC_LANG="ja_JP"
ROOT_USES_LANG="yes"

Then run SuSEconfig and restart your display manager.

If you are using the display manager gdm, you don't need to change the default language for the user root, because gdm has a menu to select the language before starting an X11 session. Unfortunately the other display managers don't have this feature.

Footnotes

.. language7
the language is indicated by the LC_CTYPE locale.

Customizing XIM server startup 

If you want to know in detail how the XIM server startup is done, please have a look a the file ~/.xim in your home directory.

You may want to do this to adapt the starting of an XIM server to you personal preferences. For example

As an Example, let's assume you usually start your X11 session in English, because you mostly use English and prefer that your window manager or desktop environment shows English menus, but nevertheless you always want to have the Japanese input server kinput2 running and always want to set the XMODIFIERS environment variable suitable for kinput2 because you often write Japanese texts. In that case, I recommend to edit your ~/.xim a bit like in the following example

case $tmplang in
    ja*)  # Japanese
         ... stuff for X11-sessions started in Japanese ...
ko*)  # Korean
     ... stuff for X11-sessions started in Korean ...
zh_*) # Chinese
     ... stuff for X11-sessions started in Chinese ...
    *)    # all other languages
         export XMODIFIERS="@im=kinput2"
         LANG=ja_JP LC_ALL=ja_JP kinput2 -xim -kinput -canna &
    ;;
esac

Add this last section “*)” for all languages not handled above, put the necessary commands to start kinput2 there and set the environment variable XMODIFIERS.

And remember to start all programs in your X11-session where you want to do Japanese input in a Japanese locale. If you have started your X11 session for example in English, programs started from a start menu of your window manager will usually start in an English locale. In that case, you have to explicitly specify a Japanese locale for the programs you want to run in Japanese mode by starting them like this:

~$ LANG=ja_JP program

In the following sections, the available XIM servers are explained in greater detail.