Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use resx files for different languages in a windows forms application?

Is it possible to use resx files for different languages in a windows forms application, the same way as in a web project?

I think that you can set the culture of the thread and it should read from the correct file.

The problem I am having is how to create the files for each language in visual studio 2008, feel like there is something very simple that I am missing.

Thanks

Shiraz

like image 924
Shiraz Bhaiji Avatar asked Dec 23 '22 08:12

Shiraz Bhaiji


1 Answers

You need to include a resource file for each culture you wish to support. These are added to the project in the same location as the main resource file, and must follow a strict naming convention.

The name of the resource file needs to include both the country code and language, for example:

  • Resources.fr-FR.resx for French (in France)
  • Resources.fr-CA.resx for French (in Canada)
  • Resources.es-ES.resx for Spanish (in Spain)
  • Resources.es-MX.resx for Spanish (in Mexico)

However, if you know that you don't need to support regional variations in a language you can just name the file with the name of that language:

  • Resources.fr.resx for French
  • Resources.en.resx for English
  • Resources.es.resx for Spanish

It will depend on how important it is that you localise for each country and/or how upset your users will be if they see the "wrong" text (e.g. color/colour etc. for US English/UK English)

See here for a list of culture codes.

NOTE: I've not had a chance to verify the code, but it looks complete.

like image 194
ChrisF Avatar answered Apr 07 '23 19:04

ChrisF