How to configure an English Japanese capable Debian.

This howto is a step by step guide to configure a working Debian english system, with the capability of displaying AND writing japanese. I gathered information from various sources (see at the end of the document) that already wrote on the issue and tried succesfully to get such a system working but, as far as I know, none of them is complete. Therefore, this document is aimed at giving all the clues to properly set up  a japanese capable english operating system.

Notes: Since english isn't my native language, please apologize for my bad english. Any help on that matter is most welcome. Besides, if you want to add some information, such as "French japanese capable OS" or "Russian japanese capable OS", just go ahead and send me an email: I'll be pleased to add such information. Adding specific information about other distributions is appreciated, too.

Note: I installed the Sarge pre release version, and you'll need some tweaking to have a working japanese capable OS, if you use this Woody configuration. The changes are in red.

1.Packages installation

You need a bunch of package to be able to use japanese (from Debian Reference):
• install Kana-to-Kanji conversion system and dictionary (for Japanese):
• canna – Local server ("free-beer" license), or
• freewnn-jserver – Network-extensible server (Public Domain)
• install Japanese input method system (for Japanese):
• kinput2-canna – for X, or
• kinput2-canna-wnn – for X, and
• egg – directly works with Emacsen even in console (optional)
• Install compatible terminals (for all):
• xterm – X (for ISO-8859-1 and UTF-8),
• kterm – X (for Japanese EUC), and
• mlterm – X (multilingual).
• rxvt-ml - X (multilingual).
• Install japanese font:
• ttf-kochi-gothic – X (for ISO-8859-1 and UTF-8),
• ttf-kochi-mincho  – X (for Japanese EUC), and
• watanabe-vfont – X (multilingual).
• gs-cjk-resource - X (multilingual).
• ttf-xtt-watanabe-mincho - X (multilingual).
• x-ttcidfont-conf
The list seems to be the minimum requirement. You may need additional fonts, and the best way to find out is to use apt-cache (such like "apt-cache search mincho" or "apt-cache search kochi")

• LaTeX and CJK installation (if needed)
• cjk-latex
• hbf-kanji48
• Configuration
• language-env
I might have forgotten some packages, feel free to mail me if you notice something is missing

Since I'm familiar with canna and kinput2, I suggest you use it, too.

2. Locales installation

en_US.ISO-8859-1
ja_JP.eucJP
You may need en_US.UTF8 or ja_JP.UTF8, also.

To do this, just type dpkg-reconfigure locales and follow the instructions. The tool will generate all the locale you checked in.

3. User local configuration

You'll need to use the set-language-env script. Select the "7 : ja  (Nihongo,Japanese)" and answer all questions default (it is written in japanese and I'm not able to translate it)
The set-language-env script will modify your .bashrc, .bash_profile and .Xressources files. The system is quite clever:
• If your terminal is japanese capable, you will have a japanese locale
• If not, it falls back to C locale.
This system is very useful to Japanese speaking users,but it is not suitable for English speaking users who need a system which responds in english, not in japanese. Besides, if the terminal you use to launch X with startx isn't japanese capable, your X Window session won't be as well.

So you need to change a few things.
#force EN menu and error displayingLANGUAGE=CLC_COLLATE=CLC_NUMERIC=CLC_MONETARY=CLC_TIME=Cexport LANGUAGEexport LC_COLLATEexport LC_NUMERICexport LC_MONETARYexport LC_TIME
You'll still have Japanese locales ON, but all the common display will be in english.

4. Startx and X tuning.

#        Load    "freetype"        Load    "xtt"
Comment freetype and add xtt driver. Warning: X will fail if freetype and xtt are loaded together

Then, search for "FontPath" and add:
	FontPath        "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"

