asp.net mvc 3 - How to implement custom resource provider dependent on different criteria than UI culture? -


i working on .net 4.0 mvc3 web application. application in english , allows users fill information regarding different regions. simplicity let's have 2 regions: united states , western europe.

now in view present string let's project opening, if user works on region united states read project initiation.

when think functionality think resource files different regions, independent ui culture.

does have recipe how achieve want?

would nice, if in future make read e.g. extendeddisplayattribute(string displayname, int regionid) placed on properties of viewmodels.

edit

i @ stage can access region information in helper should return string region. have problem resource files. want create multiple resource files failover mechanism. expected there working out of box, resourcemanager cannot used read resx files.

is there technique allow me read values specific resource files without non-sense resgen.exe?

i not want use system.resources.resxresourcereader, because belongs system.windows.forms.dll , web app.

just in case wants same in future. article turned out helpful: http://www.jelovic.com/articles/resources_in_visual_studio.htm

the piece of code use (vb) is:

<extension()> public function resource(of tmodel)(byval htmlhelper htmlhelper(of tmodel), resourcekey string) mvchtmlstring     dim regionlocator iregionlocator = dependencyresolver.current.getservice(gettype(iregionlocator))      dim resources = new list(of string)     if not string.isnullorempty(regionlocator.regionname)         resources.add(string.format("website.resources.{0}", regionlocator.regionname))     end if     resources.add("website.resources")      dim value = string.empty     each r in resources         dim rmanager = new system.resources.resourcemanager(r, system.reflection.assembly.getexecutingassembly())         rmanager.ignorecase = true          try             value = rmanager.getstring(resourcekey)             if not string.isnullorempty(value)                 exit             end if         catch          end try     next      return new mvchtmlstring(value) end function 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -