Fixed and guarded the I18N key collection against missing keys (#936)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-08-25 16:53:19 +02:00
1 parent 415ed35422
commit 99089f853e
11 files changed
+164 -34

No files matched your search

@@ -269,11 +269,14 @@ public sealed class GlobalShortcutService : BackgroundService, IMessageBusReceiv
private async Task<string> GetShortcutDescription(Shortcut shortcutId)
{
// Message bus receivers run without being awaited, so I18N.Init in MainLayout may still be
// pending during startup or a plugin reload. Resolve the active language directly to avoid
// using no language or the previously active language for the shortcut description:
var language = await this.settingsManager.GetActiveLanguagePlugin();
return shortcutId switch
{
Shortcut.VOICE_RECORDING_TOGGLE => I18N.I.GetText(language, "Toggle voice recording", typeof(GlobalShortcutService).Namespace, nameof(GlobalShortcutService)),
_ => I18N.I.GetText(language, "Global shortcut", typeof(GlobalShortcutService).Namespace, nameof(GlobalShortcutService)),
Shortcut.VOICE_RECORDING_TOGGLE => TB("Toggle voice recording", language),
_ => TB("Global shortcut", language),
};
}
@@ -320,6 +323,8 @@ public sealed class GlobalShortcutService : BackgroundService, IMessageBusReceiv
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(GlobalShortcutService).Namespace, nameof(GlobalShortcutService));
private static string TB(string fallbackEN, ILanguagePlugin language) => I18N.I.GetText(language, fallbackEN, typeof(GlobalShortcutService).Namespace, nameof(GlobalShortcutService));
private async Task<ShortcutState> GetShortcutState(Shortcut shortcutId, ShortcutSyncSource source)
{
var shortcut = this.GetShortcutValue(shortcutId);