locked
Please help with localization! RRS feed

  • Question

  • User798234430 posted

    Hi everyone!

    I've got stuck:

    I'm trying to make simple localizable site, but the point it's user who selects the language. Application shouldn't make any decisions depending on browser settings.

    All examples I've seen on MSDN or elsewhere use the auto mode of UICulture or just tell about the basics of localization system.

    I use local resources to store the translations. The task is: when a user presses some LinkButton, site should change its language.

    My solution was: on PageLoad (or on Init, tried both), depending on request parameters, set Session["lang"] = "en" (or other language I'm using). Then, I use this line (same here, tried both in Load and Init event handlers):

    Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo((string)Session["lang"]);

     This works, debugger shows, that everything goes where it should go. I even set the text of one label to CurrentUICulture and that works too, but...

    I don't see any change of language. Please help!

    PS. I use MasterPage to build this site, but neither masterpage nor child pages render with the desired language.

    Thursday, August 17, 2006 3:19 AM

All replies

  • User-503940700 posted

    Hi,

    Did you try changing the language settings in the Control Panel's Region and Language settings section?

    You have changed the culture of the current thread, but you need to change the OS settings too to display the UI settings in appropriate language.

    HTH,

    Vivek

    Thursday, August 17, 2006 4:27 PM
  • User798234430 posted

    No, the thing is that I do NOT want to automatically choose language. User must select desired language.

    And I found the solution yesterday, I just need to override the InitializeCulture() method of a page and write there culture initialization  :)

    Now, I need to know how to intercept event from some asp:LinkButton before InitializeCulture() runs.

    Any ideas on how to do that?

    Thanx 4 help

    Friday, August 18, 2006 3:21 AM
  • User-1330389549 posted

    Hi,

    My solution is to use

    <code>
    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(tMyLang)Thread.CurrentThread.CurrentUICulture = New CultureInfo(tMyLang)
    </code>

    in the Page_Init or the "Application_PreRequestHandlerExecute" of the Global.asax.

    The "tMyLang" is assigned fex.  from  1)page-querystring, or 2)session-variabel,  or 3)Cookie.

    Regards Roger.  

    Friday, August 18, 2006 5:35 AM