NightOwl888 / ICU4N

International Components for Unicode for .NET
Apache License 2.0
25 stars 8 forks source link

UCultureInfo Class (addresses #3) #27

Closed NightOwl888 closed 4 years ago

NightOwl888 commented 4 years ago

Implementation of UCultureInfo to replace ICU4J's ULocale class.

Making the class inherit System.Globalization.CultureInfo is a bit problematic for the following reasons:

  1. The TextInfo class (exposed as a property) has an internal constructor so options for populating its data are limited to Reflection or native code.
  2. The TextInfo class also exposes static members which would not be possible to override.
  3. The DateTimeFormatInfo and NumberFormatInfo have sealed constructors. Many of the properties are writable, but it is not possible to extend them or override their formatting behavior.

More attention was paid to round-tripping using ToUCultureInfo() and ToCultureInfo() methods and we now have more reliable results.

The available cultures can also now be filtered using a UCultureTypes enum, similar to how it works in .NET.

This implementation is still incomplete (missing documentation, tests, and some APIs need to be fixed to match the behavior of .NET), but is far more functional than the ULocale class that it is replacing.

This PR also contains a proof of concept implementation allowing users to inject their own custom Region and Language data (#2).