Home » Blog » Page 4

Blog

Converting zenkaku to hankaku

For historical reasons, Chinese, Japanese and Korean word processors allow certain characters (including the Roman alphabet and Arabic numerals) to be entered using wide variants called fullwidth (zenkaku; 全角) characters instead of — or rather, in addition to — the ordinary halfwidth (hankaku; 半角) characters used by everyone else.

When preparing Japanese text for translation in CAT tools like OmegaT, it often helps to convert zenkaku characters to their hankaku equivalents. The Japanese version of Microsoft Word has a built-in feature that will do this, but it’s a little bit annoying because it also converts katakana characters. All I really want to do is convert the non-Japanese characters.

Here’s a Perl script I’ve been using to do this inside TextWrangler:

#!/usr/bin/perl -w

# File: ZtoH.pl
# Author: Phil Ronan, japanesetranslator.co.uk

# Convert zenkaku to hankaku

# Prepare Japanese UTF-8 plain-text files for translation by
# converting full-width (zenkaku) characters to their half-width
# (hankaku) counterparts. Katakana characters are not converted.

# This script was written for use as a TextWrangler plugin, but
# can also be used as a command line tool -- simply pipe in the
# text you want to convert, and the results will be delivered
# to stdout.

use utf8;
use Encode;
binmode STDOUT, ":utf8";

my $s;

while (<>) {
  $s = decode_utf8($_);
  $s =~ tr/ !"#$%&'()*+,-.// !"#$%&'()*+,-.\//;
  $s =~ tr/0-9:;<=>?@A-Z[\]^/0-9:;<=>?@A-Z[\\]^/;
  $s =~ tr/_`a-z{|}〜¢£¬ ̄¦¥₩/_`a-z{|}\~¢£¬¯¦¥₩/;
  print $s;
}

(You can download the script here, but you’ll need to rename it to ZtoH.pl before running it. Make sure you save the script using UTF-8 encoding.)

If you’re using TextWrangler, simply place this file inside your Unix Filters directory (~/Library/Application Support/TextWrangler/Unix Support/Unix Filters). You should then see this script listed under Unix Filters in the !# menu. Update: In more recent version of TextWrangler, the text filters have been moved to Text » Apply Text Filter.

If you don’t have TextWrangler or you’re running some other system, then you can still use this script as long as you have Perl installed. Just pipe your UTF-8 encoded text through it, and the results will appear on stdout.

Posted in Hacks, Translation | Tagged | 2 Comments

Son et lumière

Here’s a cool idea from NEC Lighting — a ceiling light with a built-in Bluetooth speaker that can be operated via an Android app. They’re not on sale yet, but should be available later this year (in Japan, at least).

Posted in inventions | Tagged | Comments Off on Son et lumière

Sukiyaki

The song Ue o muite arukō (上を向いて歩こう) by Kyū Sakamoto (坂本 九) was given the rather cheerful title of “Sukiyaki” when released in the West back in the early 1960s. The title actually means “I’ll look up as I walk”, and the song explains that this is because the singer doesn’t want to let his tears of sorrow fall to the ground.

This stoical attitude to misfortune resonated strongly with the Japanese as they came to terms with last year’s disastrous earthquake and the events that followed. For example, in April the drinks manufacturer Suntory bought up advertising time on TV to lift people’s spirits with recordings of two Sakamoto songs sung by various celebrities who had appeared in Suntory adverts in the past. A rendering of Ue o muite arukō by artists including Tommy Lee Jones can still be seen on YouTube. But here’s the original version:

