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
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
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.
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.
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.
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'.