Humanizr / Humanizer

Humanizer meets all your .NET needs for manipulating and displaying strings, enums, dates, times, timespans, numbers and quantities

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CultureNotFoundException MalteseFormatter

jswigart opened this issue · comments

image

In the formatter registry

https://github.com/Humanizr/Humanizer/blob/main/src/Humanizer/Configuration/FormatterRegistry.cs

There is a RegisterDefaultFormatter function that catches and ignores exceptions with the comment
// Some OS's may not support the particular culture. Not much we can do for those.

Why then are the calls to register with a custom formatter not protected in the same way with their own exception catcher, when their associated culture may also similarly not be supported on a particular OS?

This seems like a clear oversight, and one I am running into when attempting to run a dotnet app on steam deck via it's proton emulation. I am already bundling ICU with the application, as per

https://learn.microsoft.com/en-us/dotnet/core/extensions/globalization-icu

Here's an example
image

the actual constructor of the formatter needs to be wrapped in the try/catch, as that is where it may fail. using a delegate to do that in this case

Duplicate of #1126