Archive for the ‘Linux’ Category

Japanese Input on Fedora 19 Schrödinger’s Cat

Saturday, 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)

Sunday, 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

Tuesday, 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. お疲れさまでした。

Unlocking Secured Password Protected PDF Files

Saturday, 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

Sunday, 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)

Monday, 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

Sunday, 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. いつものように簡単でした。

Japanese Encoding Conversion

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

Japanese Input on Fedora 17 Linux Beefy Miracle (Gnome 3)

Friday, June 8th, 2012

Setting up Japanese input IME (日本語入力方法) on Fedora 17 Linux under the Gnome 3 environment is quick and easy.

Fedora uses the IBus keyboard input method system and uses the Anthy Japanese input method for the Japanese keyboard input, so it will be a familiar process to set up and use if you have done it on earlier Fedora Linux distributions.

Japanese IME Setup Procedure

To start, open Activities from the Top Panel.

In the Search Box, type Input Method and select the Input Method Selector.

In the Input Method Selector screen, select Use IBus (recommended).

 

Press the Preferences… link to the right of Use IBus (recommended) to open the IBus Preferences screen.

On the Input Method tab, check the Customize active input methods check box.

Press the Select an input method dropdown and select Show all input methods.

Press the Select an input method dropdown once again and now select Japanese → Anthy.

Press the Add button, and then press Close.

You must log out for the changes to take effect, so press the Log Out button on the Input Method Selector screen.

When you log back in you will now have the IBus input method framework button on the Gnome top panel (It looks like a small keyboard with a globe in front of it). This is the button to change input modes. Open a text editor such as gedit or some other application with a text input window.

Press the IBus input method framework button and select Japanese – Anthy.

The keyboard icon has now changed to Aち, which shows the letter A and the hiragana character chi, which probably is trying to get something close the the pronunciation of Anthy while indicating Japanese/English input modes.

You should now be able to type in Japanese.

Use the Anthy Aち button to toggle between Japanese, English, and other Japanese IME modes.

Note: If you get the message No input window when you try to select Japanese Anthy, make sure you have the mouse cursor in an application with a text input box, such as a text editor or a Web browser.

That’s it. You should be able to type in Japanese now. Setting up Japanese IME input on Fedora Linux is simple and very similar to previous versions of Fedora.

For previous versions of Fedora, refer to:

Japanese Input on Linux Mint 13 Maya LTS (Mate)

Saturday, June 2nd, 2012

This tutorial will show you how to install Japanese input IME (日本語入力方法) in Linux Mint 13 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 Software Manager, search for ibus.

Select ibus.

Click Install.

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

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

While IBus is installing, search for anthy.

Select ibus-anthy and click Install.

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

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.

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

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

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

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.

The IBus i icon should now display in the bottom panel (The square icon; not the shield 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.

Open a text application like Text Editor. While the cursor is in the text field, press the IBus i icon in the bottom panel and select Japanese – Anthy.

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.