2026-06-28 01:43:01 +08:00
|
|
|
using System;
|
|
|
|
|
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);
|
|
|
|
|
|
2026-06-28 02:43:22 +08:00
|
|
|
var purpose = attribute.Purposes[0];
|
2026-06-28 01:43:01 +08:00
|
|
|
string menuName;
|
2026-06-28 02:43:22 +08:00
|
|
|
if (purpose == UIItemPurposes.BoardEditMenu)
|
2026-06-28 01:43:01 +08:00
|
|
|
{
|
|
|
|
|
menuName = "BoardEditContextMenu";
|
|
|
|
|
}
|
2026-06-28 02:43:22 +08:00
|
|
|
else if (purpose == UIItemPurposes.HeadToolBar)
|
|
|
|
|
{
|
|
|
|
|
menuName = "HeadToolBar";
|
|
|
|
|
}
|
2026-06-28 01:43:01 +08:00
|
|
|
else
|
|
|
|
|
{
|
2026-06-28 02:43:22 +08:00
|
|
|
menuName = purpose.Replace(".", "_");
|
2026-06-28 01:43:01 +08:00
|
|
|
}
|
|
|
|
|
|
2026-06-28 02:43:22 +08:00
|
|
|
var itemLangKey = item.GetType().Name.Replace("MenuItem", "").Replace("HeadToolBar", "").Replace("ApplicationMenu", "").Replace("ExtendedTitleBar", "");
|
2026-06-28 01:43:01 +08:00
|
|
|
var langKey = $"Lang.{menuName}.{itemLangKey}";
|
|
|
|
|
|
|
|
|
|
Application.Current.Dispatcher.InvokeAsync(() =>
|
|
|
|
|
{
|
|
|
|
|
foreach (var langInfo in langInfoList)
|
|
|
|
|
{
|
|
|
|
|
Lang.Sources.Add(new DictionaryLanguageSource
|
|
|
|
|
{
|
|
|
|
|
[langInfo.CultureInfo] = new Dictionary<string, string>()
|
|
|
|
|
{
|
|
|
|
|
{ langKey, langInfo.LangText },
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, DispatcherPriority.Send);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|