0

I have this C++ code

static const int category[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY,                       LC_NUMERIC, LC_TIME};
int op;
...
/* op = 0;  => The entire locale. */
op = 3; /* => Affects monetary formatting information */
char *setl = setlocale(category[op], "fr-FR");

I find

Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("fr-FR");
// OR
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");

which I think must be the equivalent of

setlocale( LC_ALL, "fr-FR" );

But in C#, how can I specifies the category argument for change locale information of a program?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
LeMoussel
  • 5,290
  • 12
  • 69
  • 122

1 Answers1

1

You need to work with CultureInfo class and it's members as Clone, and after that instance change any single piece of that information accordingly.

Quoting an example in MSDN link:

// Clones myCI and modifies the DTFI and NFI instances associated with the clone.
CultureInfo myCIclone = (CultureInfo) myCI.Clone();
myCIclone.DateTimeFormat.AMDesignator = "a.m.";
myCIclone.DateTimeFormat.DateSeparator = "-";

and after

Thread.CurrentThread.CurrentCulture = myCIclone;
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Tigran
  • 61,654
  • 8
  • 86
  • 123
  • OK. But what are properties of CultureInfo corresponding to each category of setlocale ()? – LeMoussel Apr 04 '14 at 12:36
  • @PapyRef: you may look, apart of already presented DateTimeFormat, on [NumberFormatInfo](http://msdn.microsoft.com/it-it/library/system.globalization.numberformatinfo%28v=vs.110%29.aspx) which is always a type of NumberFormat property inside CultureInfo class. – Tigran Apr 04 '14 at 12:56