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!

3
  • 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? Commented Dec 12, 2012 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. Commented Dec 12, 2012 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... Commented Dec 12, 2012 at 16:59

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.