User1464674564 posted
I have a site that needs to support 2 cultures, "en-US" and "fr-CA" an there needs to be a link at the bottom that can switch between the two cultures. To do this I store the current culture in a session variable and have a link button that changes the value.
Then I override the pages InitializeCulture with the following
protected override void InitializeCulture()
{
base.InitializeCulture();
if (Session["PageCulture"] == null)
{
Session["PageCulture"] = System.Threading.Thread.CurrentThread.CurrentCulture.ToString();
}
else
{
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo((string)Session["PageCulture"]);
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo((string)Session["PageCulture"]);
}
}
}
This works except for validation errors that are stored in resource files. When I switch to a different culture the validation errors are always in the default culture. Does anyone know why?
Also as a question of interest wouldn't changing the System.Threading.Thread.CurrentThread's culture change the culture for all clients running on that thread or does it do just the current request?