Quick and Dirty Japanese in FreeBSD

Japanese support under UNIX traditionally sucks. There are literally
more than 5 different input methods, each of which interface with a
multitude of conversion engines, which spit out characters in a variety
of character sets - and applications only support certain combinations
of them. It's not that any one of the combinations is hard to implement
per se, but knowing which to use and which go together can be hard to
determine for a novice. The goal of this guide is to give you a working
Japanese input and display system with the least amount of thinking.

The current version of this document applies to using the IBus input
method and the Anthy or mozc conversion engines, and uses UTF-8 encoding.
This works well for modern GUI apps (anything GTK or QT-based will
work), but isn't so great for some "legacy" applications. For the
previous version of this document, which used Canna/EUC, check here.

If you'd like to learn more about Japanese input methods in general,
here is a good place to start.

You need the following ports.

Required: 

/usr/ports/japanese/ibus-anthy		# This installs the IBus input method and the anthy conversion engine
/usr/ports/japanese/ibus-mozc		# Optional - this installs Google's new mozc conversion engine
/usr/ports/japanese/font-kochi       # Just a Japanese TrueType font

Optional (but recommended): 

/usr/ports/x11-toolkits/sakura          # sakura is tiny and works fairly well - so should any vte-based terminal
/usr/ports/editors/vim                  # vim supports UTF-8, and nvi doesn't.

After the ports are installed:

- Put the following in your .xsession or .xinitrc file (before you
  execute your window manager, obviously):

export XIM=ibus
export GTK_IM_MODULE=ibus
export QT_IM_MODULE=xim
export XMODIFIERS=@im=ibus
export XIM_PROGRAM="ibus-daemon"
export XIM_ARGS="-r --daemonize --xim"

- Ensure the "Files" section of your XF86Config or Xorg.conf includes the following in the FontPath:

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

If you don't have an xorg.conf at all, this will probably just work.

- Restart X, run "ibus-setup". Go to "Input Method" and add "Japanese - Anthy" to your list of methods.
Add mozc as well if you wish.

- start a GTK or QT app, hit ctrl-space to start IBus, and test your new Japanese input.

Updated: Sat Mar 23 01:16:04 PDT 2013

© 2003-2013 lx