fix(i18n): live-refresh smart/virtual list names on language change
All checks were successful
Release / release (push) Successful in 35s
All checks were successful
Release / release (push) Successful in 35s
Smart-list nav labels were localized only at load; subscribe the singleton ListsIslandViewModel to language changes and re-localize names in place. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -162,6 +162,26 @@ public sealed partial class ListsIslandViewModel : ViewModelBase
|
|||||||
_worker.WorktreeUpdatedEvent += _id => _ = RefreshCountsAsync();
|
_worker.WorktreeUpdatedEvent += _id => _ = RefreshCountsAsync();
|
||||||
_worker.ConnectionRestoredEvent += () => _ = RefreshCountsAsync();
|
_worker.ConnectionRestoredEvent += () => _ = RefreshCountsAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loc.LanguageChanged += (_, _) => RefreshLocalizedLabels();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string? SmartListNameKey(string id) => id switch
|
||||||
|
{
|
||||||
|
"smart:my-day" => "vm.lists.smartMyDay",
|
||||||
|
"smart:important" => "vm.lists.smartImportant",
|
||||||
|
"smart:planned" => "vm.lists.smartPlanned",
|
||||||
|
"virtual:queued" => "vm.lists.virtualQueue",
|
||||||
|
"virtual:running" => "vm.lists.virtualRunning",
|
||||||
|
"virtual:review" => "vm.lists.virtualReview",
|
||||||
|
_ => null,
|
||||||
|
};
|
||||||
|
|
||||||
|
private void RefreshLocalizedLabels()
|
||||||
|
{
|
||||||
|
foreach (var item in SmartLists)
|
||||||
|
if (SmartListNameKey(item.Id) is { } key) item.Name = Loc.T(key);
|
||||||
|
OnPropertyChanged(nameof(MachineNameLocal));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task LoadAsync(CancellationToken ct = default)
|
public async Task LoadAsync(CancellationToken ct = default)
|
||||||
|
|||||||
Reference in New Issue
Block a user