Japanese Input on Fedora 19 Schrödinger’s Cat

July 27th, 2013

Setting up Japanese input IME (日本語入力方法) on Fedora 19 Linux under the Gnome 3 environment is quick and easy, and can even be done during the initial setup process.

This quick tutorial will show you how to set up Japanese input.

Japanese IME Setup Procedure

To start, open Activities from the Top Panel.

In the Search Box, type Region & Language and select Region & Language.

fedora19-1

On the Input Sources section of the Settings screen, press the + in the lower left corner to add a new keyboard input source.

fedora19-2

On the Add an Input Source screen, select Japanese.

fedora19-3

On the next Add an Input Source screen, select Japanese (Kana Kanji).

fedora19-4

Press Add.

Close the Region & Language menu.

You should now have the input language menu in the top bar. The en displayed means English keyboard.

fedora19-5

Press it and select Japanese (Kana Kanji) to change to Japanese Input.

fedora19-6

The en should have changed to a katakana あ to indicate Japanese input.

fedora19-7

That’s it. You can now type in Japanese.

fedora18-8

Press the katakana あ in the top bar while in Japanese input mode to toggle between various input modes and typing methods.

For previous versions of Fedora, refer to:

Japanese Input on Linux Mint 15 Olivia (Cinnamon)

June 30th, 2013

This tutorial will show you how to install Japanese input IME (日本語入力方法) in Linux Mint 15 under the Cinnamon desktop environment. Japanese IME is required to be able to type in Japanese. It is pretty easy to get working, so let’s start.

Click on the Mint Menu and select Software Manager.

linuxmint15-1

linuxmint15-2

In the Enter your password to perform administrative tasks dialog box, enter your system password and press OK.

In the Software Manager, search for ibus.

linuxmint15-3

Select ibus by double clicking it.

linuxmint15-4

Click Install.

Software Manager will now download and install IBus in the background.

linuxmint15-5

While IBus is installing, search for anthy.

linuxmint15-6

Select ibus-anthy by double clicking it and click Install.

linuxmint15-7

 

Software Manager will now download and install ibus-anthy in the background.

When the activity bar on the bottom shows 0 ongoing actions, installation is complete.

linuxmint15-15

Close Software Manager.

From the Mint Menu, select to System Settings – Control Center.

linuxmint15-8

Open Languages.

linuxmint15-9

If you get the dialog box that says The language support is not installed completely, select Install to install them now.

In the Authenticate dialog box, enter your system password and press Authenticate.

On the Language Support screen, select Install / Remove Languages….

Scroll down and check Japanese, and then press Apply Changes.

The Applying changes popup screen will display. Wait for it to finish applying changes. It may take a few minutes.

On the Language Support screen, press the Keyboard input method system: drop down and select IBus.

linuxmint15-10

Then press Close.

Click the Mint Menu,  and select Preferences → Keyboard Input Methods.

linuxmint15-11

On the IBus Preferences screen, go to the Input Method tab.

Select the Customize active input methods check box.

Press the Select an input method dropdown and select JapaneseAnthy.

Press Add on the IBus Preferences screen to add the Anthy Japanese input method.

Press Close to exit the IBus Preferences screen.

You should now have a keyboard input method icon displayed in the bottom panel.

linuxmint15-12

Open a text application like gedit.

Click the keyboard icon and select Japanese – Anthy.

linuxmint15-13

The IBus keyboard icon should have changed to the Anthy Aち icon. If it does not show up, log out and log back in. It should now show up. I recommend logging out and logging back in just to make sure it starts properly. It may show up but give you a No Input Window error if it doesn’t start up properly. You can also try to restart Ibus from this menu.

linuxmint15-14

Anthy is now activated. To toggle between English and Japanese input, press Control + Space Bar. The IBus icon will now change to the Anthy Aち icon, indicating that you can type in Japanese.

That’s all there is to it. Now you can type in 日本語.

Note: Sometimes the input method reverts back to English if you are changing back and forth between windows and applications. Just press Control + Space Bar to toggle back to Anthy if this happens.

Japanese Input on Ubuntu Linux 13.04 Raring Ringtail

May 7th, 2013

