Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String resource file naming schemes and management [closed]

A trivial question perhaps, but I'm interested in the answers. I'm currently refactoring some very large monolithic string resource files (one dumpster resource file per project, in about 30 projects). I'm splitting them such that we follow a convention for our files and make the strings easier to find and manage when coding.

Generally I'm splitting the files into this scheme:

  • ErrorMessages.resx
  • LogMessages.resx
  • ViewResources.resx
  • AppResources.resx

I'm not terribly thrilled with the naming, and I'm just wondering what other people use. For example, instead of AppResources (strings for internal use by the application), I've seen a lot of demo projects use StringResources, Internal (terrible!), etc.

Ideas/anecdotes/suggestions on managing resources or standard naming schemes are appreciated.

like image 670
womp Avatar asked Apr 22 '10 17:04

womp


1 Answers

I generally structure my resources like this:

The first resource file is used by the entire application (e.g. Project.Core) and does include all sorts of widely used common strings. I actually don't make any difference between errors/exceptions and logging:

  • CommonResources.resx
    Access modifier: Public
    • Error_Context
      e.g. Error_ArgumentCannotBeNull
    • Warn_Context
      e.g. Warn_ApplicationSettingNotFoundUseDefault
    • Info_Context
      e.g. Info_UpdateAvailable
    • Validation_Context
      e.g. Validation_EmailNotValid

The second resource file is used by the presentation layer and contains all sorts of UI strings. The naming can vary from project to project but generally it looks like the following schema:

  • PresentationResources.resx
    Access modifier: Internal
    • Common_Context
      e.g. Common_Yes
    • Section/Controller_Window/View_Context
      e.g. Help_FAQ_HeadlineHowToUseResources or Help_FAQ_TextHowToUseResources

Finally every project/assembly does also have an internal resource file for Error/Warn/Info/Validation resources that are too specific to go in the CommonResources.resx file. I have to admit, that I mostly name this resource file InternalResources.cs ;)

  • InternalResources.resx
    Access modifier: Internal
    • Classname_Error_Context
      e.g. BCrypt_Error_InvalidSaltRevision
    • Classname_Warn_Context
    • Classname_Info_Context
    • Classname_Validation_Context
like image 75
Martin Buberl Avatar answered Oct 05 '22 03:10

Martin Buberl