Humanizer icon indicating copy to clipboard operation
Humanizer copied to clipboard

Mixed languages in TimeToClockNotation (ITimeOnlyToClockNotationConverter implementations do not forward the culture to ToWord)

Open acidbubbles opened this issue 1 year ago • 0 comments

When using

Examples:

This results in mixed languages.

Repro

var time = Configurator
  .TimeOnlyToClockNotationConverters.ResolveForCulture(new CultureInfo("fr-FR"))
  .Convert(new TimeOnly(19, 35), ClockNotationRounding.NearestFiveMinutes);

This results in jeudi 3 février 2022, nineteen heures fifteen

Same for es-ES: ... las seven y ten de la tarde PM

I did not validate for further languages.

Solution

I'm guessing, forwarding the culture to e.g. EsTimeOnlyToClockNotationConverter so it can then forward it to ToWord would be the sensible solution, but it is an API change that I wouldn't be comfortable submitting, since it would affect potentially multiple files.

Workaround

Setting the CultureInfo.CurrentUICulture works, but it is not a desirable solution because it requires locking the string creation in multi-threaded environment, and we don't want to affect the UI culture necessarily.

acidbubbles avatar Jun 13 '24 03:06 acidbubbles