Use null as the default locale, which resolves to the current system default locale (#1185)

This commit is contained in:
Oleksii Holub
2024-01-15 23:58:28 +02:00
committed by GitHub
parent 982ba6a76c
commit 057beaacd6
5 changed files with 26 additions and 18 deletions

View File

@@ -9,13 +9,15 @@ public class LocaleToDisplayNameConverter : IValueConverter
{
public static LocaleToDisplayNameConverter Instance { get; } = new();
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
value is string locale ? CultureInfo.GetCultureInfo(locale).DisplayName : null;
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
value is string locale && !string.IsNullOrWhiteSpace(locale)
? CultureInfo.GetCultureInfo(locale).DisplayName
: "System default";
public object ConvertBack(
object value,
object? value,
Type targetType,
object parameter,
object? parameter,
CultureInfo culture
) => throw new NotSupportedException();
}