Last post Aug 09, 2011 04:02 AM by smirnov
Contributor
2808 Points
1815 Posts
Aug 09, 2011 03:45 AM|jeyaseelan@ajsquare.net|LINK
hi there,
i changed my IE language to German(Germany) by this way http://whatismyipaddress.ricmedia.com/help/browser_language/internet_explorer_7/
after that i execute below code from front-end
string strCurrentCutlture = string.Empty; strCurrentCutlture = System.Threading.Thread.CurrentThread.CurrentCulture.Name; Response.Write("Currrent Cutture is " + strCurrentCutlture);
but its always giving output us English. why its gave me always English? and how can i get the exact culture?
All-Star
35159 Points
9075 Posts
Aug 09, 2011 03:47 AM|smirnov|LINK
Use HttpRequest.UserLanguages or the Headers collection in the Request object - Request.Headers["Accept-Language"].
The Thread.CurrentCulture Property gets or sets the culture for the current thread, not a client.
To set current culture according to browser settings, use
using System.Globalization; using System.Threading; private void Page_Load(object sender, System.EventArgs e) { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages[0].ToString()); Thread.CurrentThread.CurrentUICulture = new CultureInfo(Request.UserLanguages[0].ToString()); lblToday.Text = Today; lblMessage.Text = "Culture Info Display Name " + Thread.CurrentThread.CurrentCulture.DisplayName; }
Aug 09, 2011 03:55 AM|jeyaseelan@ajsquare.net|LINK
Sminov,
Thanks for your response.
Request.UserLanguages[0].ToString(); its good in aspx.cs file but how can we get the language from a class file (without uqerystring concept)
Aug 09, 2011 04:02 AM|smirnov|LINK
You mean how to access the Request class?
System.Web.HttpContext.Current.Request.UserLanguages[0].ToString();
Contributor
2808 Points
1815 Posts
find my current culture
Aug 09, 2011 03:45 AM|jeyaseelan@ajsquare.net|LINK
hi there,
i changed my IE language to German(Germany) by this way http://whatismyipaddress.ricmedia.com/help/browser_language/internet_explorer_7/
after that i execute below code from front-end
string strCurrentCutlture = string.Empty;
strCurrentCutlture = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
Response.Write("Currrent Cutture is " + strCurrentCutlture);
but its always giving output us English. why its gave me always English? and how can i get the exact culture?
J.Jeyaseelan
All-Star
35159 Points
9075 Posts
Re: find my current culture
Aug 09, 2011 03:47 AM|smirnov|LINK
Use HttpRequest.UserLanguages or the Headers collection in the Request object - Request.Headers["Accept-Language"].
The Thread.CurrentCulture Property gets or sets the culture for the current thread, not a client.
To set current culture according to browser settings, use
Contributor
2808 Points
1815 Posts
Re: find my current culture
Aug 09, 2011 03:55 AM|jeyaseelan@ajsquare.net|LINK
Sminov,
Thanks for your response.
Request.UserLanguages[0].ToString(); its good in aspx.cs file but how can we get the language from a class file (without uqerystring concept)
J.Jeyaseelan
All-Star
35159 Points
9075 Posts
Re: find my current culture
Aug 09, 2011 04:02 AM|smirnov|LINK
You mean how to access the Request class?
System.Web.HttpContext.Current.Request.UserLanguages[0].ToString();