-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support InvariantGlobalization / default to InvariantCulture #41
Comments
Interesting, I had no idea. Is that a new thing they are doing? I agree, changing the default to invariant makes sense. We should release that as a breaking change. |
Yes, fairly new. See dotnet/aspnetcore#47029. |
Do you think setting the default to invariant is better, or should we use whatever the current culture is? |
Good question. I think that using the current culture is a better idea. 👍 |
Sounds good to me! |
Yes, by default, the current culture is used unless you specify one with the CultureInfo overload. However, MessageFormat and other Java-style formatters are built upside down so the culture is specified at object creation instead of being passed into the Format method, which would be more practical in a multi threaded app and conform with the rest of the dotnet culture behaviors. You could "fix" this by adding a constructor overload that doesn't accept culture, but it seems broken when the culture of the current thread changes to something else and this instance still uses the culture from the time it was created. |
How often does the current culture change though? |
In a web app, the culture is tied to the thread of the current request. So, every request can be in a different culture. This means that the instance of Of course, the app also can change the culture of the current thread as needed which can also make the The way Microsoft gets around this issue for its formatters are to make them static methods. |
Tbh I'm fine changing from passing the culture to the constructor to passing it via a parameter, it'll just be a breaking change. Unless we make it optional and keep the constructor one as a fallback. |
When enabling InvariantGlobalization (which I believe is now the default in API/gRPC/Worker project templates), the library fails with:
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.
The text was updated successfully, but these errors were encountered: