Localised resource files in VS2008

by dotnetpete 10. October 2008 14:12

I'm looking into internationalisation for a project we're about to start. There are a few articles on how to localise label text etc on windows forms. But what about error messages that are displayed to the user.

I created a new resource file calles Messages.resx and this created a "code behind" CS file that allowed me to access each of the string resouces in the file. Cool so far. Once I had a few message texts in the resource file I copied it a few times to Messages.fr-FR.resx for France French, Mesages.fr.resx for default French, Messages.nb-NO.resx for Norwegian etc. Each of these resource files also had "code behind" CS files but they were empty. 

I set my UI culture before loading my form in my static void Main method like so:

System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-FR"); 

And to my surprise when I called Messages.M001 (M001 was name of the message in the resource file), it would attempt to get the text for message M001 in my Mesages.fr-FR.resx file. How cool is that?

Also interesting if I set my UI culture to fr-BE it would try to receive the text from the Messages.fr.resx file as I didn't have a Belgium specific resource file.

Any advice or tips on how to handle internationalisation would be most appreciated too. 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Internationalisation | Culture

Add comment


 

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

dotnetpete

Hi I'm dotnetpete. I'm an owner and software developer at Advantech Software in Brisbane, Australia. My passions are writing great software and coffee.