As the web grows, more and more international businesses are turning to the web. The demand for a multi-lingual website has never been so great. There are currently a few pay services out there that offer a translation API and also a few free ones (Google and Microsoft). One of the services that I have been looking at recently is the Microsoft Translator service. The API has support for SOAP, AJAX and HTTP which is a great addition to the API.
In this example, we are going to take a look at the Translator SOAP API. It's really easy to use you get up and running in a matter of minutes. One of the great things I like about this service, is that you can add your own translations to the translation memory. This means that you can add your own self translated text if you prefer. Eventually this will keep on building and the service will improve over time. The API also allows you to choose your translated text based on a rating, which is useful if you are looking for accurate translations.
First, sign up for a BING appId. Once signed up you will need to use this appId in order to make any requests to the service. Sign in with your Windows Live ID and generate an application ID according to the instructions. So, keep it in a safe place and don't share it where necessary.
Let's start off by translating some simple text. You need to add a service reference in your project to the translator API. Right click on references in your project in the solution explorer and choose "Add Service Reference"
Then add the following address. We are going to call our Namespace "TranslateService".
I added another class to my project to wrap these methods around the Visual Studio generated code, but you could always call it directly - depending on your preferences.
I am calling these methods via unit tests, but normally this would go in your application code.
Call it and voila! We have our translated text.
Another great feature of this API is that you can request a WAV file with the translated speech. Once the method has been included in our project, you simply call it and it will return the URL of a WAV file containing an audio version of the text you requested.
I've only really touched on a few of the features, but adding translated text to your site based on the user preference could be a great addition to your site. This tool is a great starting point - hope this helped a little!
Add your comment