Where to set language and culture
-
Dear All, What is the proper place to set the default culture and uiculture of the entire website? And the proper place to set the user specific culture and uiculture based on data in de database, ofter the user logs in? Thanks in advance.
The bad thing is that processes do inherit the language/culture settings from Windows, not from a parent thread. Consequently, you must set that whenever a new thread is started - i.e. at least once for each web page.
-
Dear All, What is the proper place to set the default culture and uiculture of the entire website? And the proper place to set the user specific culture and uiculture based on data in de database, ofter the user logs in? Thanks in advance.
Following tip may help you: Satellite Assembly Example in C# (Step by Step)[^]
Happy Coding... :)
-
Dear All, What is the proper place to set the default culture and uiculture of the entire website? And the proper place to set the user specific culture and uiculture based on data in de database, ofter the user logs in? Thanks in advance.
Hi, Please follow any one of the below alternatives.
Alternative 1
In Web.Config file: <globalization culture="de-AT" uiCulture="de-AT" ….>
Note: If configured here the value would remain same for all the webforms of the project and is not based on clients choice of language.Alternative 2
//Following should be written in Global.asax and this global to all the webforms of the application.
protected void Application_BeginRequest(object sender, EventArgs e)
{
if (Request.Cookies["culture"] == null) return;
System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(Request.Cookies["culture"].Value);
System.Threading.Thread.CurrentThread.CurrentCulture = ci;
System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
}For more information on Globalization follow the below link http://www.bestdotnettraining.com/Online/Training/ASP-NET/Globalization-and-Localization-/59[^]
Grace
-
Dear All, What is the proper place to set the default culture and uiculture of the entire website? And the proper place to set the user specific culture and uiculture based on data in de database, ofter the user logs in? Thanks in advance.
Hi, the proper place is inside the function Application_BeginRequest in the global.asax file.
protected void Application_BeginRequest(object sender, EventArgs e)
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB");
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");
}