CultureInfo.InstalledUICulture
for system install language
CultureInfo.CurrentCulture
for user regional settings (numeric formatting preference)
CultureInfo.CurrentUICulture
for current user language
The current thread gets its culture info on startup from its launching thread and it can be "changed from within" like this CultureInfo.CurrentUICulture = new CultureInfo("en-GB");
but to detect "change from without" you need to ask Windows. Here is a simple demo calling GetUserDefaultLCID()
using P/Invoke.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
namespace ConsoleApp2
{
class Program
{
private static readonly Dictionary<uint, CultureInfo> Cultures;
static Program()
{
Cultures = new Dictionary<uint, CultureInfo>
{ // These just happen to be what I have installed
{ 0x0809, new CultureInfo("en-GB") },
{ 0x0409, new CultureInfo("en-US") },
{ 0x1C09, new CultureInfo("en-ZA") }
};
}
[DllImport("kernel32.dll")] static extern uint GetUserDefaultLCID();
static void MonitorCulture()
{
while (true)
{
Console.WriteLine($"CurrentUICulture : {Cultures[GetUserDefaultLCID()].EnglishName}");
Thread.Sleep(2000);
}
}
static void Main(string[] args)
{
var monitor = new Thread(MonitorCulture);
monitor.Start();
Console.WriteLine("Press a key to exit...");
Console.ReadKey();
}
}
}
Which produced this: [1]: https://i.stack.imgur.com/Sou6y.png as I changed Language while the program was running.