Back in April 2009 I wrote about the Microsoft Translator (aka the Bing Translator), the various APIs that it exposes and in particular the REST API that it exposes to allow the automation of translation. At the time I also added a Microsoft Translator class to the list of translator classes used in the tool suite for my book, .NET Internationalization. In this post I join the dots and show you how to make use of these classes and automatically translate your resx files to another language.
- Get your Microsoft Translator "app id" from http://search.live.com/developers/appids.aspx.
- Download the free source code for the book from here.
- Extract the source code to a folder of your choice.
- Open ResourceAdministration\ResAdmin\App.Config and change the "value" of the "MicrosoftTranslatorApplicationId" key to the "app id" that you were given for the Microsoft Translator.
- Build the source code by opening a Visual Studio command prompt in the folder that you extracted the source code to and running "msbuild BuildAll.proj". If FxCop is not installed on your machine there will be build errors but these are not related to the translation tools and you can ignore these.
- Connect to the internet (the Microsoft Translator needs an internet connection).
- In ResourceAdministration\ResAdmin\bin\debug you will find ResAdmin.exe. This is the Resource Administrator which is a developer tool for managing resources. Run ResAdmin.exe.
- You will see the following dialog. In the "Source of Resources" enter the base directory containing your resx files. In the "Invariant language" enter the language code that the original resources are in (e.g. "en" for "English"). Click OK.
- Next you will see the main form. You need to tell the Resource Administrator what language(s) to translate to. Select Tools | Languages and enter all of the languages to translate to (you should probably de-select Albanian at this point). Click OK.
- You will be asked if you want to automatically add the necessary resx files for the new language(s). Click Yes. At this point if "Automatic Translation" is on (see the status bar) the text in the resx files will be translated.
- The Resource Administrator tool uses a collection of machine translators to translate text where it falls back to other suitable translators if one fails. You can configure which translators are included in the list by selecting Tools | Translators.
Note that the Resource Administrator utility is not hard wired to use solely resx files. You can use the same utility with other sources of resources (including a database) by selecting Tools | Resources Source.
For more information on how to use the Resource Administrator see the .NET Internationalization book.