Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify current culture?

Tags:

c#

.net

 CultureInfo culture = new CultureInfo("en-US");

        culture.DateTimeFormat.DateSeparator = "/";
        culture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";

        //dekadikoi arithmoi
        culture.NumberFormat.NumberDecimalSeparator = ".";
        Thread.CurrentThread.CurrentCulture = culture;
        Thread.CurrentThread.CurrentUICulture = culture;

As it is required to work that way everywhere! The problem is that doing new CultureInfo("en-US"); all other computer-specific settings are omited... Is there a way to copy the CurrentCulture? I tried to modify currentculture but i got read only error...

like image 749
GorillaApe Avatar asked Oct 12 '10 08:10

GorillaApe


1 Answers

CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();

culture.DateTimeFormat.DateSeparator = "/";
culture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";

//dekadikoi arithmoi
culture.NumberFormat.NumberDecimalSeparator = ".";
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;

You may wish to use:

CultureInfo culture = (CultureInfo)CultureInfo.CurrentUICulture.Clone();

instead.

like image 153
Jon Hanna Avatar answered Oct 19 '22 23:10

Jon Hanna