Get Client machine localization
-
i need to get machine localization in my website. i change my machine localization ("Regional and Language Options" control panel.) and check with below code but always it shows as 'en_US'.. string strCluture = CultureInfo.CurrentCulture.Name; what i need to do to get current localization. am i missing some setting or what?
-
i need to get machine localization in my website. i change my machine localization ("Regional and Language Options" control panel.) and check with below code but always it shows as 'en_US'.. string strCluture = CultureInfo.CurrentCulture.Name; what i need to do to get current localization. am i missing some setting or what?
Mugdha_Aditya wrote:
i change my machine localization ("Regional and Language Options" control panel.)
and check with below code but always it shows as 'en_US'..string strCluture = CultureInfo.CurrentCulture.Name;
what i need to do to get current localization. am i missing some setting or what?
Did you restart your application after you changed the setting? The CultureInfo is set for the app when it starts, and (luckily) doesn't change while running - even if the user changes it. The new CultureInfo should be displayed after you start your app.
Mugdha_Aditya wrote:
i need to get machine localization in my website.
Care to explain a bit? You're fetching the culture of the webserver, not of the connected clients.
Bastard Programmer from Hell :suss:
-
Mugdha_Aditya wrote:
i change my machine localization ("Regional and Language Options" control panel.)
and check with below code but always it shows as 'en_US'..string strCluture = CultureInfo.CurrentCulture.Name;
what i need to do to get current localization. am i missing some setting or what?
Did you restart your application after you changed the setting? The CultureInfo is set for the app when it starts, and (luckily) doesn't change while running - even if the user changes it. The new CultureInfo should be displayed after you start your app.
Mugdha_Aditya wrote:
i need to get machine localization in my website.
Care to explain a bit? You're fetching the culture of the webserver, not of the connected clients.
Bastard Programmer from Hell :suss:
Hey... Thanks for the your reply. I have restarted my application as well as my pc. still its not applying selected culture.
-
i need to get machine localization in my website. i change my machine localization ("Regional and Language Options" control panel.) and check with below code but always it shows as 'en_US'.. string strCluture = CultureInfo.CurrentCulture.Name; what i need to do to get current localization. am i missing some setting or what?
Apart from
CurrentCulture
, there is alsoCurrentUICulture
. Since you're talking about a web site, do not forget to set theCurrentUICulture
to the desired value whenever a new thread (!) is started - otherwise your web site will always run in the localization of your web server. E.g.System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo("de-DE");
Threads get their culture specific settings from the operating system, not from the thread they were started from.
-
Apart from
CurrentCulture
, there is alsoCurrentUICulture
. Since you're talking about a web site, do not forget to set theCurrentUICulture
to the desired value whenever a new thread (!) is started - otherwise your web site will always run in the localization of your web server. E.g.System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo("de-DE");
Threads get their culture specific settings from the operating system, not from the thread they were started from.
i dontt want to set culture , i want to getculture info. i have done below changes in page load but still its not working. System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo("de-DE"); string strCluture = CultureInfo.CurrentCulture.Name; strCluture returns en-US :(