mirror of
https://github.com/jayfunc/BetterLyrics.git
synced 2026-01-12 10:54:55 +08:00
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using BetterLyrics.WinUI3.Helper;
|
|
using BetterLyrics.WinUI3.Services;
|
|
using Microsoft.UI.Xaml.Data;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Windows.Globalization;
|
|
|
|
namespace BetterLyrics.WinUI3.Converter
|
|
{
|
|
public partial class LanguageCodeToDisplayedNameConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, string language)
|
|
{
|
|
if (value is string langCode)
|
|
{
|
|
if (PhoneticHelper.IsPhoneticCode(langCode))
|
|
{
|
|
return PhoneticHelper.GetDisplayName(langCode);
|
|
}
|
|
else
|
|
{
|
|
return new Language(langCode).DisplayName ?? langCode;
|
|
}
|
|
}
|
|
return value?.ToString() ?? "";
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|