Home > OS >  Upgrade from .Net Core 2.2 to 3.1 changed culture detection on Ubuntu
Upgrade from .Net Core 2.2 to 3.1 changed culture detection on Ubuntu

Time:12-26

I have an ASP.Net Core app that I just upgraded from 2.2 to 3.1 as part of an effort to get to the latest version.

Everything is running correctly, except my numbers are now formatted differently.

Instead of showing a "$" in front of currencies, I now see "¤" (and I'm there are many other changes such as string comparison, etc).

It appears my Culture changed from English (United States, Computer) to .

Where does the default culture come from? I've searched quite a bit and there are many topics about how to set the culture in code, etc. That's not what I'm looking for.

I want to know how .Net is determining a culture when you do nothing explicitly to set it since that his how the app was running previously. And more importantly, what would need to be adjusted to return the culture to how it was working previously without having to explicitly set it in code.

Below is the value of locale

$ locale
LANG=C.UTF-8
LANGUAGE=
LC_CTYPE="C.UTF-8"
LC_NUMERIC="C.UTF-8"
LC_TIME="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_MONETARY="C.UTF-8"
LC_MESSAGES="C.UTF-8"
LC_PAPER="C.UTF-8"
LC_NAME="C.UTF-8"
LC_ADDRESS="C.UTF-8"
LC_TELEPHONE="C.UTF-8"
LC_MEASUREMENT="C.UTF-8"
LC_IDENTIFICATION="C.UTF-8"
LC_ALL=

If I run a simple .Net program to print out the Culture, etc.

static void Main(string[] args) {
    Console.WriteLine($"CurrentCulture   = {CultureInfo.CurrentCulture.Name}");
    Console.WriteLine($"CurrentUICulture = {CultureInfo.CurrentUICulture.Name}");
    Console.WriteLine($"{RegionInfo.CurrentRegion}");
}

...this is what I get

CurrentCulture   =
CurrentUICulture =
IV

CodePudding user response:

It seems no locales are set on systems. You can check the blogs and set locales.

enter image description here

Related issue

asp.net core linux - CultureInfo get country code

  • Related