Japanese Pronunciation Translation
上を向いて歩こう Ue o muite arukō I’ll look up as I walk
涙がこぼれないように Namida ga koborenai yō ni So the tears won’t fall
思い出す春の日 Omoidasu haru no hi As I remember those days in spring
一人ぼっちの夜 Hitori botchi no yoru Because tonight I’m all alone
. . .
上を向いて歩こう Ue o muite arukō I’ll look up as I walk
滲んだ星を数えて Nijinda hoshi o kazoete Counting the stars with tearful eyes
思い出す夏の日 Omoidasu natsu no hi As I remember those days in summer
一人ぼっちの夜 Hitori botchi no yoru Because tonight I’m all alone
. . .
幸せは雲の上に Shiawase wa kumo no ue ni Happiness lies above the clouds
幸せは空の上に Shiawase wa sora no ue ni Happiness lies above the sky
. . .
上を向いて歩こう Ue o muite arukō I’ll look up as I walk
涙がこぼれないように Namida ga koborenai yō ni So the tears won’t fall
泣きながら歩く Nakinagara aruku But still the tears well up
一人ぼっちの夜 Hitori botchi no yoru Because tonight I’m all alone
. . .
思い出す秋の日 Omoidasu aki no hi As I remember those days in autumn
一人ぼっちの夜 Hitori botchi no yoru Because tonight I’m all alone
. . .
悲しみは星の陰に Kanashimi wa hoshi no kage ni Sadness lies in the shadow of the stars
悲しみは月の陰に Kanashimi wa tsuki no kage ni Sadness lies in the shadow of the moon
. . .
上を向いて歩こう Ue o muite arukō I’ll look up as I walk
涙がこぼれないように Namida ga koborenai yō ni So the tears won’t fall
泣きながら歩く Nakinagara aruku But still the tears well up
一人ぼっちの夜 Hitori botchi no yoru Because tonight I’m all alone
Posted in Miscellaneous | Tagged , , | 1 Comment

Moving house (part 3)

Regular visitors might have noticed that I’ve been in the process of moving house most of this year. Having spent the entire summer and most of the autumn living at temporary addresses, we have — finally!! — moved into the place we wanted.

Here’s the new address:

6 Herbert Road, Exeter EX1 2UQ
Tel: +44 (0)1392 202673

Posted in Moving house | Tagged | Comments Off on Moving house (part 3)

OmegaT + Google Translate v2 + Mac OS X

OmegaT is a free, open-source, cross-platform computer-assisted translation tool. One of its useful features is an interface to the Google Translate API that enables it to provide a (somewhat helpful) machine translation of each chunk of text as it is being translated. Earlier this year, Google announced that its free translation API is to be replaced with a paid service, and will stop altogether on 1st December 2011.

Providing an API key

Recent versions of OmegaT are compatible with the paid service (Google Translate v2), but before you can use it you have to set up an account with Google and give them your credit card details. In return, you’ll get an identification code called an API key that OmegaT will need when interacting with Google. However, the OmegaT developers haven’t yet made it very easy to enter this key.

Windows users can provide this information by adding the following line to the OmegaT.l4J.ini configuration file (replacing “xxxx” with your actual API key):

-Dgoogle.api.key=xxxx

On other operating systems, the API key has to be provided as a command line argument when the OmegaT Java application is started up. Which is a nuisance, because there’s no way of adding command line arguments when you start an application by clicking its icon.

A workaround for OS X

This can be remedied with a bit of AppleScript and Unix scripting. Copy and paste the following code into AppleScript editor (not forgetting to replace “xxxx” with your API key), then save it as a run-only application. Don’t call this file OmegaT.app; any other name is fine.

set apikey to "xxxx" as string
set ss to "java -jar -Dgoogle.api.key=" & apikey & " $(ls -ptd $(find " & ¬
     "/Applications -name \"OmegaT.app\" -maxdepth 2 -type d |xargs) " & ¬
     "|head -1)Contents/Resources/Java/OmegaT.jar >/dev/null 2>&1 &" as string
do shell script ss

You can then drag this file to the dock and run it with a single mouse click. It works by searching for a file called OmegaT.app inside your Applications folder, digging down to the Java application inside it, and then launching this application with your API key as a command line argument. If you have more than one version of OmegaT installed on your computer, this script will run the most recent one it can find.

★ Update ★

Jean-Christophe from the OmegaT team just informed me that there’s another way of providing a Google Translate API key, which involves adding a google.api.key item under Java > Properties in the info.plist file inside the OmegaT application bundle. This is definitely a neater solution, but will have to be repeated every time you upgrade OmegaT, unfortunately.

