locked
Change UI culture.. RRS feed

  • Question

  • User1596687657 posted

    protected override void InitializeCulture()

    {

    if (Session["lang"] != null)

    {

    Thread.CurrentThread.CurrentUICulture = new CultureInfo(Session["lang"].ToString());

    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Session["lang"].ToString());

    }

    else

    {

    Thread.CurrentThread.CurrentUICulture = new CultureInfo("hi");

    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("hi");

    }

    }

    If i m putting this method on an ASP.net page it is working fine but my problem is i want to use this code on multiple pages

    so i want to put this code at one place.

    where i can put this code?????

    Wednesday, November 30, 2011 1:25 AM

Answers

  • User1401801381 posted

    Hi

    define it in your web.config

      <system.web>
        <globalization culture="fr-FR" uiCulture="fr"/>

    Or in the Global.asax or maybe in your master page if you want to make it dynamic

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 30, 2011 3:34 AM

All replies

  • User1401801381 posted

    Hi

    define it in your web.config

      <system.web>
        <globalization culture="fr-FR" uiCulture="fr"/>

    Or in the Global.asax or maybe in your master page if you want to make it dynamic

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 30, 2011 3:34 AM
  • User1622957740 posted

    Sam's suggestion of using web.config settings works great if you know explicitly which language to choose. You can also use Auto to automatically switch into the browser's locale, but that's rarely what you really want.


    However if you dynamically want to switch language based on the browser preferences then you need to do this at the Application level. Put the code above into Application_BeginRequest.

    There's more info on how to do this at the beginning of this article:

    http://www.west-wind.com/presentations/wwDbResourceProvider/introtolocalization.aspx


    Hope this helps,

    +++ Rick ---

    Monday, December 5, 2011 7:01 PM