There has been always a popular question on the ASP.NET forums about the difference between CurrentCulture and CurrentUICulture. I wanted to distinguish things in this post and make it clear once and for all.
- CurrentCulture and CurrentUICulture are both of type CultureInfo which is part of the System.Globalization.
- CurrentCulture and CurrentUICulture are boh properties of the current thread represented as: System.Threading.Thread.CurrentThread.CurrentCulture and System.Threading.Thread.CurrentThread.CurrentUICulture
- CurrentCulture is used mainly to format the Dates, Currencies, etc ... For that reason it should be set specific. For instance, you need to set the CurrentCulture as:
System.Threading.Thread.CurrentThread.CurrentCulture= new CultureInfo("ar-LB");
We have set current culture to be a specific culture and mainly, Arabic - Lebanese. So make sure always to be specific in specifying the CurrentCulture
- CurrentUICulture is mainly used for language/text translations. So the ResourceManager is based upon the CurrentUICulture. It doesn't matter whether the culture set here is specific or neutral. For instance, either ar or ar-lb works fine with the CurrentUICulture:
System.Threading.Thread.CurrentThread.CurrentCulture= new CultureInfo("ar"); // ar-lb
Both work fine in this case.
- ASP.NET controls (Calendar for example) with built-in localization cannot use a neutral culture. When you want to make use of the built-in localization of ASP.NET Controls, make sure to specify a specific culture in the CurrentCulture.
Hope this post helps you clarify the differences between CurrentCulture and CurrentUICulture.
Regards
Tags: ASP.NET 1.x, ASP.NET 2.0 - General