Skip to content

✨Fallback to invariant culture if cultures are not found#1266

Merged
angularsen merged 1 commit intomasterfrom
agl/support-invariantculture-only
Jun 18, 2023
Merged

✨Fallback to invariant culture if cultures are not found#1266
angularsen merged 1 commit intomasterfrom
agl/support-invariantculture-only

Conversation

@angularsen
Copy link
Owner

@angularsen angularsen commented Jun 18, 2023

Fixes #1238

Applications crashed when running on Linux or Raspberry PI systems if .NET cultures were not installed.

Specifically, UnitAbbreviationsCache.Default threw an exception trying to instantiate the fallback CultureInfo with en-US.

Changes

  • Change fallback culture to InvariantCulture
  • Add CultureHelper.GetCultureOrInvariant() to handle CultureNotFoundException
  • Change UnitInfo to map invariant culture to en-US localization

Applications crashed when running on Linux or Raspberry PI systems if .NET cultures were not installed.
Specifically, `UnitAbbreviationsCache.Default` threw an exception trying to instantiate "en-US" `CultureInfo`.

### Changes
- Change fallback culture to `InvariantCulture`
- Add `CultureHelper.GetCultureOrInvariant()` to handle `CultureNotFoundException`
@angularsen
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System.Globalization.CultureNotFoundException UnitsNet.ToString() on system that Culture information is not available

1 participant