3

In my current project, on the main page I can switch language (FR|NL|UK).

All the texts are in ressources (.resx) files. The language code (FR, NL, UK) I need to use is in myMode.

How can I do to set all the : @HTML.Label( ....)

Thanks,

2 Answers 2

9

When you change language you need to change the current UI culture. You also need to track the user language preferences somewhere (route, cookie, session, ...). Here's a nice guide that I would recommend you reading.

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

5 Comments

I prefer not play with UI culture, I'd like depending of Language variable in my model get a value from the ressource file
@Kris-I, in this case you could set the current UI culture only for the current request based on the value of your model. You could do this in the controller action that is supposed to render the view. This way only the current user and for the current action will get a localized version. You are not persisting it.
And the syntax @HTML.Label .. ?
@Kris-I, you could use a custom helper: thinkingguy.net/2010/01/…
+1 for that link. With a bit of tweaking it is very powerful (slightly broken route mapping in the example).
0

I agree with the previous answer, that you have to change the current UI culture. On drop down change, you can store the language in cookie. And then using this cookie you can set the current UI culture. Depending on the culture, the application will pick up text from resource files depending on language selection.

Comments

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.