This tutorial will show you how to set up Japanese input IME (日本語入力方法) on Ubuntu Linux 13.04 from the Unity interface so you can type in Japanese in all your favorite Ubuntu applications. The installation procedure is identical to the previous Ubuntu 12.04 and Ubuntu 12.10 releases.

Setup Procedure

To start, select Dash home from the Unity Launcher.

ubuntu13-04-1

From the Dash home, search for Language Support.

ubuntu13-04-2

Select Language Support.

ubuntu13-04-3

Note: If you get the language support is not installed completely dialog box at this point, press Install to install them now.

ubuntu13-04-4

On the Language tab of the Language Support screen, press Install / Remove Languages…

On the Installed Languages screen, scroll down to Japanese and check Installed, and then press Apply Changes.

Enter your password on the Authenticate screen.

It will take a few moments to download and install the Japanese IME packages.

Back on the Language Support screen, select IBus for the Keyboard input method system, and then press Close.

ubuntu13-04-5

Once again select Dash home from the Unity Launcher.

ubuntu13-04-1

From the Dash home, search for Keyboard Input Methods.

ubuntu13-04-6

Select Keyboard Input Methods.

ubuntu13-04-7

Note: You may get a pop up message saying Keyboard Input Methods (IBus Daemon) has not been started. Do you want to start it now? Select Yes.

On the Input Method tab of the Ibus Preferences screen, select the Customize active input methods check box.

Then, press Select an input method and select Japanese → Anthy.

ubuntu13-04-8

Press Add and then press Close.

The Ibus keyboard icon will now display on the top panel.

ubuntu13-04-9

Open up any application with a text box such as gedit and place the cursor in the text box.

Press the Ibus keyboard icon on the tap panel and select Japanese-Anthy.

ubuntu13-04-10

The Ibus keyboard icon will now change to the Anthy Aち icon.

ubuntu13-04-11

That’s it. You can now type in Japanese in Ubuntu 13.04. お疲れさまでした。

Japanese Input on Mac OS X 10.8 Mountain Lion

April 13th, 2013

Setting up Japanese input IME (日本語入力方法) on Mac OS X so you can type in Japanese is extremely easy. It just takes a few clicks in System Preferences and you are ready to go.

Japanese IME Setup Procedure

To start, open System Preferences from the dock.

mac-osx-108-1

 In the Personal section of System Preferences, click on Language & Text.

mac-osx-108-8

On the Language & Text screen, click the Input Sources menu.

mac-osx-108-9

On the Input Sources menu of the Language & Text screen, scroll down until you find あKotoeri and click the On button. By default it selects Hiragana, Katakana, and Romanji input.

mac-osx-108-4

You should now have the flag icon on the Mac OS top menu bar, indicating that you have multiple keyboard input methods available.

mac-osx-108-5

Click on the flag and select あ Hiragana to type in Japanese.

mac-osx-108-6

That’s it. Like most things on a Mac, it’s pretty easy and it just works.

If you want to change the keyboard shortcut used to switch between keyboard input methods, press the Keyboard Shortcuts… button on the same Input Sources menu of the Language & Text screen where you turned on Japanese input.

mac-osx-108-7

Unlocking Secured Password Protected PDF Files

February 23rd, 2013

Out of all the possible file formats out there, translating a PDF document is usually the worst-case scenario. The only thing worse than a PDF, is a locked password-protected PDF with security settings that don’t allow you to even copy and paste text out of it. It’s very difficult to look up Japanese words if you can’t copy the text, and you definitely can’t make use of translation memory software if you have no access to the text. So here is a simple way to unlock those secured PDFs to get access to the text.

You Will Need

A Linux computer or VM with Ghostscript installed.

How to Unlock the Secured PDF with Ghostscript

We’re actually going to create a identical copy of the PDF that is unlocked. We’ll use Ghostscript to do this. Ghostscript is a PostScript and PDF language interpreter and previewer that is commonly found pre-installed on most major Linux distributions. If it isn’t already installed, it can be easily obtained using your distro’s package management tool.

Using Ghostscript on Linux, you can unlock a PDF with a single command:

gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=OUTPUT.pdf -c 
.setpdfwrite -f INPUT.pdf

