Wednesday, January 9, 2008

Language Translation and Currency

Our newest client continues to demand things we don't yet do with WorkXpress. This time, it's language translation and currency conversion.

They are a company that works with people in Europe and so they have a need to know how many Euro's $200 converts into at any given moment (since the exchange rate changes every second), and they need to know what those comments mean that were faxed into them from overseas.

Currency Conversion : Web Services to the rescue!

The problem with telling someone that $200 is 174.78 EUR is that this minute that is true,but th next minute it might be 173.99 EUR. So, as a programmer the challenge is figuring out how to lookup the rate, in real time.

Conversion basics :

1 USD = 0.7544 EUR (Euros) at this moment.
So, if you have USD's, then $rate = 0.7544

$new_amount = $amount * $rate;

Simple enough. Now, for my next trick : I'll find an accurate place to get the rate!

You can pay $200 a day for it : http://www.oanda.com/site/converter-intro/ccc_intro.shtml

Or, you can pay $40 a day for it : http://www.xe.com/sitemap.php

Or, you can get it for free! : http://www.webservicex.net/WS/WSDetails.aspx?WSID=10&CATID=2

All of these are SOAP Web Services, which with one SOAP call will give you the up-to-the-minute currency exchange rate. But, how good is the free one?

So, I setup 4 Tabs in Fire Fox. One that showed the rate of USD to EUR on all 3 of these web services, and the 4th was Yahoo! Currency Exchange. Then, every minute or so, for 15 minutes I hit refresh on all 4 tabs, and compared the rates. They were the same... across the board!

So, I decided to use the Free one :-)

Language Translation : There's got to be a webservice for that, right?

The short answer here is : there used to be! BabelFish used to provide their translations through web services, but apparently it caused them big load issues, with no benefit ($) to the company. So, they shut down their web service, which also shut down every other translation web service, since it seems they all actually used babel fish :-)

So, I had no luck finding an actual web service that did this. I did come across the "Unofficial Google Translate API". Which is a simple post, and screen scrape setup of Google's Beta Translation service.

So, while not a SOAP Web Service, it does provide real time translation that I was able to integrate into WorkXpress using AJAX.