5

是否可以在 Windows 窗体应用程序中使用不同语言的 resx 文件,就像在 Web 项目中一样?

我认为您可以设置线程的文化,它应该从正确的文件中读取。

我遇到的问题是如何在 Visual Studio 2008 中为每种语言创建文件,感觉我缺少一些非常简单的东西。

谢谢

设拉子

4

2 回答 2

10

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.

于 2009-10-26T18:39:22.353 回答
2

Just add a resource file and change its name to have the language short name. For example, if the default is Resources.resx, for a resource for Hebrew, the resource will be named Resources.he.resx and for German it will be named Resources.de.resx.

于 2009-10-26T18:37:52.450 回答