Quick and Dirty Japanese in FreeBSD

Setting up Japanese input under *NIX machines has always driven me
nuts whenever I've tried it - there are so many different ways to
do it and obscure environment variables to know about.  I almost
considered getting a MacOS X machine instead.  I finally sat down
took a day to get everything banged out the way I want it, and kept
some notes so you can too.

You need the following ports:


/usr/ports/japanese/Canna		# The basic Japanese input server
/usr/ports/japanese/kinput2-canna	# An interface to the canna server
/usr/ports/japanese/alias-fonts		# A meta-port providing lots of nice Japanese fonts


/usr/ports/japanese/im-ja		# Gives you japanese input support under Gnome applications
/usr/ports/japanese/Eterm (or kterm)		# A nice terminal emulator
/usr/ports/japanese/nvi-euc-jp		# A Japanese version of the one true vi clone
/usr/ports/japanese/w3m			# A text based web-browser with Japanese support
/usr/ports/japanese/xyaku		# An excellent popup translator for X.

- add canna_enable="YES" into /etc/rc.conf

- Run /usr/local/etc/rc.d/canna.sh start.

- Put "kinput2 &" and "XMODIFIERS='@im=kinput2' LANG=ja_JP.EUC LANGUAGE=en_US xyaku &" into your .xsession file.

- Edit the "Files" section of your XF86Config.  Insert the following line:

	FontPath     "/usr/X11R6/lib/X11/fonts/local/"

- Change your hotkey/menu item to start Eterm to the following:

	XMODIFIERS='@im=kinput2' LANG=ja_JP.EUC LANGUAGE=en_US Eterm

- Change your shell's environment to set EDITOR and VISUAL to 
  be /usr/local/bin/nvi.  If you use your shell environment across
  multiple machines, some of which won't have this nvi version, try:

for VI in /usr/local/bin/nvi /usr/bin/vi /usr/bin/vim
        if [ -x $VI ]; then
                export EDITOR=$VI
                export VISUAL=$VI

- Restart X, start Eterm, hit shift-space, and test your new Japanese input.

- Return to this page with w3m, and you should see the following
  as hiragana:  ä 

- Test out xyaku - highlight a simple English word, and hit "ctrl-F1".
  You should see a popup with the definition of that word.

  NOTE: There's a glitch in the xyaku port currently that results in 
	the EDICT variable in /usr/X11R6/libexec/xyaku/edict.sh
	pointing to the wrong location.  Change it to 
	/usr/local/share/dict/edict/edict.  I've submitted 
	a patch, but the maintainer of the port doesn't seem
	to understand the problem.

You should now be able to input and read Japanese from your terminals.
Programs started from these terminals will also inherit these
settings.  Programs started from a menu or other helper program
won't inherit the XMODIFIERS environment, and will behave normally.
I find this a happy medium, so I can start Mozilla and such from
the menu(and not have to deal with it making English fonts huge),
or start it from the terminal if I need Japanese input.

Thanks to Scott Robbins for guidance.

Updated Tue Mar 15 10:02:01 PST 2005

© 2003-2005 lx

Unauthorized reproduction encouraged.