-
Hi, I have turned on Globalization Invariant Mode in a C# project by adding the following line in my <InvariantGlobalization>true</InvariantGlobalization> However, even after this modification, it happens that exceptions (coming from .NET libraries) are translated (probably based on .NET runtime and its localization or computer localization). Is Thank you! PS: My question might or might not be related to #40427. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Exceptions messages are pulled from .resx files, such as from here: As far as I can tell, there are some translated resx files, such as for source generation and tests, but not for exception messages. There is some information in this issue: #46656 |
Beta Was this translation helpful? Give feedback.
-
To answer the original question in this issue: The resource lookup depends on the CultureInfo. If no specific culture is specified during the resource lookup request, then CultureInfo.CurrentUICulture will be used for the resource lookup. When enabling Globalization Invariant mode, in .NET 6.0 we only support InvariantCulture by default. That means the resource lookup will always be performed using the Invariant culture and most of the resources would be picked up from neutral resources specified by the attribute If you are using .NET 5.0 or NET Core 3.1, then in Invariant mode, we allow creating different cultures and resource lookup will just work as it does in outside Invariant mode. The only difference will be the fallback to parent cultures will not work in the Invariant mode as it is not supported there. |
Beta Was this translation helpful? Give feedback.
To answer the original question in this issue:
The resource lookup depends on the CultureInfo. If no specific culture is specified during the resource lookup request, then CultureInfo.CurrentUICulture will be used for the resource lookup. When enabling Globalization Invariant mode, in .NET 6.0 we only support InvariantCulture by default. That means the resource lookup will always be performed using the Invariant culture and most of the resources would be picked up from neutral resources specified by the attribute
NeutralResourcesLanguageAttribute
on the code assemblies.If you are using .NET 5.0 or NET Core 3.1, then in Invariant mode, we allow creating different cultures and resource loo…