K
Kevin Blount
I'm trying to create a multi-lingual ASP.NET (C#) page where text, etc
comes from a database, so that I don't have to maintain 6 copies of the
page. This is mostly working just fine, but I have a question about
displaying dates.
In ASP (original) I was able to SetLocale("fr-FR") or SetLocale("nl-NL")
at the start of the page based on an 'if' statement that determined
which language should be shown.
I understand that C# doesn't have "SetLocale", and that I need to
explore cultures. I found some code that might work, but had some questions:
- what namespace do I need for this to work?
- what other methods (? right term? kinda new to C#) can I add long side
DateSeparator and ShortDatePattern?
- can I set, via a 'switch' or 'if' different CultureInfo parameters? or
perhaps I can set a string to be "nl-NL" and use that as a parameter?
- is there a way to do with without using .Parse? Nothing against it,
just mostly curious
thanks
Kevin
comes from a database, so that I don't have to maintain 6 copies of the
page. This is mostly working just fine, but I have a question about
displaying dates.
In ASP (original) I was able to SetLocale("fr-FR") or SetLocale("nl-NL")
at the start of the page based on an 'if' statement that determined
which language should be shown.
I understand that C# doesn't have "SetLocale", and that I need to
explore cultures. I found some code that might work, but had some questions:
Code:
CultureInfo myCulture = new CultureInfo("sl-SI", true);
myCulture.DateTimeFormat.DateSeparator = "/";
myCulture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
DateTime date = DateTime.Parse(datestr, myCulture);
- what namespace do I need for this to work?
- what other methods (? right term? kinda new to C#) can I add long side
DateSeparator and ShortDatePattern?
- can I set, via a 'switch' or 'if' different CultureInfo parameters? or
perhaps I can set a string to be "nl-NL" and use that as a parameter?
- is there a way to do with without using .Parse? Nothing against it,
just mostly curious
thanks
Kevin