views:

3738

answers:

6

I am trying to localize a desktop app (C#) in VS2008.

I have mastered localizing the forms for multiple languages and I also have a project resource file for general strings but I cannot fathom out how to create multiple language versions of this file!

It doesn't seem to be documented anywhere.

The consequence seems to be that if I want to produce, say, a German version of my application I have to edit the general resource file (Properties/Resources.resx), build and deploy the application, then re-edit the general resource file back to English.

Every time I want to produce a new German version I would have to do the same. This seems so clunky compared to the tools for localising forms that I am sure there is a better way in VS2008. Does anyone know what it is?

+1  A: 
MadKeithV
A: 

Thanks - I'll investigate that, but at first glance it isn't quite what I was hoping for. Is this a big hole in VS2008?

A: 

Actually Visual Studio has this built in. On your form you wish to localize for a language change the property Localizable to true.

Then change the Language property to the language you wish to set up a resource file for. In your case, choose German.

Change all the text on the form to the German text. This will create an additional resx file for each language you change the Language Property too.

Once you finish you can change to another language for another translated form resource file or switch back to default.

Now when the computer is run on a machine set up to use a different language it will look for a resx file to match and switch all the controls to use the text provided in the resource file.

You can also test this by changing the CurrentUICulture on the CurrentThread

Here is a nice walk-through on MSDN as well: http://msdn.microsoft.com/en-us/library/y99d1cd3(VS.80).aspx

KMessenger
A: 

That's fine for forms (see my original question - I already have it in place) but it's no good if you want to have general purpose string resources because if you add them to the form resource files they get removed whenever you change to a new language or modify the form. You can only use the form resource files for properties of the form and its controls.

What seems to be missing is an easy way (or just a way) to have multiple language versions of the project resource file.

+1  A: 

You're right, I misread the question.

In that case what you might want to try is add a new Item to the your project, or you add an existing copy of your existing resource file just might have to rename it first outside VS.

Choose "Resources file"

Name it Resource.de-DE.resx

Once it it created you can move it the Properties folder.

Open the file, change the access modifier at the top to internal, it will be set to "No code generation"

Add your strings with the German translations to the new resource file

Compile and when the language or thread UI culture changes it should use the correct values from the language resource file.

My quick little test worked fine and switched as desired.

KMessenger
A: 

I have the same problem too! But the only way I could overcome this, was to add some labels in my form and add strings in them. Then set the visible property of them to false. And for each form, just use their text property! Sounds foolish but at least it works :D

screw good practice
alfred barthand