feat(i18n): add Avalonia loc:Tr markup extension and LocalizedString
This commit is contained in:
22
src/ClaudeDo.Ui/Localization/LocalizedString.cs
Normal file
22
src/ClaudeDo.Ui/Localization/LocalizedString.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.ComponentModel;
|
||||
using ClaudeDo.Localization;
|
||||
|
||||
namespace ClaudeDo.Ui.Localization;
|
||||
|
||||
public sealed class LocalizedString : INotifyPropertyChanged
|
||||
{
|
||||
private readonly ILocalizer _localizer;
|
||||
private readonly string _key;
|
||||
|
||||
public LocalizedString(ILocalizer localizer, string key)
|
||||
{
|
||||
_localizer = localizer;
|
||||
_key = key;
|
||||
_localizer.LanguageChanged += (_, _) =>
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Value)));
|
||||
}
|
||||
|
||||
public string Value => _localizer[_key];
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
}
|
||||
Reference in New Issue
Block a user