
It took me three days to get this working for myself. That's utterly ridiculous. Considering that it's an isolated sort of issue to even come up, I figure that I should memorialize it. So here we go - Jen's guide to getting Japanese input working in Mozilla on RedHat 7.2. I use a bash script for part of this; the commands I put in there can just as easily be put in .xinitrc if you like.
Step One Install a kanji/kana conversion server and an input method
I use cannaserver and kinput, but I'm not wedded to them - canna just happened to be alphabetically first in the first list I looked at. The rpms I used may already be installed on some linux distributions, but if not, they can be downloaded from rpmfind.net, or anywhere else fine rpms are sold :
kinput2-canna-wnn6-v3-14.i386.rpm
locale-ja-9-1.noarch.rpm (need Japanese locales, don't you know)
kterm-6.2.0-22.i386.rpm (I don't think I really needed this, but hey, whatever)
For various silly reasons, this didn't actually work for me until I rebooted poor Chiyo. Rebooting is not something we like to do, generally, so people more Unix-competent can figure out how else to get cannaserver running as a service.
Step Two The .xinitrc file
I added the following lines to .xinitrc. These could get put in the script later used, or vice versa.
Note! Make sure that if you're using .xinitrc to exec a window manager (like I am), that these commands are placed before the window manager command. Window managers will take over and ignore these gems.
/usr/bin/X11/kinput2 -canna &
xmodmap -e 'keycode 67 = Kanji'
Now, smartsy people might ask why these commands are necessary. Well, here's the breakdown:
/usr/bin/X11/kinput2 -canna & | Starts up kinput when you start x, using canna as its conversion server |
xmodmap -e 'keycode 67 = Kanji' | This one is negotiable. Apparently kinput was originally supposed to be activated via a Kanji key, which, funny enough, doesn't come on most keyboards. Kinput, on my system at least, will get switched by the default SHIFT-SPACE, but reportedly, on some systems that key combo doesn't work. This command just makes sure that if SHIFT-SPACE doesn't work, CTRL-F1 will. |
Step Three The .Xdefaults file
This one's easy. Add the following to your .Xdefaults file : "*inputMethod kinput2" (sans quotes, of course). Amazingly enough, this tells X to use kinput as an input method. Imagine that.
Step Four Making it work when you want
Now, some people don't like scripting, or whatever - if you're one of those, these commands can just be put in your .xinitrc file for indiscriminate Japanese use. I, on the other hand, prefer to only have kinput pop up when I want it to. To do this, I make use of the fact that kinput will not work unless certain language variables are set to Japanese. Following the lead of the excellent Scott Robbins (page listed at the bottom of this page), I use the following script, located in a place within my path, and named "japan" (you can name it whatever you want).
#!/bin/bash
XMODIFIERS="@im=kinput2" LANGUAGE=en_us LC_CTYPE=ja_JP $1 &
When this is called, it sets the XMODIFIERS variable that Mozilla won't love you without, and sets the locale (by way of LC_CTYPE) to Japanese, then waits for another input (the variable $1). Sooo, if you call something like this : "japan mozilla," then Mozilla will start up with the options set such that it will use kinput2 (yay). I personally use WindowMaker, and Mozilla is in a dock tab - I just changed its invocation to include this script, and it works like a dream.
If you don't want to use a script, however, you can set these variables in any way you like - before I scripted it, I had the XMODIFIERS and LC_CTYPE values being set in .xinitrc.
Step Five Making sure it, you know, works
Theoretically, if you've installed all that junk and done all that junk, you should be able to start X, fire up Mozilla, go to something like, say, Google, and toggle kinput by hitting either SHIFT-SPACE or CTRL-F1 while your cursor is in the textfield. You will know it worked if a little box pops up at the bottom of the screen with a hiragana in it. At that point, it works pretty much like Kotoeri on the Mac, or the Microsoft IME. Type in what you want phonetically, hit space to cycle through suggestions... yadda yadda yadda. Email me if it doesn't work for you. We go beat some sense into things.
In my attempts to get this working, I culled information from varied sources, and have since found more on getting Japanese properly supported in a multitude of Linux systems - I've leaned towards RedHat, because that's what I used, but many of the links below have links to Mandrake, SUSE and Debian resources.