# Start Japanese environmentexport LANG=ja_JP.eucJPexport LC_MESSAGES=ja_JP.eucJP #change to en_US on Sarge, otherwise Mozilla will be in japaneseexport LC_CTYPE=ja_JP.eucJPLANGUAGE=Cexport LANGUAGE# Start Japanese inputXMODIFIERS="@im=kinput2"export XMODIFIERSkinput2 -xim -kinput -canna &xmodmap -e 'keycode 115 = Kanji'[window manager - mine is fvwm2]
All the locales will be set to japanese but, to  keep the English menu, we add LANGUAGE set up to C locale. You can probably use your own locale as well (such as French) but you may have some problems with accents and kanji.
At this stage, we launch the kinput2 software which can handle japanese entry, and we add the left Windows Key as "Kanji Key". The default {Shift space} remains, but since the Windows key is unused...

List of the Windows Keys codes.
left Windows key: 115
right Windows key  : 116
right Window menu key : 117

5. *dm tuning

I'm not familiar with the configuration of a X display manager such as xdm or gdm, since I don't like it. Any help about this part will be appreciated.

6. fvwm2 tuning

Well, it's not really tuning, but the font in the configuration sample files aren't japanese capable, so you need to change them. I suggest -misc-fixed-*-*-*-*-14-*-*-*-*-*-*-* instead, which is quite similar.
You may notice that the japanese isn't properly handled in the FvwmPager, and I still don't know why.

7. Others window managers

I'm not familiar with the configuration of others window manager such as the gnome one or KDE one, since I don't like them. Any help about this part will be appreciated.

7.1. Gnome (contributed by Charles Plessy)  !!This may be deprecated on sarge!!

deb http://im-ja.sourceforge.net/ ./

And run
apt-get update
apt-get install im-ja-applet im-ja-canna

Gnome-terminal is now fully japanized. To swith in hiragana, please change the input method with the right-click menu.

8. X software

If everything goes smooth, you must be able to launch your favorite software with japanese writing enabled.
Note: if you launch it from a xterm, it will not work! You need to launch it from the fvwm2 menu.
a. Terminal.
To test if it works, launch a kterm or a krxvt and type this:
ga[kanji key]ga[enter]
You must get this:

If you've followed this document, [kanji key] must be {Shift space} or the left Windows key.

The basic use of kinput2 is quite simple.
• Switch into Kanji mode (hit the Kanji key): You are in the normal mode.
• Start typing: you are in hiragana mode. Type watashi, you will see this:
• Then, hit the space key. it becomes this:

It suggests the most used kanji at first.
• Re hit space and you'll have a new window which which contains more kanji:
• After selecting the correct kanji by hitting space, press enter. You are back to normal mode. You can continue typing some japanese or hit kanji key again to get back to english.
Please notice you can't hit the kanji key in hiragana mode, or you'll loose what you're typing. I suggest you hit enter at each Japanese word to avoid mistakes.
b.LaTeX-CJK
CJK stands for Chinese Japanese Korean. We'll see here how to use LaTeX to write Japanese.
After installing the cjk-latex package, don't forget to run texconfig in the root account to have all stuff OK.
Then, to start a Japanese text, type this before:
\begin{CJK*}{JIS}{song}
and \end{CJK*} at the end.
Please notice you might have some errors if you use XEmacs (never try with emacs): XEmacs is often puzzled with charset, and especially with Japanese ones. Try using vim instead.
Besides, using accents in a CJK section coded in JIS, EUC or SJIS will make some odd things. I've never tried the UTF8 subsystem, though. Anyway, I think - at this time - the most standard is to use a JIS/EUC charset and forge the accents, like \'e instead of é.

