ASP.NET - MVC 3: Localization

前端 未结 2 911
梦如初夏
梦如初夏 2020-12-12 22:48

I am about to implement localization for my MVC3 web application. Googling my way through large amounts of ways to do it, I was left unsure which way to implement this. I fo

2条回答
  •  醉酒成梦
    2020-12-12 23:18

    I've come up with an easier way to handle localization where you don't have to use resource files or attributes. It involves custom metadata providers.

    MVC3 uses metadata providers to get all text strings. My approach allows you to either use string tables, a database, flat files or any other source to provide the translations. All you need to do is to inherit two interfaces.

    Read about it here: http://blog.gauffin.org/2011/09/easy-model-and-validation-localization-in-asp-net-mvc3/

    Edit

    Everything is now documented at github and there are nuget packages: https://github.com/jgauffin/griffin.mvccontrib

提交回复
热议问题