That’s a rather long series of parameters, so let’s break it down so you understand what is going on.

  • The gs command invokes Ghostscript.
  • The -q switch invokes quiet mode, which suppresses a lot of messages that you probably aren’t interested in.
  • The -dNOPAUSE switch enables no pause after each page.
  • The -dBATCH switch will exit after the last file completes.
  • The -sDEVICE=pdfwrite switch selects the device. In this case, we select the pdfwrite device to create a PDF. Ghostscript works with numerous devices for almost every possible format, including graphic formats such as jpeg, tiff, png, bmp, etc.
  • The -sOutputFile=OUTPUT.pdf switch selects the output file that we are creating. We read in a locked PDF, and we create a new, unlocked PDF file called OUTPUT.pdf in this case.
  • The .setpdfwrite operator automatically sets up parameters that are useful for creating PDFs using the pdfwrite output device.
  • Our locked PDF file we want to unlock is INPUT.pdf in this example.

Converting Multiple Files in Batch

Suppose you have an entire directory full of locked PDF files you want to unlock. Here is a quick little Bash script you can do on the Linux command line to unlock all the PDFs at once.

for x in *.pdf
do
   gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=converted_$x -c 
   .setpdfwrite -f $x;
done

In this script, all of the converted PDFs will be prefixed with converted_.

That’s all there is to it. If you have a Linux computer or virtual machine, it just takes one command to create an unlocked copy of the PDF.

Japanese Input on Fedora 18 Linux Spherical Cow

February 17th, 2013

Setting up Japanese input IME (日本語入力方法) on Fedora 18 Linux under the Gnome 3 environment is easier than ever. However, it is different from previous Gnome 3 versions of Fedora, such as Fedora 16 and 17.

This quick tutorial will show you how to set up Japanese input with the Anthy input system.

Japanese IME Setup Procedure

To start, open Activities from the Top Panel.

In the Search Box, type Region & Language and select Region & Language.

fedora18-1

Select the Input Sources tab on the Region & Language screen.

fedora18-2

On the Input Sources tab, select the + in the lower left corner to add a new keyboard input source.

fedora18-3

On the Choose an input source dialog box, select Japanese (Anthy).

fedora18-4

Press Add.

Close the Region & Language menu.

You should now have the input language menu in the top bar. The en displayed means English keyboard. Press it and select Japanese (Anthy) to change to Japanese Input.

fedora18-5

The en should have changed to a katakana あ to indicate Japanese input.

fedora18-6

That’s it. You can now type in Japanese.

fedora18-8

Press the katakana あ in the top bar while in Japanese (Anthy) input mode to toggle between various input modes and typing methods.

fedora18-7

For previous versions of Fedora, refer to:

Japanese Input on Linux Mint 14 Nadia (MATE)

December 10th, 2012

This tutorial will show you how to install Japanese input IME (日本語入力方法) in Linux Mint 14 under the MATE desktop environment. Japanese IME is required to be able to type in Japanese. It is pretty easy to get working, so let’s start.

Click on the Mint Menu and select System → Software Manager.

In the Enter your password to perform administrative tasks dialog box, enter your system password and press OK.

In the Software Manager, search for ibus.

Select ibus by double clicking it.

Click Install.

Software Manager will now download and install IBus in the background.

While IBus is installing, search for anthy.

Select ibus-anthy by double clicking it and click Install.

Software Manager will now download and install ibus-anthy in the background.

When the activity bar on the bottom shows 0 ongoing actions, installation is complete.

Close Software Manager.

From the Mint Menu, select to System → Control Center.

Open Language Support.

If you get the dialog box that says The language support is not installed completely, select Install to install them now.

Note: You may get an error when trying to Install at this point. Continue on anyways, as it seems like a bug in Mint and still lets you install Japanese input method.

In the Authenticate dialog box, enter your system password and press Authenticate.

On the Language Support screen, select Install / Remove Languages….

Scroll down and check Japanese, and then press Apply Changes.

The Applying changes popup screen will display. Wait for it to finish applying changes. It may take a few minutes.

On the Language Support screen, press the Keyboard input method system: drop down and select ibus.

Then press Close.

On the Control Center screen, scroll down and select Other → Keyboard Input Methods.