Here’s a screen capture to show you how it’s done. The green blobs are left-clicks, and the expanding circles are right-clicks.

Thanks, Jean-Christophe.

How to add your Google API key to info.plist in OmegaT

Posted in Hacks, Translation | Tagged | 1 Comment

QR code failure

QR codes are continuing to grow in popularity across Europe and the United States, according to a report by 3G Vision (Global Growth in Mobile Barcode Usage – Q2 / 2011). I’ve been suggesting for a long time that it might be worth adding one when you get your business card translated into Japanese. Well now it seems that you should maybe have one on your English business card already.

On a related note, last weekend’s newspaper carried an advert for the 20th anniversary edition of Nirvana’s groundbreaking album Nevermind:

It might not look like it, but that yellow blob at the bottom right is a QR code. Unfortunately the designers of this advert have mangled the thing up so much that it’s unlikely anyone will be able to scan it successfully. The inventors of QR codes (a Japanese company called Denso Wave) clearly state in their specifications that codes should be surrounded by a clear margin of at least four dot-widths (or “modules”). Without this margin, your scanner will probably be unable to locate the QR code at all, let alone decode it.

To make matters worse, the designers have also pasted a doodle of a stoned-looking smiley face right in the middle. Although QR codes are capable of withstanding a certain amount of degradation before they become unreadable, this really isn’t going to help.

Here it is, anyway. Let me know if your mobile manages to decode it. Hey, you might even win something. Apparently.

Posted in Miscellaneous | Tagged | Comments Off on QR code failure

Moving house (part 2)

We have now arranged the purchase of another house in Exeter. Unfortunately we won’t be able to move in before the end of the temporary lease on the house where we are currently staying. So from Thursday 25th August, we will have another temporary address, which is as follows:

48 Polsloe Road
Exeter
EX1 2DS

If you need to contact me by telephone, please use the mobile number: +44 (0)754 683 1591.

Posted in Miscellaneous, Moving house | Tagged | Comments Off on Moving house (part 2)

Inside the Hiroshima Peace Memorial

The Genbaku Dome (原爆ドーム) in Hiroshima (photo: Michael Helmer)

One of the unmistakable features of the Hiroshima skyline is the shattered remains of the dome structure at the top of what used to be known as the Hiroshima Prefectural Industrial Promotion Hall. This building lies almost directly at the hypocentre of the atomic explosion that devastated much of the city 66 years ago yesterday (August 6th 1945).

Today, the locals call it the A-bomb dome (原爆ドーム; genbaku dōmu), although it is now a UNESCO World Heritage Site and is officially known as the Hiroshima Peace Memorial (広島平和記念碑; Hiroshima heiwa kinenhi).

The building isn’t normally open to the public, so can only be seen from the outside. However, Google Japan announced on Friday that they had added the site to Google Maps (Google 日本 Blog; Japanese only). So now you can take a virtual walk around the ruins whenever you like.

Posted in Miscellaneous | Tagged | Comments Off on Inside the Hiroshima Peace Memorial

Downtime

The company hosting this website will be updating their network switches later today. As a result, this site will be temporarily offline between 23:15 and 00:45 BST tonight (22:15 and 23:45 GMT).

If you’re in Japan, that means the site will be unavailable between 07:15 and 08:45 tomorrow morning (August 3rd).

Apologies for any inconvenience.

Posted in Miscellaneous | Tagged | Comments Off on Downtime

Cat’s ears

The latest invention from Japan is a headset that monitors the wearer’s brain activity and moves a pair of furry cat’s ears to reflect what the wearer is thinking.

The product is called necomimi, which translates directly as “cat’s ears” (猫耳; ねこみみ). Its developers hope to have it on sale by the end of this year. Their website has all the latest news.

I have to admit I thought this was all a hoax when I first heard about it, but a recent news article on the BBC website has another video that shows the product being tried out by ordinary members of the public.

Posted in inventions | Tagged , | Comments Off on Cat’s ears


Header image: Snow covers the golden pavillion at Kinkakuji (金閣寺), a Buddhist temple in Kyoto. Photo: Frank Gualtieri.

Powered by WordPress