Greetings,
I'm doing a project in MVC (the preview 2) and yesterday I did the localization. Choosing to do it via resources, I managed to quickly set up the translation (created the App_GlobalResources folder, put some named resx's there, put UICulture="auto" Culture="auto" in my @Page directives, called the texts via <%=Resources.Strings.name%> and presto!).
So far, so good, but now I'd like to explicity choose an idiom (because that's more web 2.0
) and I'm having troubles with this. What I did was to create an extra action in HomeController that gets an idiom code as id and saves it on session. (this is working) Then, I tried to use the following code, on all controller actions that needed to be translated:
1 if (session["Language.Code"] != null) {
2 string UserCulture = (string)session["Language.Code"];
3 if (UserCulture != "") {
4 Thread.CurrentThread.CurrentUICulture = new CultureInfo(UserCulture);
5 Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(UserCulture);
6 }
7 }
8 }
This didn't work and I'm trying to undestand why. Any ideas?