views:

287

answers:

2

Today I'm playing with localization. I have a winforms app where I've set localizable to true on my screen, then I went and converted all the text to spanish as best as I could. So now I have my screen.resx and my screen.es.resx and everything looks good/bueno. How do I now run my app and have the spanish version come up? I tried going into regional and language options and setting my 'standards and formats' option to spanish. Now my dates are in spanish which is good, but the text on my app is still the english version. How do I get this thing to load with my screen.es.resx?

+2  A: 

did you set your applications Culture / UI Culture to Spanish? In following code, en-US will be replaced by ur UI culture and it will use appropriate resx file depending on the way u have them up

HTH

System.Globalization.CultureInfo myCI = new System.Globalization.CultureInfo("en-US", false);
System.Threading.Thread.CurrentThread.CurrentUICulture = myCI;
System.Threading.Thread.CurrentThread.CurrentCulture = myCI;
Suneet
A: 

You control which language resource that are used by setting the CurrentUICulture of the current thread. You will most likely also want to set the CurrentCulture (that controls number and date formats and such) (C# code):

// the following using statements must be present
// using System.Threading;
// using System.Globalization;
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("es-ES");
Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture;

For a more detailed discussion on the difference between CurrentUICulture and CurrentCulture, there is a blog post by Michael Kaplan on the topic.

Fredrik Mörk