Skip to content

Commit

Permalink
Merge pull request #1065 from Humanizr/catch-unsupported-cultures
Browse files Browse the repository at this point in the history
Add try/catch around formatter registration
  • Loading branch information
clairernovotny authored May 5, 2021
2 parents b8c06d7 + 92f76a4 commit 3d3814f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Humanizer/Configuration/FormatterRegistry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Humanizer.Localisation.Formatters;
using System.Globalization;

using Humanizer.Localisation.Formatters;

namespace Humanizer.Configuration
{
Expand Down Expand Up @@ -56,7 +58,14 @@ public FormatterRegistry() : base(new DefaultFormatter("en-US"))

private void RegisterDefaultFormatter(string localeCode)
{
Register(localeCode, new DefaultFormatter(localeCode));
try
{
Register(localeCode, new DefaultFormatter(localeCode));
}
catch (CultureNotFoundException)
{
// Some OS's may not support the particular culture. Not much we can do for those.
}
}

private void RegisterCzechSlovakPolishFormatter(string localeCode)
Expand Down

0 comments on commit 3d3814f

Please sign in to comment.