-
-
Notifications
You must be signed in to change notification settings - Fork 8
Description
In #3, a UCutureInfo type was created to replace the ICU4J ULocale type. The main goals for doing this are:
- To provide a similar API as the
CultureInfoclass - To provide a way to set the culture/default culture of the current thread
- To fill gaps in behavior between ICU and the .NET platform
We managed to get a prototype in place, but there are still some remaining tasks and research to complete.
Known Issues
-
TwoLetterISOLanguageName/GetTwoLetterISOLanguageNamereturnsnullfor invariant culture, which is different than the documented behavior of ICU4J (at least for the 3 letter language), which is to return empty string. In .NET, the behavior is to return the string"iv". - The
Parentproperty behaves differently in than the .NET platform. In ICU, the script tag is not considered as part of the fallback behavior, but in .NET it is (i.e.uz_Cyrl_UZfalls back touz_Cyrlin .NET, but in ICU it falls back touz). TheAcceptLanguageoverloads ofUCultureInfodepend on the current behavior for the tests to pass. For now,Parenthas been marked internal until this can be addressed. - The default behavior of
CurrentCultureandCurrentUICulturewhen not explicitly set is to track the properties of theCultureInfo.CurrentCultureandCultureInfo.CurrentUICulture. So, when either of the latter changes, the former are automatically updated to the nearest corresponding culture. If set explicitly, this tracking stops and the culture that is set is used instead. However, once set there is currently no way to "unset"UCultureInfo.CurrentCultureorUCultureInfo.CurrentUICultureto get back to the original tracking behavior. - The
ULocaleclass in ICU4J was immutable and itsClonemethod simply returned itself. However, in .NETUCultureInfowas designed to be mutable unless it is wrapped using theReadOnlymethod. For now,UCultureInfois immutable and markedsealedso the behavior cannot be changed. - Since LCID is not available in the CLDR data and is deprecated, the property has been commented out and none of the method overloads or constructors that utilize it have been added.
- The
Nameproperty effectively returns the base name in ICU4J. They are similar, however, in .NET they are typically delimited by hyphen and in ICU they are delimited by underscore. Through some limited testing, it appears bothUCultureInfoandCultureInfoaccept either format. More research is required to determine whether changing to the .NET convention makes sense. - Lack of caching. In ICU4J, static properties for the most commonly used cultures (to match the JDK). In .NET, there are no such properties, but there are methods available to provide read-only cached cultures.
Missing Members of CultureInfo
The following members of CultureInfo are not yet present in UCultureInfo.
Properties
-
Calendar- NOTE: ICU4J has its own calendars that are not ported and not planned for the current release -
CompareInfo- This is the equivalent of theCollatorclass in ICU4J, however the API is more extensible in ICU4J and custom sort rules can be defined. It may not make sense to merge the two. -
DateTimeFormat -
IsReadOnly -
KeyboardLayoutId -
LCID -
NumberFormat- Added in BREAKING: Added Rule-Based Number Format Static API #46. -
OptionalCalendars -
Parent- Marked internal, since the behavior differs from .NET (see above) -
TextInfo- Although ICU has properties that make sense to put here, the constructor is internal -
ThreeLetterWindowsLanguageName -
UseUserOverride
Methods
-
public static UCultureInfo CreateSpecificCulture(string name) -
public UCultureInfo GetConsoleFallbackUICulture() -
public static UCultureInfo GetCultureInfo(string name) -
public static UCultureInfo GetCultureInfo(int culture) -
public static UCultureInfo GetCultureInfo(string name, string altName)- This one seems to be a duplicate of passing the keyword (i.e.@collation=phonebook), but in ICU4N, there is currently no culture cache. -
public virtual object GetFormat(Type formatType)- Added in BREAKING: Added Rule-Based Number Format Static API #46. -
public static UCultureInfo ReadOnly(UCultureInfo ci)- Added in BREAKING: Added Rule-Based Number Format Static API #46.
Missing Members of ULocale
Properties
-
CharacterOrientation- Marked internal, since the logical place to put it would be onTextInfo -
LineOrientation- Marked internal, since the logical place to put it would be onTextInfo -
IsRightToLeft- Marked internal, since the logical place to put it would be onTextInfo
API Documentation
- Some of the JavaDocs have yet to be converted and other members (including the main class header) have not yet been documented.
UCultureInfoBuilder
-
UCultureInfoBuilder
ICU4J's ULocale class has a nested Builder class that has been de-nested and marked internal. Its purpose is to safely build a locale object while validating the inputs, as the UCultureInfo class provides no such validation. The CultureInfo class also doesn't provide validation upon creation, but will throw an exception if the requested culture doesn't exist on the platform.
More research is needed to determine if a similar function exists on the .NET platform so we can correctly map this functionality (which does exist on the Java platform) or whether it makes sense to keep it as is and add it to the public API.