Click here to Skip to main content
Click here to Skip to main content
Go to top

Auto Translate and Synchronize Resources in Your .NET Applications

, 14 Jun 2009
Rate this:
Please Sign up or sign in to vote.
Auto translate and synchronize is a little utility application and it works by simply taking your single fallback resource file (Resx) as input and automatically translates it in real time, creating a language specific resource file.

Introduction

Creating multilingual applications while being easy and improving greatly with each version of the .NET Framework, making the translations or replicating your fallback resource file across languages is a daunting task.

What happens is during the development of your application, you create key/value pairs in your .resx files, one at a time. This is not difficult, and VS.NET has a pretty good editor for resx files right there in VS.NET design environment itself. So far, so good.

It starts getting problematic later on when you now plan to create a resource for the 2nd, 3rd, 4th... language, you find yourself manually duplicating the resource file, renaming it and then editing the values to the new language.

That is the first problem, manual replication. The second problem is synchronization. Now that you have more than 1 resource file, e.g.: resources.resx, resources.en-US.resx, resources.it-IT.resx, etc. you are going to have to keep them in sync. So if you add a new key/value in your main resource file, you are now responsible to see that this key along with the language specific value is replicated across all your resources.

This is indeed a problem. AT&S is a little utility application written in WPF, and it's goal is to address both these concerns. This has been so much of an issue for me that as you can see, I ended up writing a utility application.

But yet again, I have a 3rd problem. The translation itself. I certainly do not have corporate backing and I do not have the monetary means to hire translators to make my application multilingual. Sure, I can do the Italian and English languages, but what about Japanese ? or Chinese ? Perhaps Hindi or Arabic ? mm maybe Russian ? This is a broader audience for me and yet I am unable to tap into that market.

The answer to all this is the recent online translator offered by both Microsoft and Google freely. This is fantastic because it may not be perfect, but I understand the translation perfectly and it makes sense. Not 100% but does it matter? It is better than nothing and it's free. Not to mention that if I really had the means, it would actually help reduce the task my translator will be doing now that half the job is done and the only remaining work is to make the necessary corrections to achieve a higher level of accuracy.

One issue I've had with the online translator is that I have key/value pairs, each value containing the data for the translation. And copying and pasting a value at a time via the online translators is not exactly how I want to spend my weekend and every weekend after that. In effect, both Microsoft and Google expose rich APIs to access their services which made it real easy to write a little utility application that interfaced with them and submitted the values for translation one value at a time in an automated manner. Perfect.

While this application is quite simple and consists of a single screen and 4 buttons, it's hard to not know what you need to do but let's simply walk through it.

Before you can use either Microsoft translate or Google translate, you'll need to signup with them for an application ID (Microsoft) / API Key (Google) and supply this to the application. Note below we are supplying our Microsoft application Id.

The Google API screen is identical.

After supplying the ID, you may very well select either Microsoft or Google as your translation service and begin. One thing to note is you also need to select your default resource file. All the translations and auto generated resources will be based on this.

Also if you do not want translation but rather you simply want to duplicate the resource into a language specific resource file, then you may very well select the "System" option instead. When this is selected, instead of performing translation it will replicate the resource naming it accordingly with the selected language.

The resource files are auto generated within the same folder as your fallback resource, the one you browsed to previously (read above). If you want to view the newly created files in Visual Studio, you'll have to select the folder and from your Edit menu (main menu bar in VS.NET) or from Solution Explorer title bar itself, select the "Refresh" Icon. You also need to have "Show all files" option in Solution Explorer enabled by default, if not enable it.

Next you might also want to right click the file and select "Add to project" from within Solution Explorer, that way it's added to your project. In short, bottom line is any file you add from outside Visual studio requires this as it doesn't know.

This application is available as a free download. You'll find it at http://www.jiffycms.net/autotranslatesynchronize.aspx.

There is no particular reason why the download requires a 30 second registration. I simply want to track usage and I want you as a member on my site Smile | :)  

Just kidding. No signup required. Go grab it.

History

  • 14th June, 2009: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Alessandro Zifiglio
Web Developer Typps.com
Italy Italy
I'm alessandro and currently run www.typps.com

Comments and Discussions

 
QuestionDl Impossible Pinmemberjeremy.valentin4-Mar-11 0:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 14 Jun 2009
Article Copyright 2009 by Alessandro Zifiglio
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid