I have deployed my .NET Core (v2.1) application onto my Ubuntu server (Ubuntu 18.04 LTS). The application target audience are UK based.
In C# I am doing:
@invoice.Amount.ToString("C")
Which formats the value as a currency based on system culture and should show something like £107.50, instead I get $107.50.
I checked the locale and I had en_US so I ran update-locale LANG=en_GB.utf8 and I restarted everything (kestrel, nginx and session). Now when I run the locale command, I get:
LANG=en_GB.utf8
LANGUAGE=
LC_CTYPE="en_GB.utf8"
LC_NUMERIC="en_GB.utf8"
LC_TIME="en_GB.utf8"
LC_COLLATE="en_GB.utf8"
LC_MONETARY="en_GB.utf8"
LC_MESSAGES="en_GB.utf8"
LC_PAPER="en_GB.utf8"
LC_NAME="en_GB.utf8"
LC_ADDRESS="en_GB.utf8"
LC_TELEPHONE="en_GB.utf8"
LC_MEASUREMENT="en_GB.utf8"
LC_IDENTIFICATION="en_GB.utf8"
LC_ALL=
But still, I get $107.50 instead of £107.50. What am I missing?
ToString(method inC#should accept second parameter, try@invoice.Amount.ToString("C",CultureInfo.CurrentCulture)or@invoice.Amount.ToString("C",CultureInfo.CurrentUICulture)or@invoice.Amount.ToString("C",CultureInfo.GetCultureInfo('en-GB'))or@invoice.Amount.ToString("C",CultureInfo.CreateSpecificCulture('en-GB')). Might requireusing System.Globalization.