Open Source Web Application Framework for ASP.NET Core
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

34 lines
833 B

using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using Volo.Abp;
namespace Volo.CmsKit.Web.Icons;
public class LocalizableIconDictionary : Dictionary<string, string>
{
[NotNull]
public string Default {
get => _default;
set => _default = Check.NotNullOrWhiteSpace(value, nameof(value));
}
private string _default;
public LocalizableIconDictionary([NotNull] string defaultIcon)
{
Default = defaultIcon;
}
public string GetLocalizedIconOrDefault(string cultureName = null)
{
cultureName ??= CultureInfo.CurrentUICulture.Name;
var localizedIcon = this.GetOrDefault(cultureName);
if (localizedIcon != null)
{
return localizedIcon;
}
return Default;
}
}