开发者

Configurable Content System in ASP.NET

开发者 https://www.devze.com 2023-01-16 20:21 出处:网络
I need to design a configurable content system for all of the text in our web application that will tie together our need for Translation with the ability for Groups of users, Subgroups of users, and

I need to design a configurable content system for all of the text in our web application that will tie together our need for Translation with the ability for Groups of users, Subgroups of users, and single Users开发者_开发问答 to configure what a given label, Error Message, or piece of system text says.

Because everything needs to be configurable through the interface, resource files don't seem like the solution.

I don't expect to find something like this out of the box. How would you go about designing something like this, or what would you begin to configure in order to get this functionality?


I have achieved the type of functionality you are looking for by creating a database backed custom resource provider, and setting the <globalization> tag in the Web.Config to point to your custom provider. see: http://msdn.microsoft.com/en-us/library/aa905797.aspx

Then within your pages and code, you can refer to GetGlobalResourceObject or GetLocalResourceObject to get localized resources.

Whilst this is primarily designed for multiple languages, I have used it in combination with custom locale functionality to provide different labels, error messages and text to different groups of users.


Create a simple table along the lines of:

table Resources {
  language varchar(100)
  label varchar(100) /* you might consider a different key type, but this would be easiest on coding */
  value varchar(max)
}

You might simply cache the whole table on the web server to perform the look ups locally and simply expire the cache when a value is changed.

It's a relatively easy thing.

0

精彩评论

暂无评论...
验证码 换一张
取 消