Silverlight's System.Globalization Namespace

One of the ever-present questions in the Silverlight world is "what's missing ?". In other words what does the .NET Framework or WPF have that Silverlight doesn't ? In terms of globalization the obvious place to start is the System.Globalization namespace and to this end I have written a simple Silverlight Globalization Class Comparison document that lists all of the classes, methods and properties in the .NET Framework's System.Globalization namespace and indicated whether the same feature exists in Silverlight's System.Globalization namespace.

For me it is one thing to know that Silverlight doesn't support a particular feature but it is another to know exactly why it doesn't and whether it will be coming in a future release of Silverlight. Of course, this is often speculation but in this post I give my opinion on why specific features aren't there and if they are coming (there are no official secrets being revealed here ? this is purely speculation based on reasonable deduction).

Let's start with the missing lunisolar calendars (ChineseLunisolarCalendar et al). There is no technical reason why these calendars couldn't be in Silverlight so I suspect that these have been excluded in the name of keeping the download size down.

Also missing is the PersianCalendar together with TextInfo.IsRightToLeft and FrameworkElement.FlowDirection support for right to left languages. Silverlight 2 (and at the current time Silverlight 3) has no support for right to left languages and it is likely that we will need to wait for Silverlight 4 before this appears (Microsoft are well aware that this is an important feature).

The CultureAndRegionInfoBuilder for building custom cultures is absent and is very unlikely to ever turn up in Silverlight. Apart from the inherent differences between the platforms on which Silverlight runs a fairly substantial block to incorporating CultureAndRegionInfoBuilder is that it requires administrator rights to create a custom culture. That is not to say that a Silverlight application cannot use custom cultures (it can) just that the Silverlight application has no way to create the custom cultures that it needs.

All method overloads and properties that have anything to do with locale IDs (LCIDs) are also missing and are unlikely to ever put in an appearance. Apart from the fact that this is a Windows concept and not cross-platform there is the more important point that culture names are the preferred way to identify cultures in the .NET Framework. Culture names always uniquely identify a culture whereas locale IDs are ambiguous (for custom cultures) and are therefore not reliable. Other Windows-specific features such as CultureInfo.ThreeLetterWindowsLanguageName go the same way for the same reason. I suspect that the very useful RegionInfo.GeoId falls into this category.

Others like TextInfo.ToTitleCase do not appear to have any technical reason why they are not included in Silverlight and I can only speculate here that this is another victim of keeping the download side down again.

The TextInfo properties for use with code pages (ANSICodePage, OEMCodePage etc.) are all missing and again I speculate that these are missing because there is no desire to bloat Silverlight with support for legacy systems when Silverlight itself fully supports Unicode.

As new Silverlight releases come out I will update the document and no doubt the list will both shrink (as Silverlight adds features like right to left support) and grow (as the .NET Framework adds more to the System.Globalization namespace).

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by: guysmithferrier
Posted on: Tuesday, March 31, 2009 at 10:22 PM
Tags:
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (2) | Post RSSRSS comment feed

Related posts

Comments

Rupak Ganguly us

Thursday, April 30, 2009 10:58 PM

Rupak Ganguly

Hi Guy,
Great article. I stumbled upon your post while I was trying to search for using custom cultures in Silverlight 2.0.
I saw this section in your post "That is not to say that a Silverlight application cannot use custom cultures (it can) just that the Silverlight application has no way to create the custom cultures that it needs." and got excited.
I need to use some custom cultures (en-HK) in my Silverlight app. but have not been able to.

Can you explain or point me to relevant links as to how one can use custom cultures in SL apps? Any help would be greatly appreciated.

GuySmithFerrier gb

Friday, May 01, 2009 1:02 AM

GuySmithFerrier

Rupak,

I'm not sure what problem you are having. The Silverlight application can consume any custom culture just like any other culture. The problem from the point of view of the Silverlight application is that it has no way it can create the custom culture. But it can consume it if the custom culture already exists on the machine. Consequently custom cultures are suitable for use in a Silverlight application if Silverlight is being used in an intranet where you have access to the machines but they would not be suitable for use on the internet as there is no way you could run an install program to install the custom culture (and this requires administrator access anyway).

Guy