Explicit localization

Last post 05-09-2008 9:54 AM by Nocker. 2 replies.

Sort Posts:

  • Explicit localization

    05-08-2008, 5:19 PM
    • Loading...
    • Nocker
    • Joined on 05-08-2008, 5:04 PM
    • Posts 2

    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 Big Smile) 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?
    Filed under:
  • Re: Explicit localization

    05-09-2008, 2:06 AM
    • Loading...
    • gyan_flip
    • Joined on 04-25-2008, 11:08 AM
    • Baghi - Bhojpur - Bihar - India
    • Posts 49

    What is the error you got?

    Gyan
  • Re: Explicit localization

    05-09-2008, 9:54 AM
    • Loading...
    • Nocker
    • Joined on 05-08-2008, 5:04 PM
    • Posts 2

    No errors. The code runs, only that it ignores the language change. I already traced that the code actually gets the language code. But the changes are being ignored.

    This code runs at controller level, before any other controller logic.

Page 1 of 1 (3 items)