Skip to content

Support InvariantGlobalization / default to InvariantCulture #41

@glen-84

Description

@glen-84

When enabling InvariantGlobalization (which I believe is now the default in API/gRPC/Worker project templates), the library fails with:

System.Globalization.CultureNotFoundException : Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name')

en is an invalid culture identifier.

   at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride)
   at Jeffijoe.MessageFormat.Formatting.Formatters.VariableFormatter.GetCultureInfo(String locale)
   at Jeffijoe.MessageFormat.Formatting.Formatters.VariableFormatter.Format(String locale, FormatterRequest request, IReadOnlyDictionary`2 args, Object value, IMessageFormatter messageFormatter)
   at Jeffijoe.MessageFormat.MessageFormatter.FormatMessage(String pattern, IReadOnlyDictionary`2 args)

Would it make sense to default to the invariant culture (empty string "") instead of "en"?

This affects static usage – with a custom instance you could simply specify the locale/culture yourself.

It's a breaking change, but worth it in my opinion.

An alternative would be to allow the locale on the default instance to be set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions