Files
Better-Seewo/Better-EN5/UIItemManagerExtensions.cs

36 lines
1.1 KiB
C#

using System.Collections.Generic;
using System.Windows;
using System.Windows.Threading;
using Cvte.EasiNote;
using Cvte.Windows.Localization;
namespace BetterEN5
{
static class UIItemManagerExtensions
{
public static void AppendWithLang(this IUIItemManager manager, UIItem item,
UIItemAttribute attribute, IList<UIItemLangInfo> langInfoList)
{
manager.Append(c => item, attribute);
var purpose = attribute.Purposes[0];
var prefix = purpose == UIItemPurposes.BoardEditMenu ? "BoardEditContextMenu" : purpose;
var key = $"Lang.{prefix}.{item.GetType().Name}";
Application.Current.Dispatcher.InvokeAsync(() =>
{
foreach (var langInfo in langInfoList)
{
Lang.Sources.Add(new DictionaryLanguageSource
{
[langInfo.CultureInfo] = new Dictionary<string, string>
{
{ key, langInfo.LangText }
},
});
}
}, DispatcherPriority.Send);
}
}
}