Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 23, 2011 03:49 PM by MikeSW
Jan 19, 2011 09:15 PM|LINK
Hi. I been looking for hours on the web to find a good tutorial where I can do a database localization with mvc 2, I can't find any its all resource files. So I'm trying to reach out to you guys and see if you got any links, books or suggestions on this
topic? I would love for it to be url routes based localization but that I can figure out somehow i think. Thanks
Jan 20, 2011 03:52 AM|LINK
Jan 20, 2011 08:23 AM|LINK
Thanks Raduenuca, but this was not really what im looking for, for the moment i think i got the url routing problem done with /en-US/Site.. What seem impossible to find is the database tutorial. Why is there not a mvc/omr example of this out? its a pretty
common task people would use and from what i seen a lot is wondering about it.
Jan 20, 2011 08:42 AM|LINK
If you look for examples using databases and EF with mvc there are a lot, but this has nothing to do with the localization problem. Localization is done with the help of resource files. Please specify better the features of the example you need(just list
Jan 20, 2011 09:55 AM|LINK
Hi Franesco. Like i described in my first post I'm looking for a way to handle localization through a database and not resource files, i know it can be done i seen it but there are no good examples of it that i can find. So im looking for - Database localization
for a asp.net mvc 2 project - entity framework 4 or nhibernate as OMR
Jan 20, 2011 01:27 PM|LINK
If you want to use database for localization, just use anything (EF, plain old ADO.NET, nHibernate etc) that you would use to query database based on what incoming culture information you got from the client.
Am I missing something here?
Jan 20, 2011 02:04 PM|LINK
Hi sachingusain I get that but how do you go about making it work so the localization gets the info from the database and use it, instead of the resource file? thats where the problem is.
I got no problems no problem with handling EF or Nhibernate but that has nothing to do with this matter except that is what I would like to use for it. It is how to kinda connect the resource database to the localization part that is the problem. There are
a lot of tutorials on how to use resource files but no good one with database. so that is what Im looking for..
Jan 20, 2011 02:14 PM|LINK
Refer to this post from Scott:
Within that you can see: "Jeff Modzel recently published an article that shows how to build a custom Resource Provider that stores the resource strings in a database instead."
Refer that article and you can go from there. Note that even if the article would say ASP.NET, I am sure this can be done in MVC too without constraints (with some tweaking, ofcourse).
You can also refer to "Extending the ASP.NET 2.0 Resource-Provider Model" article here:
Again, it might refer to ASP.NET but you can do it in MVC too.
Jan 20, 2011 04:31 PM|LINK
I think @sachingusain gave you the solution. I add just that localization is not specific to either Asp.net, Mvc or windows form but is a general .Net concept, so any example dealing
with localization with db is ok. The only peculiarity of MVC that, however is common also to Web Forms, is that you can set the currentUICulture simply by setting it in globalization section of the configuration file a fixed culture or "auto" in which case
MVC or web froms will do culture autodetection based on information sent by the browser. Autodetection is a good starting point, then you can redirect the user to a culure specific url that set always the same culture. Obviously it is convenient to give also
the opportunity to change culture manually.
Don't forget also of globalization of date and numbers....To handle them properly in client validation there is some job to be done...it is not automatic.
Jan 23, 2011 03:23 PM|LINK
Thanks for the links. I found that the other day looking but I thought it was a bit complicated (or maybe I made it complicated?). Anyway I'll try this out today but if anybody got sample code they would love to share that would be awesome and welcome.
Thanks agin this place rocks