How do you organize your resource files?

We're looking to use resource files (.resx) in an ASP.NET app for storing localized values. There may be thousands of strings in total across the site which we'll want to store.

Is there a best practice for organizing values in to one or more resource files? Do you keep all values in one file? Do you separate in to multiple resource files based on subject matter? Perhaps there's a common resource file for the site's common values ie "Ok", "Continue", etc?

It seems storing all resources in a single file will be overbearing for maintaining.

Any suggestions?


Yes, one single file seems like a bad choice in a moderately-sized app or bigger :-)

We basically use this approach:

  • each webform has its own local resources for buttons, labels and so forth
  • there are a number of global resources, organized by topic - eg a "general" resource for things like "yes", "no", and so forth; one for error messages that keep popping up all over the place, and so forth - a few global resources based on area of use
  • any other code (more business code rather than ASPX/ASCX code behind) has their own resource files
  • It's always a balancing act between having hoodles of files vs. having files with way too many entries, though :-)

    Marc

    链接地址: http://www.djcxy.com/p/42378.html

    上一篇: 动态创建的DropDownList在Postback上丢失了ListItems

    下一篇: 你如何组织你的资源文件?