|
/// <summary> |
|
/// Gets the localiser for the specified culture |
|
/// </summary> |
|
/// <param name="culture">The culture to retrieve localiser for. If not specified, current thread's UI culture is used.</param> |
|
public TLocaliser ResolveForCulture(CultureInfo? culture) |
|
{ |
|
var cultureInfo = culture ?? CultureInfo.CurrentUICulture; |
|
return FindLocaliser(cultureInfo)(cultureInfo); |
|
} |
This code is using the CurrentUICulture, which is not correct. It should be using the CurrentCulture instead. While these are often set to the same value, this is not always the case -- in particular, the UI culture is often en-US when the culture is some other English variant.
I noticed this error when calling ToOrdinalWords on a DateTime.
Humanizer/src/Humanizer/Configuration/LocaliserRegistry.cs
Lines 30 to 38 in d7368b9
This code is using the
CurrentUICulture, which is not correct. It should be using theCurrentCultureinstead. While these are often set to the same value, this is not always the case -- in particular, the UI culture is oftenen-USwhen the culture is some other English variant.CurrentUICultureshould be used only for UI string resource translations.CurrentCultureshould be used for all other purposes, including numeric and date formatting.CurrentCulturereflects user custom settings from the control panel.I noticed this error when calling
ToOrdinalWordson aDateTime.