Icon.pngI’m happy to announce the results of a few hours of tinkering: The Pinyin Tone Widget. This OS X dashboard widget will take a series of Chinese pinyin words with tone numbers appended at the end of each syllable and will add the tone marks where appropriate (e.g. zhong1guo2 becomes zhōngguó).

Many years ago, before Unicode became dominant, I used a Microsoft Word macro written by a Chinese language scholar, James Dew, as the basis for making an old Mac OS 9 application that translated texts between various pinyin fonts that were floating around online. Later, I made an online script that could convert tone numbers into unicode tone marks. I was surprised to hear from various Chinese language instructors at a conference I presented at a few years later (2003) that many of them used the script regularly when preparing texts for their Chinese language classes.

The online script still works but there is a much more elegantly written online script which does the same thing written by a more skilled programmer in Taiwan named Mark Wilbur hosted on his site Doubting to Shuō. You can find his tool here: Pinyin Tone Tool.

My old PHP script is ugly by comparison to Mark’s compact javascript so I have essentially installed his script to work in an OS X dashboard widget. You can download the widget here:

Pinyin Tone Widget v. 1.02

To use it, just enter the pinyin into the large text field and press the “Add Tone Marks” button. It will add the tones and select the resulting text so you can copy it for use elsewhere with Command-C.

mockup.gif

If you like the widget and find it useful, send your thanks to Mark at doubtingtoshuo at gmail.com.

This was my second Dashboard widget. The first was the 檀紀 Conversion Widget that students of Korean history may find useful when reading newspapers and documents from the days when Korea used that calendar more frequently. I really love the free Apple development environment for creating these widgets called Dashcode, which comes with the developer tools for OS X. You just need to know a little javascript and you can be up and running with your own widget.

Next time I need a distraction I hope to create another widget which changes romanized Korean text using “eo” or “eu” into ŏ and ŭ. I won’t be writing a full tool for conversion between McCune-Reischauer and the new government romanization system, which is a pain, but some of us when writing romanized Korean words prefer to keep using the McCune-Reischauer system but have trouble creating the ŏ and ŭ easily directly from the keyboard.

Another calendar widget is in the works too, one for Chinese dates that will convert Qing (I am too lazy to go back further) and republican period calendar years into the Western years, and another for Japanese years that will convert Meiji, Taisho, Showa, and Heisei years via a widget. Anyone who wants to add older imperial reigns can modify the resulting widget when it comes out.

UPDATE: I have updated the widget and changed two things: 1) I saved it to be backward compatible with 10.4.0 instead of 10.4.3 and 2) I changed it so that if you press enter, it will trigger the button for conversion.

UPDATE: None of the widgets I make seem to be compatible with OS X 10.4.11. I’m not sure why but there were some things changed in 10.4.3 regarding dashboard widgets. If you want to upgrade your OS to 10.4.3 then you first need to upgrade to 10.4.2 and then 10.4.3, both of which are free upgrades.

UPDATE: 10.4.11 is a newer version than 10.4.3 - the newest Tiger has to offer (it was 11 as in after 10, not as in after 1 but before 2, my bad). So I guess my widgets are doomed to only work on Leopard. That is lame! Still have no idea why this is…also happened with the calendar widget I just made with far less and different code.