The Transliteration Component in YUI


Some posts ago, I was describing a greasemonkey script that I had written to enable transliteration of the roman script to Indian languages. It leveraged the service called Quillpad. However, it was still greasemonkey, and was not really wide spread. For websites to plugin this components of transliteration, a lot of work still remained to be done.
I was thinking of writing a Javascript Component that when included would bring in the capabilities of transliteration right away. That was when I heard Chris Heilmann talk about the YUI Rich Text Editor (RTE). Though still in its beta, the architecture seems great, allowing pluggable functionality, something that is a must for an editor. Our team at the Yahoo picked this up to create a hack for the hack day. I was hacking up the JavaScript part, while Anishek and Srithar wrote the proxy for quillpad.
Some of the changes that the quillpad guys made included sending individual words instead of sentences, and throwing the 500 internal server error on sending trailing spaces. Thus, the backend proxy had to separate the words, remember the special characters between the words, call the quillpad service to do the transliteration, add the special characters properly back to the words and send the result back.
On the front end, I had to add an extra button to the "insert" button group, and on clicking it, send the selected text up to the server to get the transliteration. I did have some time to fetch the selected text as there were no public JavaScript methods in the RTE that did this. Investigation revealed a method called _getSelection(). There was also a private variable called _select, but that seemed more like a buffer to hold the current node that was selected. A little experimentation, and I got the selection up and working.
That was it for the hack day, but I am now also working on it to tranliteration of the text as I type. This would make getting an Indic interface link in Orkut (Ctrl+G) or the hindi blogger interface easier into a website.