Humanizer icon indicating copy to clipboard operation
Humanizer copied to clipboard

DateTimeOffset.Humanize(culture: newCulture) doesn't emit translated text

Open mrbelk opened this issue 2 years ago • 2 comments

I am trying to use the DateTimeOffset.Humanize() method in a Xamarin.Forms application and specifying a cultureinfo that's different from the current OS culture (in this case "es," and "fr") but when I "Humanize" a DateTime or DateTimeOffset, the resulting text is in the default culture "en-US".

Is this a known bug? Is there any additional setup I have to perform in order to "register" the other languages? I have added the culture specific Humanizer.Core.fr and Humanizer.Core.es Nuget packages in addition to the base Humanizer.Core package. All of the versions are the same.

Thanks, Matthew

mrbelk avatar Dec 07 '22 18:12 mrbelk

I forked the repo and added a simple test to the DateHumanizerDefaultStrategyTests and the TimeSpanHumanizerTests to pass a CultureInfo object to the .Humanize() extension method and it appears to work correctly. That would seem to indicate a problem in my code, but I can't for the life of me figure out what the problem is. I guess my next step will be to directly reference the Humanizer project from my app's project.

mrbelk avatar Dec 07 '22 19:12 mrbelk

when I directly reference the Humanizer project in my xamarin.forms app, everything seems to work as expected. It would appear there's something up with the nuget packages when I add just the 2 languages that I need. When I added the "catch-all" Humanizer project, which includes all of the cultures, I still get the default culture translation, not the actual culture specified in the CultureInfo object passed in to the Humanize method.

mrbelk avatar Dec 07 '22 20:12 mrbelk