locked
Setting UICulture to auto RRS feed

  • Question

  • User1334482106 posted

    Hi

    I want to set the UICulture to auto.  I know that I can do this in the individual page or I can set this globally in the web.config file.

    However, my web pages all inherit from a base page (of which I have several) and I want to set this value in one of these base pages so that if affects every page that inherits from this base page, but no others. 

    Is this possible?  If so...how?

    Thanks

    Griff

    Monday, September 19, 2011 9:48 AM

Answers

  • User1334482106 posted

    Hi hans_v

    Thanks - I'd worked out that this should be set in the InitializeCulture, what I wasn't sure of was how to actually set it to AUTO.

    What I'm doing is this (defensive coding removed for clarity):

            protected override void InitializeCulture()
            {
                // Load the language from the browser
                string uiLang = this.Page.Request.Headers["Accept-Language"];
    
                // Set the UI culture
                System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(uiLang.Split(",".ToCharArray())[0]);
    
                //Base
                base.InitializeCulture();
            }

    Griff

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 20, 2011 5:18 AM

All replies

  • User-1199946673 posted

    You need to override the InitializeCulture method in the base page:

     

    Monday, September 19, 2011 5:46 PM
  • User1334482106 posted

    Hi hans_v

    Thanks - I'd worked out that this should be set in the InitializeCulture, what I wasn't sure of was how to actually set it to AUTO.

    What I'm doing is this (defensive coding removed for clarity):

            protected override void InitializeCulture()
            {
                // Load the language from the browser
                string uiLang = this.Page.Request.Headers["Accept-Language"];
    
                // Set the UI culture
                System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(uiLang.Split(",".ToCharArray())[0]);
    
                //Base
                base.InitializeCulture();
            }

    Griff

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 20, 2011 5:18 AM