0

I've got an MVC application which does use some custom routing:

{Customer}/{Entity}/{Action}

The {Customer} route variable could be understood like the localization variable. I'd like to change the labels on the views according to the value in {Customer}. This means for Customer1, Field1 is labeled Username and for Customer2, Field1 is named LoginName. (example doesn't make sense, but should show the requirement).

How can I achieve the desired result? I started with creating two resource-files Labels.Customer1.resx and Labels.Customer2.resx but don't know how to enable these in the view.

By the way, I'm NOT using the razor-engine.

Thanks!

Charles
  • 50,943
  • 13
  • 104
  • 142
stromflut
  • 186
  • 1
  • 9
  • 1
    are you looking to extract what the route variable named `{Customer}` is? `/foo/bar/baz` get's `foo`? `/a/b/c` get's `a`? – Eonasdan Dec 12 '12 at 16:24
  • Normally resource files are based on languages? Setting the Thread.CurrentUICulture to the culture specified in the resx would use that cultureinformation. – AntonR Dec 12 '12 at 16:30
  • no, I'm extracting the {Customer} at several points of the application, that's not the point. I'm wondering how to use resource-files for the problem which is not actually regarding the currentUICulture... – stromflut Dec 12 '12 at 16:59

1 Answers1

1

The links I am adding below show how to use resources files and how to use the values inside them to replace the label's values in order to change a different value according tho the resource file you have chosen.

According to this you can create a property where you can set the current resource file. Once you have set the current resource file you can call the values for each label from there

http://www.4microsoftsolutions.com/post/AspNet-Globalization-and-Localization-using-Local-Resource-files-and-Global-Resource-files-.aspx

Loop through all the resources in a .resx file

Community
  • 1
  • 1
Claudio
  • 11
  • 2
  • not that easy to implement. looks like it's quite impossible the way I want this. My solution: I am going to create a dedicated class just for providing the view with strings, dynamically loaded from xml-files. – stromflut Dec 19 '12 at 15:48