You may get a popup dialog box that says Keyboard Input Methods (IBus Daemon has not been started. Do you want to start it now? Select Yes to start IBus.

The IBus daemon is now started and the IBus preferences screen will now display.

On the IBus Preferences screen, go to the Input Method tab.

Select the Customize active input methods check box.

Press the Select an input method dropdown and select JapaneseAnthy.

Press Add on the IBus Preferences screen to add the Anthy Japanese input method.

Press Close to exit the IBus Preferences screen.

You should now have a keyboard input method icon displayed in the bottom panel.

Open a text application like Text Editor.

Click the keyboard icon and select Japanese – Anthy.

The IBus keyboard icon should have changed to the Anthy Aち icon. If it does not show up, log out and log back in. It should now show up. I recommend logging out and logging back in just to make sure it starts properly. It may show up but give you a No Input Window error if it doesn’t start up properly. You can also try to restart Ibus from this menu.

Anthy is now activated. To toggle between English and Japanese input, press Control + Space Bar. The IBus icon will now change to the Anthy Aち icon, indicating that you can type in Japanese.

That’s all there is to it. Now you can type in 日本語.

Note: Sometimes the input method reverts back to English if you are changing back and forth between windows and applications. Just press Control + Space Bar to toggle back to Anthy if this happens.

Japanese Input on Ubuntu Linux 12.10 Quantal Quetzal

October 28th, 2012

This tutorial will show you how to set up Japanese input IME (日本語入力方法) on Ubuntu Linux 12.10 from the Unity interface so you can type in Japanese in all your favorite Ubuntu applications. The installation procedure is identical to the previous Ubuntu 12.04 release.

Setup Procedure

To start, select Dash home from the Unity Launcher.

From the Dash home, search for Language Support.

Select Language Support.

On the Language tab of the Language Support screen, press Install / Remove Languages…

On the Installed Languages screen, scroll down to Japanese and check Installed, and then press Apply Changes.

Enter your password on the Authenticate screen.

It will take a few moments to download and install the Japanese IME packages.

Back on the Language Support screen, select ibus for the Keyboard input method system, and then press Close.

Once again select Dash home from the Unity Launcher.

From the Dash home, search for Keyboard Input Methods.

Select Keyboard Input Methods.

You may get a pop up message saying Keyboard Input Methods (IBus Daemon) has not been started. Do you want to start it now? Select Yes.

On the Input Method tab of the Ibus Preferences screen, select the Customize active input methods check box.

Press Select an input method and select Japanese → Anthy.

Press Add and then press Close.

The Ibus keyboard icon will now display on the top panel.

Open up any application with a text box such as gedit and place the cursor in the text box.

Press the Ibus keyboard icon on the tap panel and select Japanese-Anthy.

The Ibus keyboard icon will now change to the Anthy Aち icon.

That’s it. You can now type in Japanese in Ubuntu 12.10. いつものように簡単でした。

A Star is Born – Introducing Honyaku Star Japanese/English Dictionary

October 4th, 2012

Today I’m launching Honyaku Star, a new online Japanese/English dictionary.

The goal of Honyaku Star is to be the world’s most comprehensive free, online Japanese/English dictionary and corpus. Honyaku Star is built on top of numerous excellent community dictionaries, and adds to it the Honyaku Star dictionary, which tries to fill in everything else that isn’t in those general dictionaries, with the goal to be the best, and only dictionary you need.

Honyaku Star is more than a dictionary, it is also a Japanese/English bilingual corpus. In other words, a database of parallel texts to provide context, usage, and examples of words and phrases you search for. Many words have lots of valid translation varieties, and seeing it used in various different contexts can help you understand the different meanings and pick the appropriate usage. When you search in Honyaku Star, you get dictionary results and example sentences together.

I built Honyaku Star because I use online Japanese/English dictionaries every day, and none of them satisfied me. There are certain things I want, and don’t want out of an online Japanese/English dictionary. So, I built Honyaku Star based on the principles I think are important.

  • Dictionaries and language resources should be free and easily accessible.
  • The one and only dictionary advanced students and translators will need.
  • Lots of relevant results for a search query. 1,000 results if possible.
  • Provide in-context usage and examples sentences.
  • Clean, simple user interface.
  • No pagination in the UI.
  • Searches should be super fast. Instantaneous!
  • No visual distractions. No ads. No random Web content. No useless information like character encoding codes.
  • No advanced search! It should be smart and bring back results in an intelligent way.
  • The primary goal of a searchable dictionary is to be a useful language resource–it should not a means to draw you in and sell you language services or books.

I think I’ve kept with my design principles on this initial version, and it’s only going to get better with time.

The technology behind Honyaku Star is Linux, PHP, Perl, MySQL, and the awesome full-text index Mroonga. I’ll post more about some of the technical challenges in future posts.

Honestly, I made Honyaku Star for myself, to be the ideal dictionary that I’d want to use everyday. But my hope is others will find it useful. All user feedback is welcome and appreciated. And if you use and like Honyaku Star, consider contributing translations to it.

Start using Honyaku Star today at http://honyakustar.com.

Japanese Encoding Conversion

July 16th, 2012

Japanese has many different text encodings, and one that pops up a lot when you are working on text files is EUC-JP (Japanese Extended Unix Code). You find EUC-JP encoding used in many Japanese Web sites, text documents, JMdict and EDICT glossary files, and so on. This encoding is particularly troublesome because a lot of English-language text editors and utilities don’t know how to deal with it.

Usually you want to work with UTF-8 instead, so here are some strategies for converting EUC-JP encoding into UTF-8.

Simple Command-Line Conversion in Linux

On Linux this is really easy. Use the iconv command-line conversion utility.

iconv -f EUC-JP -t UTF-8 input.txt > output.txt

or

iconv -f EUC-JP -t UTF-8 input.txt -o output.txt

input.txt is in EUC-JP encoding, and the resultant output.txt is converted to UTF-8. Short and sweet, and can easily be piped to further commands.

We can use a Bash loop to automate this. For example, to convert all XML files to UTF-8:

for x in *.xml;
do
  iconv -f EUC-JP -t UTF-8 $x > converted/$x
done

Command-Line Perl Program

Let’s write a simple Perl program that will take two command-line arguments: the input file in EUC-JP encoding, and the resultant output file converted to UTF-8. We will be able to run the program like this:

./convert input.txt output.txt

For this, we will use the from_to() function that is part of the Encode module. The from_to() function takes three parameters: the input, the encoding of the input, and the desired encoding of the output.

from_to($input, "euc-jp", "utf8");

Here is the full program:

#!/usr/bin/perl
use strict;
use warnings;
use Encode "from_to";

my $inputFilename  = $ARGV[0];
open(INFILE,  "<", "$inputFilename")  or die "Can't open $inputFilename:  $!";

my $outputFilename = $ARGV[1];
open(OUTFILE, ">", "$outputFilename") or die "Can't open $outputFilename: $!";

while (<INFILE>) {
   from_to($_, "euc-jp", "utf8");
   print OUTFILE $_;
}

close INFILE  or die "INFILE:  $!";
close OUTFILE or die "OUTFILE: $!";

Command Line PHP Program

PHP programs can also be run on the command line. Let’s add a little bit more this time and convert all non-PHP files in a directory from EUC-JP to UTF-8 and put them in a tmp directory using command-line PHP.

We will use the mb_convert_encoding() function which works on multi-byte strings. The mb_convert_encoding() function takes three parameters: the input, the desired encoding of the output, and the encoding of the input.

mb_convert_encoding($input, "UTF-8", "EUC-JP");

Here is the full program:

<?php

$dirHandler = opendir(".");

while ($fileName = readdir($dirHandler)) {

   if ($fileName != '.' && $fileName != '..' 
                        && $fileName != 'php' && $fileName != 'tmp') {

      $file = file_get_contents("./$fileName", FILE_USE_INCLUDE_PATH);
      $convertedText = mb_convert_encoding($file, "UTF-8", "EUC-JP");

      echo "$fileName\n";

      $writeFile  = "../tmp/$fileName";
      $fileHandle = fopen($writeFile, 'w') or die("can't open file");
      fwrite($fileHandle, $convertedText);
      fclose($fileHandle);
   }
 }

?>

Just Use Firefox and a Text Editor

Finally, a very simple way to convert EUC-JP text to UTF-8 if you are working with plain text is to simply open the file in Firefox. Firefox almost always gets the encoding right, and if it doesn’t, you can manually set it in the Character Encoding menu. Then, copy and paste the text into your favorite text editor and save it as UTF-8.

As you can see, you have lots of easy options for converting text between various encodings. And the same scripts can be used for other Japanese encoded strings such as JIS and Shift-JIS.