Miles
Miles

Reputation: 5736

Multilingual Winforms in .Net - opinions and suggestions

So I've got a program that needs to be multilingual. The only difference between what I'm needing and what I've found on the web is that all the computers my program will run on are set to the localization of EN.

We have spanish speaking employees that will use the program just like the english speaking employees. So I won't be able to set something up based on the localization of the computer, it'll all have to be done in code.

I was thinking of trying to create an XML file (really just a dataset) for every form that I have and having each data table be a selectable language. In each table, it would have the information (control name, property, and text) to set the labels/checkboxes/etc that it needs to. I'll have to create a new form control so that I can have a generic function to go through and rename all of these controls if possible.

<DataSet>
   <English>
     <ControlName>labelHello</ControlName>
     <ControlProperty>Text</ControlProperty>
     <Text>Hello</Text>
   </English>
   <English>
     <ControlName>labelBye</ControlName>
     <ControlProperty>Text</ControlProperty>
     <Text>Bye</Text>
   </English>
   <Spanish>
     <ControlName>labelHello</ControlName>
     <ControlProperty>Text</ControlProperty>
     <Text>Hola</Text>
   </Spanish>
</DataSet>

Also I didn't know much about the strings in the resources file for each form. Could I do it from there and use .Net functions to achieve this?

So I'm up for lots of suggestions because I really don't want to go back into the program I just wrote and put this in, I hate going back and adding more functionality once I've already spent so much time with this sucker...

Thanks

Upvotes: 2

Views: 1837

Answers (3)

Binary Worrier
Binary Worrier

Reputation: 51719

With Windows you can have a machine culture EN, but for the browser, individual users of the PC can select prefered cultures (IE & Firefox anyway). Everything else on PC is english In IE, go to tools, Options, click the language button on the general tab. You can specify a prefered hierarchy of languages.

Otherwise go with Joes answer.

Upvotes: 0

GregUzelac
GregUzelac

Reputation: 472

It is a pain, but its not hard. Within VS2008's WinForm designer, select the form, view its properties and set Localizable=True (if you view the partial class/code behind file you will see a new line that looks something like

  resources.ApplyResources(this, "$this")

Then, for each locale you want to support, select Language, and localize any changes needed over the Default local.

I believe Windows allows the user to specify a different locale for a specified application. I last tried this with Windows 2000.

Upvotes: 1

to StackOverflow
to StackOverflow

Reputation: 124794

You can set the culture you want in code, e.g.:

Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-ES");

See this MSDN article for more info.

Upvotes: 2

Related Questions