7

Using:

Console.WriteLine(System.Globalization.CultureInfo.CurrentCulture.ToString());

I get "en-US".

What should I change in my control panel settings ( Region and Language ? ) to get something else for example "en-CA" .

TiyebM
  • 2,684
  • 3
  • 40
  • 66
  • What's the context? What kind of app is this? – Jon Skeet Jan 23 '14 at 17:51
  • Duplicate of http://stackoverflow.com/questions/9697604/from-where-cultureinfo-currentculture-reads-culture , your answer is in the linked question. – Louis van Tonder Jan 23 '14 at 17:53
  • @LouisvanTonder, he is not writing an MVC application, his issue is with a console application. Not a duplicate as it doesn't apply – Anthony Shaw Jan 23 '14 at 17:55
  • @JonSkeet It is a Silverlight app, When I go to regional and language setting I can change the short date format and then I can see the result of my change if I call "CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern" So I was wondering what I change there to be able to call something similar in C# side to see "en-CA" for example? if possible at all –  Jan 23 '14 at 18:03
  • @AnthonyShaw , "What should I change in my control panel settings ( Region and Language ? ) " – Louis van Tonder Jan 23 '14 at 18:11
  • Just a small hint from my own experience: in the windows region control panel, I had to set the regional format to the explicit value instead of the «recommended» option before CurrentCulture became what I was expecting it to be – kvaale Aug 11 '23 at 14:09

4 Answers4

12

What should I change in my control panel settings ( Region and Language ? ) to get something else for example "en-CA" .

You can change it for current thread like:

System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-CA");

and then:

Console.WriteLine(System.Globalization.CultureInfo.CurrentCulture.ToString());

would return:

en-CA
Habib
  • 219,104
  • 29
  • 407
  • 436
5

In my experience, the culture was set by the version of the operating system. Not really a setting in the control panel. We used to have to have multiple VM's running multiple version of Windows to test our cultural based features

Anthony Shaw
  • 8,146
  • 4
  • 44
  • 62
  • oh ok thanks, I thought it is similar to when we change date time formats in there, I thought there is something for culture too. –  Jan 23 '14 at 18:04
1

You can change the language in the Region and Language control panel. Choose English (Canada) from the drop-down combo box labeled Format. Note that this will apply for the user and is the User Locale.

As a side note, starting with Windows 8, the user locale defaults to whatever your Windows display language is and Windows Store apps make use of the language list to align the language that is used for producing date and time strings and number formatting, etc., with the language that is used for retrieving resources. .Net attempts to participate in this, so for Windows Store Apps, changing the language list is the preferred way to get this effect.

Eric MSFT
  • 3,246
  • 1
  • 18
  • 28
0

you could just define a key in your App.config like this

<configuration>
    <appSettings>
        <add key="DefaultCulture" value="en-CA" />
    </appSettings>
</configuration>

and in your application read that value and set the culture

 CultureInfo culture = new CultureInfo(ConfigurationManager.AppSettings["DefaultCulture"]);
    Thread.CurrentThread.CurrentCulture = culture;
    Thread.CurrentThread.CurrentUICulture = culture;
Amarnath Balasubramanian
  • 9,300
  • 8
  • 34
  • 62