Pinyin Tone Dashboard Widget

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.

17 thoughts on “Pinyin Tone Dashboard Widget”

  1. Very cool — I’d just been thinking to myself today how useful something like this would be, since as is I have to keep Wenlin open for all of my Pinyin-typing needs. Unfortunately, the widget doesn’t seem to be working on my computer — OSX 10.4. Is this one of those pesky Leopard-only features?

  2. Hmm…I think it needs OS X 10.4.3 minimum.

    do you have updates installed up to 10.4.3?

    I have just uploaded another “backward compatible” version that should work with 10.4.0 as well: widgetfor10.4.0.zip

    What happens when you try to load it? Nothing happens when you push the button?

    It is hard for me to test since I run Leopard…but I hope it runs on 10.4 as well.

  3. Works nicely, thanks! My only feature request would be to have it preserve capital letters at the start of syllables, for names and so on. Right now it changes everything to lower-case.

  4. Thanks for your kind words. I had been planning to make a Firefox plug-in of the tone tool, but I got busy with work and forgot about it. I’m glad someone found a way to make something useful with it.

  5. Weird — am running 10.4.11, but for some reason it isn’t working for me — the ‘Add Tone Marks’ button just doesn’t do anything.

    A random guess — is this using the ‘Web Clip’ thing? I think that’s a Leopard-only feature for widgets, though I could be wrong.

  6. Hey Brendan, I’m not sure why it isn’t working! I’m really sorry I don’t know how to fix that. It isn’t a web clip thing, just plain old Javascript…

    TenThousandThings: I will look into keeping the upper case – I’ll ask Mark if I have to make any major changes to the script to make it work without his making everything lowercase.

  7. TenThousandThings: A quick test shows that removing the command to make everything lower case works – I’ll ask Mark why he added that line and if there are no issues I’m overlooking I’ll update the widget to keep upper case.

  8. No worries — am going to be upgrading to Leopard soonish anyway, with any luck, so we’ll see if that takes care of it.

  9. I’m running 10.4.11 as well and neither the regular nor the backward compatible version work for me :(

  10. Strange…I don’t know what to say…It works here on Leopard…I wish I knew what was going on…

  11. Great! I just wish I could understand why it doesn’t work on 10.4 despite supposed compatibility being set up in XCode.

  12. What a great tool! Thanks so much for putting this together. I second the request for the “keep capital letters capitalized” feature though :)

  13. Here’s another nice tool developed by an international school in Beijing. It’s called PinyinMaker. It takes chinese text and converts it to pinyin and allows you to generate flashcards. http://pym.wab.edu

  14. thanks, for me it’s useful after a change from pc to mac using word for mac. just a pity it does not work integrated in word. thanks for your work :-)

Comments are closed.