View previous topic :: View next topic |
Author |
Message |
ap3000 Guest
|
Posted: Fri Oct 02, 2009 11:47 am Post subject: Getting Users default language? |
|
|
Maybe I don't get the concept right, but what I try to accomplish is that our app checks if the users default language is NL, so yes than use the invariant language(Netherlands) or if not - Then use the English translation.
But On my own machine it all ready went wrong.
I thought that I could use this to
Code: |
if (CultureInfo.CurrentUICulture.Name == "nl-NL")
{
CultureManager.UICulture = new CultureInfo("nl");
}
else
{
CultureManager.UICulture = new CultureInfo("en");
}
|
But my OS is English and I have selected Dutch/Netherland as language/region and it doesn't matter witch language/region I set hi's always giving me the Dutch version. With other words the
Code: |
CultureInfo.CurrentUICulture.Name
|
is always returning nl-NL.
Please shine some light for me here. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Fri Oct 02, 2009 10:46 pm Post subject: |
|
|
The CultureInfo.CurrentUICulture property is set by default by the .NET framework to the culture of the OS. It isn't affected by the regional settings. So I would have expected if your OS UI is English then that would be the default value for CurrentUICulture.
The CultureInfo.CurrentCulture (and Thread.CurrentThread.CurrentCulture) property is set by default to the regional settings value. This means that if you want your application UI to be based (by default) on the regional settings selected then your code should execute the following before displaying any forms:
Code: | Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture; |
If you are using the Infralution CultureManager component to support changing the culture of open forms dynamically then you should instead call:
Code: | CultureManager.ApplicationUICulture = Thread.CurrentThread.CurrentCulture; |
The sample C# and VB Windows forms projects included in the Version 2 installation demonstrate how to do this. _________________ Infralution Support |
|
Back to top |
|
|
|