views:

68

answers:

4

What is the best way to make my C#/WPF application support different languages?

I want to be able to give my users the choice to choose a language.

Thanks

A: 

How much text are we talking, here? You could always just use case statements that checks a language variable and places the appropriate language then, but this will turn into a mess if you've got a TON to replace.

In response to your comment:

Realize that this may not be the best solution, as I'm not familiar with the built in support with .NET.

You can simply keep a variable that contains the language, for example, strLang, and when you're placing text just have your program run a case statement to output the proper language.

Switch (strLang)
{
 case "EN":
 //OUTPUT ENGLISH TEXT HERE
 break;
 case "SP":
 //OUTPUT SPANISH TEXT HERE
 break;
}

As you can see, it can really clutter your code depending on the number of languages and the amount of text, so you may want to check out the book Randy suggested.

Eclyps19
It's not a complete ton, a few pieces of text here and there, can you explain how I would do all this. Thanks.If you want an idea of how much text we're talking about you can look at the app here:http://sinvise.net/preRelease/b1/Shutdown%20Timer%203.0%20Alpha%20x86.rarThanks
Sandeep Bansal
Thanks for the sample, I reckon using a case statement is a way, but it also creates a heck of a lot of code.
Sandeep Bansal
Which is why I'm hoping others have a better answer for you :) Best of luck!
Eclyps19
+2  A: 

There is a lot of information to digest, but the .Net framework has built in support for Internationalization

I wish I could give you an easy example, but it is not a "drag and drop" solution. You will need to put a lot of thought into how you design your application for this.

Josh
Thanks. The resources idea makes sense. I'll try it out first thing tomorrow.
Sandeep Bansal
A: 

Pick up the following excellent book: .NET Internationalization by Smith-Ferrier. One of my next projects will be to internationalize our applications. This is going to be my guide.

Randy Minder
A: 

How about tokenising the strings you are going to use in your application and then have separate language files which are then loaded in at runtime?

E.g. on my form I want to show 'First Name' in different languages, so it's stubbed with the token "firstnnamestring" and when the form is being loaded I'll replace the text with whatever's configured in the languages file depending on the current language.

The language files can be simple XML with key value pairs of 'token' and 'display text'.

theburningmonk
This was something I was actually looking at! Would you be able to provide some sample code on what you did to make it identify the values? Thanks
Sandeep Bansal