Getting localised resource for Models From Database in ASP.NET MVC
How to get Localized resourse for Model Data.
I have searched enough on web and getting examples for only getting resource from .resx file.
[Required(ErrorMessageResourceName = "LogOnModel_UserName_Required",
ErrorMessageResourceType = typeof(Resources.Global))]
[LocalizationDisplayName("LogOnModel_UserName_DisplayName",
typeof(Resources.Global))]
But I need to get from Database.
I have created my own localisation helper class but how to pass the HttConte开发者_运维技巧xtBase from Model. I am able to pass the context from Controller as well as View. But not in this.
Any help is greatly appreciated.
Thanks
My company has a little utility (written in house) which reads the data from a database and generates the resx files. The class used is ResXResourceWriter. See some of my other questions/answers for more information on using resx files within MVC2.
While I'm sure it's possible to read the resource strings directly from the database, do you really want that kind of a hit.
The solution we have gives us the flexibility of a web front end (again written in house) over some database tables (Our web from end makes performing translations nice and easy), but eliminates the potential performance hit that would be incurred with constant accessing of the database to retrieve the resource strings.
Hope That Helps.
精彩评论