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):
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

You must add to your system the proper locales:
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:
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.
add this at the end of your .bashrc:
#force EN menu and error displaying
LANGUAGE=C
LC_COLLATE=C
LC_NUMERIC=C
LC_MONETARY=C
LC_TIME=C
export LANGUAGE
export LC_COLLATE
export LC_NUMERIC
export LC_MONETARY
export LC_TIME
You'll still have Japanese locales ON, but all the common display will be in english.

4. Startx and X tuning.

Edit your XF86Config file, search for freetype, and:
#        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"

edit your .xinitrc file and add this, just before window manager.
# Start Japanese environment
export LANG=ja_JP.eucJP
export LC_MESSAGES=ja_JP.eucJP #change to en_US on Sarge, otherwise Mozilla will be in japanese
export LC_CTYPE=ja_JP.eucJP
LANGUAGE=C
export LANGUAGE
# Start Japanese input
XMODIFIERS="@im=kinput2"
export XMODIFIERS
kinput2 -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!!

Please add the following line on your /etc/apt/source.list file.

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.
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
For basic information about LaTeX, please go to the main website.
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:

9. OpenOffice.org

You  can download the 1.1.1 version at OpenOffice.org. It's a free download.

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.
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.

References and usefull links.

If you have made some similar document about another distribution, feel free to mail me, I'll be glad to add it.
I use all of this documents to make mine, it may be useful for others.

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

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

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

Thanks


Changelog

August, 15: Version 1.1
May, 30. Version 1:

Back to index.

Guillaume "LoneWolf" Estival.