There are various ways to enable Japanese input to some degree in Ubuntu 12.04, 12.10 and 13.04*. Instead of temporarily changing the keyboard layout, the use of an input method editor (IME for short) is far more effective; changing phonetically spelt Latin characters (Rōmaji) directly into the corresponding Kana and Kanji.
Installing the relevant language and IME packages
Firstly, we need to install the required language packages for Japanese. This can be done through the Language Support utility; however, this program can be avoided entirely by installing the required packages using the following terminal command:
sudo apt-get install language-pack-ja language-pack-gnome-ja
After successful installation of the language packages, it is time to install a relevant input method editor. Anthy is a commonly-used IME for Japanese input on Unix-based systems and it conveniently works with the input method framework IBus. If the Language Support utility has been previously installed, IBus will have likely been included with it; regardless, it can be installed or updated alongside Anthy with the following terminal command:
sudo apt-get install ibus ibus-gtk anthy ibus-anthy
Configuring IBus for Japanese Anthy Input
With all the required packages installed, IBus can be started as a background daemon process; but, it also needs to be configured to use Anthy in its accompanying GUI interface. To start IBus and open the configuration window, use the command:
ibus-daemon -d && ibus-setup
When the window opens click the ‘Input Method’ tab and tick the checkbox ‘Customise active input methods.’ Select ‘Japanese -> Anthy’ on the drop-down menu, ‘Select an input method.’ Finally, click the Add button.
Next, the IBus process needs to run on each boot; this is fairly simple to resolve, either set the Ibus daemon to run on start-up – Google is your friend here – or set the IBus as the default input method using this command:
A lovely GUI will pop-up. Click OK and then a new window will ask if you want to change the current user configuration. Click Yes and select the ‘ibus’ radio button, followed by OK again. Click the OK button on the final summary window and hey presto, the configuration has been updated. At last, to start using the new configuration simply restart the computer – more advanced users can just restart their X server.
The End Result
Assuming the above is completed without a hitch, it will now be possible to swap between Japanese and the system’s standard input, on the fly, by using the Ctrl + Space shortcut. While typing in Japanese, remember to use the shortcut F7 to swap from Hiragana to Katakana. The Space bar is used to cycle through other forms, like the related Kanji.
こううん！ ｜ コウーン！ ｜ 幸運！
* This method should work for 13.04; however, it may not. I have yet to test it from a fresh install.