Blog Home  Home Feed your aggregator (RSS 2.0)  
Mayur's Blog - CurrentUICulture and CurrentCulture in ASP.NET: Difference and Usage
 
# Friday, May 8, 2009

First time I went through these confusing names and found some information about them and thought to display on my blog so that it will be useful to others.

CurrentUICulture sets your UI language ( i.e. it translates 'tool tips', 'menus', 'helps' etc in a specified language)

CurrentCulture sets your default user locale (i.e. format of date, currency, format of time etc; there are approximately 208 locales in vista. So it displays $10,000 for 'en-US' and £10,000 for 'en-GB')

You can visit this little app to get an idea
http://www.mayurbharodia.com/CalendarCultureUI/default.aspx

In this app the calendar language is traslated by CurrentUICulture, while currency is formatted by CurrentCulture.

For more info visit this blog:
http://blogs.msdn.com/michkap/archive/2007/01/11/1449754.aspx

Wondering how to set it up! The following might give you a little idea.

Make sure that you are importing namespaces for system.threading and system.globalization into your code. The following code instructs run time to change current thread's culture based on the given input. InitializeCulture is a method of page class.

 protected override void InitializeCulture()

    {

        base.InitializeCulture();

 

        string lang = "hi";

 

        /*I have hardcoded language to Hindi, "hi" stands for Hindi;

        you can also set it up programmatically */            

 

        if (lang != null && lang != "")

        {

            Thread.CurrentThread.CurrentUICulture  = new CultureInfo(lang);

            Thread.CurrentThread.CurrentCulture = 

            CultureInfo.CreateSpecificCulture(lang);

        }

    }

Friday, May 8, 2009 11:45:24 PM UTC  #       | 
Copyright © 2022 Mayur Bharodia. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: