-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Incorrect CurrentCulture derived from OS in .NET 8 runtime #110095
Comments
I assume it's the same as here: runtime/src/libraries/Common/src/System/Text/EncodingHelper.Unix.cs Lines 21 to 29 in 35e23f7
But I can't find the exact place that does it.
AFAIR .NET only uses a single culture at once, it has no way to use different cultures for different things without you specifying it manually. |
Tagging subscribers to this area: @dotnet/area-system-globalization |
Thanks, I'll have a look.
Yes, I use The |
.NET depends on the ICU for getting the default locale which is used as CurrentCulture. ICU is using LC_MESSAGES & LC_ALL for picking the default locale. I am closing this issue but feel free to send any more questions we can help with. It only uses LANG as a fallback if |
Thanks for the source code links. But I'm not sure if you fully understand my problem. I want the messages to be in English (en_US) language and all other culture dependent stuff (dates, numbers, ...) to be in Czech (cs_CZ) format. How can I achieve this? Both Linux and Windows systems offer settings where you can configure it that way. It even works in .NET application running in Windows environment. Why doesn't it work on Linux? Why does .NET take only LC_MESSAGES and apply it to everything? |
On Linux, both On Windows, however, the UI culture is configured separately from the current culture settings. Windows uses a distinct mechanism for setting the UI culture. You can still customize this behavior in your code. During your app's initialization, you can read any environment variable of your choice to determine the culture name for both messages and formatting. Then, use |
Oh, I see. So in other words, it's not supported/implemented in .NET running on Linux. That's very unfortunate. I also found this 3 years old issue discussing the same thing. Is this at least planned for a future release? It seems pretty essential to me. |
#61148 issue is specific to We currently have no plans to change this behavior on Linux, but we welcome your feedback. If there’s significant demand, we may consider it in the future. Could you clarify exactly what changes you’re proposing for Linux platforms? |
I'm struggling with incorrect
CurrentCulture
setting coming from the operating system.When preparing the SDK and aspnet images, the required locales are installed and then set via env variables:
This should work so that all the localized values are in the
cs_CZ
locale and only messages (exceptions, dotnet tools messages etc.) are in theen_US
locale. But it doesn't work as expected. Everything is inen_US
locale format (dates, numbers, messages, ...). It's as if thecs_CZ
is not set at all.When I type the
locale
command into the system, it shows:Which seems fine. However, .NET's
CurrentCulture
andCurrentUICulture
both returnen-US
. The only way to change this is to setLC_ALL
tocs_CZ
, but that also changes the language of messages, and of course not only in the .NET application, but also in the tools etc., which I don't want.Why does the .NET 8 not use the
cs_CZ
locale for dates, numbers or anything really?Am I doing something wrong or is this a bug?
How is the
CurrentCulture
determined?Can you point me to some technical documentation or even source code that explains how it's determined from the OS settings?
Thanks in advance.
The text was updated successfully, but these errors were encountered: