Skip to content

Breaking change for value returned from CurrentUICulture on Windows #37146

Closed
@batzen

Description

@batzen

Description

In previous versions of .NET (including core) CultureInfo.CurrentUICulture returned the UI language i chose for displaying on Windows.
Starting with .NET 5.0 this is no longer the case and instead my chosen region format is returned.
I think this is a huge breaking change.
I first noticed this when installing the preview SDK version, compiled and received all output in german, which is definitely not what i want.

Configuration

Windows settings:
image
image

Other information

Sample program:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>net48;netcoreapp3.1;net5.0</TargetFrameworks>
  </PropertyGroup>

</Project>
using System;

namespace locale_tests
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("System.Globalization.CultureInfo:");
            Console.WriteLine("CurrentCulture      : " + System.Globalization.CultureInfo.CurrentCulture);
            Console.WriteLine("CurrentCulture   (F): " + System.Globalization.CultureInfo.CurrentCulture.GetConsoleFallbackUICulture());
            Console.WriteLine("CurrentUICulture    : " + System.Globalization.CultureInfo.CurrentUICulture);
            Console.WriteLine("CurrentUICulture (F): " + System.Globalization.CultureInfo.CurrentUICulture.GetConsoleFallbackUICulture());
        }
    }
}

Output with net48 is:

PS C:\DEV\Projects\locale_tests> dotnet run -f net48
System.Globalization.CultureInfo:
CurrentCulture      : de-DE      
CurrentCulture   (F): de-DE      
CurrentUICulture    : en-US      
CurrentUICulture (F): en-US   

Output with netcoreapp3.1 is:

PS C:\DEV\Projects\locale_tests> dotnet run -f netcoreapp3.1
System.Globalization.CultureInfo:
CurrentCulture      : de-DE      
CurrentCulture   (F): de-DE      
CurrentUICulture    : en-US      
CurrentUICulture (F): en-US   

Output with net5.0 is (5.0.100-preview.4.20258.7):

PS C:\DEV\Projects\locale_tests> dotnet run -f net5.0       
System.Globalization.CultureInfo:
CurrentCulture      : de-DE      
CurrentCulture   (F): de-DE      
CurrentUICulture    : de-DE      
CurrentUICulture (F): de-DE    

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions