Sam's suggestion of using web.config settings works great if you know explicitly which language to choose. You can also use Auto to automatically switch into the browser's locale, but that's rarely what you really want.
However if you dynamically want to switch language based on the browser preferences then you need to do this at the Application level. Put the code above into Application_BeginRequest.
There's more info on how to do this at the beginning of this article:
surbhi garg
0 Points
1 Post
Change UI culture..
Nov 30, 2011 05:25 AM|LINK
protected override void InitializeCulture()
{
if (Session["lang"] != null)
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo(Session["lang"].ToString());
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Session["lang"].ToString());
}
else
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo("hi");
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("hi");
}
}
If i m putting this method on an ASP.net page it is working fine but my problem is i want to use this code on multiple pages
so i want to put this code at one place.
where i can put this code?????
sam_xiii
Contributor
2366 Points
381 Posts
Re: Change UI culture..
Nov 30, 2011 07:34 AM|LINK
Hi
define it in your web.config
<system.web> <globalization culture="fr-FR" uiCulture="fr"/>Or in the Global.asax or maybe in your master page if you want to make it dynamic
http://www.sambeauvois.be
rstrahl
Contributor
2233 Points
375 Posts
ASPInsiders
MVP
Re: Change UI culture..
Dec 05, 2011 11:01 PM|LINK
Sam's suggestion of using web.config settings works great if you know explicitly which language to choose. You can also use Auto to automatically switch into the browser's locale, but that's rarely what you really want.
However if you dynamically want to switch language based on the browser preferences then you need to do this at the Application level. Put the code above into Application_BeginRequest.
There's more info on how to do this at the beginning of this article:
http://www.west-wind.com/presentations/wwDbResourceProvider/introtolocalization.aspx
Hope this helps,
+++ Rick ---
West Wind Technologies
Making waves on the Web
www.west-wind.com/weblog