This commit is contained in:
2026-02-23 14:31:48 +08:00
parent 1704ad37d2
commit 4c874fa50b
6 changed files with 277 additions and 60 deletions
@@ -0,0 +1,20 @@
using System;
using System.Windows.Markup;
using Ink_Canvas.Properties;
namespace Ink_Canvas.MarkupExtensions
{
/// <summary>
/// XAML 中用键名取本地化字符串,无需在 Strings.Designer.cs 中为每个键添加属性。
/// 用法:xmlns:i18n="clr-namespace:Ink_Canvas.MarkupExtensions" 然后 Text="{i18n:I18n Key=Settings_Title}"
/// </summary>
public class I18nExtension : MarkupExtension
{
public string Key { get; set; }
public override object ProvideValue(IServiceProvider serviceProvider)
{
return string.IsNullOrEmpty(Key) ? string.Empty : (Strings.GetString(Key) ?? $"#{Key}");
}
}
}