Yesterday, I blogged about how you can use Google Translate to translate a string in C#. To make it more useful than just a simple translator, and because I need to translate some Global Resource files for an E-commerce website that I’m working on, I wanted to create a small Windows Application in C# that could read a Global Resource file (.resx) and translate it into a selected language using the method for translating a word in C# that i blogged about yesterday.
This is how it looks so far. You simply select the resource file you want to translate. Select the current language of the resource file in the middle box, and select the language you want to translate it to in the last box. Click Translate at it should work. The new resource file will be saved in the same location as the application itself.
« Translate text in C#, using Google Translate Migrate web.config to support the IIS 7 Integrated Pipeline »






Hi, I thought the same idea too about generating resx files for different languages using Google Translate but not sure how. It will be very helpful if you can post up the source code about the windows app that you are working on
You can download the app, including source code, through the link to my Sky Drive. At the bottom of the post – ResxTranslator.zip
Nicely done Martin, that certainly makes things easier getting started with translations. I have one suggestion though…in the Translator class, set the proxy credentials on your web client. Many corporations use a proxy server to allow access to the Internet.
Just one line in the using statement of Translator.TranslateText:
[b]webClient.Proxy.Credentials = CredentialCache.DefaultCredentials;[/b]
and it’ll use the current Windows credentials to pass to the proxy.
Thanks and great job!
Hey Chad
That makes a lot of sense. Thanks for your input.
Awesome!
Sometimes resources can contain images. But the working folder is different so ResXResourceReader throws an exception when trying to read .resx file (GetEnumerator). This happens if you have relative links to the image files.
The solution to this is to set the current working directory as:
using (ResXResourceReader rr = new ResXResourceReader(resxFilePath))
{
string outputFilePath = String.Format("{0}.{1}.{2}", Path.GetFileNameWithoutExtension(resxFilePath), toLanguageShortname, Path.GetExtension(resxFilePath));
[b]System.Environment.CurrentDirectory = Path.GetDirectoryName(resxFilePath);[/b]