1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-09-27 03:52:57 +02:00
bitwarden-mobile/src/Core/Utilities/LocalizableEnumConverter.cs

25 lines
777 B
C#

using System;
using Microsoft.Maui.Controls;
using Microsoft.Maui;
namespace Bit.App.Utilities
{
/// <summary>
/// It localizes an enum value by using the <see cref="Core.Attributes.LocalizableEnumAttribute"/>
/// </summary>
public class LocalizableEnumConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
return value != null ? EnumHelper.GetLocalizedValue(value, value.GetType()) : string.Empty;
}
public object ConvertBack(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
}
}