by Michael S. Kaplan, published on 2005/06/26 21:20 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2005/06/26/432874.aspx
Recently overheard in the microsoft.public.dotnet.internationalization newsgroup:
I'm developing a web application, in that I have to display the short date according to the customized date format of client machine's culture.
For example Culture = "fr-CA" and default Short date format = "yyyy-MM-dd", when you customize the shortdate format to "dd.MM.yy". Then the short date should be displayed in the format "dd.MM.yy" to the client.
I'm able to display the date in the custom short date format while executing through the VS2005 IDE. But after deploying the same web application, the date is displayed only in the default short date format, though the short date format is customized.
A commonly asked question, though unfortunately the answer is not really one that will make peron asking happy -- those settings (basically user overrides) are not available on the server. They are retrieved through a call to the Win32 NLS GetLocaleInfo function (for the short date you would pass the LOCALE_SSHORTDATE flag).
The only piece of information that the server gets related to locale is the HTTP_ACCEPT_LANGUAGE (which, as I mentioned in the article GEOID -- The LCIDs maligned little brother....) is currently based on the user locale. Anyway, right now it is based on the setting that you can set your CurrentCulture to, but there is no way to get the overrides....
Of course if you have a client side component you could send the information to the server but that has all kinds of dependencies on what is running on the client side, which ASP.NET tries to avoid when it can.
Another option is to have UI in the application that allows your users to set their preferred format if they would like to do so. Most users probably would not bother (most users do not change the setting in the Regional and Language Options UI, either) but those who would like to change a setting would probably not mind doing so.
If anyone complains, you can either blame the IETF for not having an HTTP header with the info, or on the makers of all the big browsers for not agreeing on some sort of standard for passing the data. :-)
On a side note, in that post about GEOIDs I meant what I said about the fact that many settings probably should be configured to use the GEOID where they are using an LCID today. That PM (Matt Ayers) is right. I tend to raz Matt a lot because we just have that kind of a relationship, but I do like to give him credit when I think he's right. We really ought be more region based when it makes sense to be so....
This post brought to you by "♃" (U+2643, a.k.a. JUPITER)
# David on 27 Jun 2005 5:13 AM:
# Michael S. Kaplan on 27 Jun 2005 5:21 AM:
# David on 27 Jun 2005 6:30 AM:
# CornedBee on 27 Jun 2005 6:33 AM:
# Tanveer Badar on 22 Dec 2007 1:06 AM:
There is supposed to be an implementation of <globalization enableClientBasedCulture/> in some future version of netfx. But MSDN says (http://msdn2.microsoft.com/en-us/library/hy4kkhe0.aspx) this is not in use (read not implemented) at the moment.
go to newer or older post, or back to index or month or day