I have become obsessed with ColdFusion Builder Extensions. I am convinced that no other single feature of the IDE is as valuable as this. (And I love the rest of the features too, so I’m saying a lot here.) The ability to leverage ColdFusion know-how and features into tooling is awesome. A lot of the extensions we’ve shown off have been about code generation. I think that’s important, as it is big part of the Builder story. We make you more productive, but you make yourself even more productive. Of late though, I’ve been focused on extensions that do more than just generate code, they use ColdFusion capabilities in non-obvious ways. I’ll be posting them over the next few weeks.
Here’s the first:
I created a language translator that allows you to translate content in the editor window to other languages. As a first pass, it only does English, French, German, and Italian, but as I experiment I will expand them. To use:
- In the Editor window, highlight the content you want to translate
- Right-click it to bring up the context menu
- Choose Google Language Tools -> Translate
That should drop the translated content back into your editor, below the original content.
To build this I used a few different pieces. In the last Public Beta drop of ColdFusion we added the ability to grab highlighted content from the editor window in a ColdFusion Builder extension. I take that highlighted content and pass it to the server. On the server I pass it to a CFC that I wrote that consumes the Google Language API. It’s a JSON-powered webservice, so I used ColdFusion support for JSON to simply get at this data. From there, I can use a feature of ColdFusion Builder called “callbacks” to write the translated code back to the editor window. Specifically, I used the “inserttext” callback, which allows me to insert text at a specific line of code. I can use this to carefully place the translated text.
Possible use cases:
- Translating HTML content to multiple languages
- Translating code comments to your native language
- Creating language packs for your applications
Sound cool? Check it out on Riaforge: Google Language Tools Extension.