To test if LaTeX works, feel free to download this example. It's one of my japanese texts I've made for my japanese course (I'd learning japanese): This is BAD japanese (very bad) but there is useful CJK commands in it, and basics cases are shown. Please refer to /usr/share/doc/cjk-latex/commands.doc.gz and /usr/share/doc/cjk-latex/ruby.doc.gz for details.

c.Various X softwares
Here are some others examples:
• Gimp 1.2. It works perfectly if you select the japanese capable fonts. Please note that the font selection may be quite slow, it takes about 5 to 10 seconds to display it (on my celeron 800)

• Mozilla: You must install the japanese pack before: Use the "Download more" button.

Warning: You need to be root to be able to add a language pack under mozilla.
After that, you must get this:

I've wrote "edogawa" in the search field. Please note the "a" hiragana in the small window below, which tells you you are in japanese mode.

9. OpenOffice.org

OOo needs some Asian languages tuning: Go to Tools -> Options

At the first launch, "Searching in" and "Asian Layout" may not be displayed. You must first check "Asian languages support", select "Japanese" in "Default languages for documents" and click OK.
Then, you MUST see "Searching in" and "Asian Layout".

After that, go to "Text document" and "Basic Fonts" (both): you must set up the proper default font for English (first one) AND japanese. I suggest you  use the "Mincho" font.

There is a special issue about OOo: The Japanese isn't properly handled by the default UI font, so you will have something like this:

Yeah, quite ugly.
Here comes the hint (Thanks to Takamichi Akiyama from discuss@ja.openoffice.org)

You need to TYPE "Andale Sans UI" in the "Font" field even if the font is not in the listbox.
Use Mincho in the "Replace with" listbox under Linux, and "MS Mincho" under Windows XP.

And you will have this:

You can see that both the window manager (fvwm2) and OpenOffice fully understand japanese. We've done it!

Please note that this hint works under Windows XP.

You can test your OOo configuration with this file, which is the OOo file in the latest screenshot.

Note: To make furigana, select the kanji and pull down "Format -> ruby": you will be able to add furigana in your text like the latest example.

10. Printing.

Although the printing with OpenOffice works perfectly well, it won't work with Mozilla.

I still haven't found a way to directly print with mozilla.

By the way, you can use PS file output, and I've done some test with the PS conversion, and the result depends on the page charset and default charset you use.
• This one must work.
• This one must not, since the charset page is false (iso-8859-1) and must be a Japanese one. As a workaround this, simply go to view -> Charset Coding -> iso-2022-jp.
When the PS file looks good on your system, use ps2ps to force the Japanese font, and print the resulted file. It MUST work.

For plain text, I've found one way, but need to pass through a2psj and ps2ps, so I've made a very simple bash script:

#!/bin/sh
#Small script to print japanese text on printer.
#Usage: lprj [text file] [-P[printer]]
FILE=echo $USER-date +%s.ps a2psj$1 >/tmp/$FILE ps2ps /tmp/$FILE - |lpr \$2

There are probably plenty of better methods, mail me if you have something better (wonder if I must mind deleting the tmp file)

This is the end.

And you must have a quite useful Japanese capable english operating system.
Feel free to mail me (text only email) if you want to add something, comment or anything.

I use all of this documents to make mine, it may be useful for others.

Debian: Basic japanese configuration under Debian (Osamu Aoki - ) .
Debian: Some usefull hints (debian ML - ).
Debian: How to set up pine/pico in japanese (JWS - ).

Mozilla/Kinput2: Default key for kinput2 under mozilla (Katsuhiko Momoi - ).
Mozilla/X:  Use of xmodmap, use of xinitrc (laeren - ).
X tuning: Some clues about xmodmap (various - ).
Gnome: Prise en charge du japonais sous debian (Charles Plessy -  )

OOo: Basic use (Jim Breen - ).
OOo: Figure out which debian fonts I need (Noriaki Sato - ).
OOo: I've found the hint but Takamichi Akiyama told me the way to make it (OOo - ).
OOo: Good way to find out which font on your system is japanese capable under OOo (discuss@ja.openoffice.org - ).
OOo: How to configure furigana (OOo - ).

Thanks

• Takamichi Akiyama, who have resolved my OOo problem
• G. Roderick Singleton, for redirected me on the discuss@ja.openoffice.org mailing list
• Charles Plessy, for the hint about Gnome setup
• Michel Givon, for greatly improving English

Changelog

August, 15: Version 1.1
• Improving English (Thanks to Michel Givon)
• Adding a Gnome part (Thanks to Charles Plessy)
May, 30. Version 1:
• First public version

Back to index.

Guillaume "LoneWolf" Estival.