Add conditional check for plugin hotkey updates

Previously, `UpdatePluginHotkeyInfoTranslations` was called for all plugins, even those without hotkey support. This commit adds a conditional check to ensure the method is only invoked for plugins implementing the `IPluginHotkey` interface.

Additionally, comments were added to clarify the purpose of the hotkey update logic. These changes improve robustness by preventing unnecessary or invalid calls for non-hotkey plugins.
This commit is contained in:
Jack251970 2025-10-16 20:36:55 +08:00
parent f6759a50d3
commit e3306ecfe8

View file

@ -360,7 +360,7 @@ namespace Flow.Launcher.Core.Resource
public static void UpdatePluginMetadataTranslations()
{
// Update plugin metadata name & description & plugin hotkey name & description
// Update plugin metadata name & description
foreach (var p in PluginManager.GetTranslationPlugins())
{
if (p.Plugin is not IPluginI18n pluginI18N) return;
@ -368,7 +368,11 @@ namespace Flow.Launcher.Core.Resource
{
p.Metadata.Name = pluginI18N.GetTranslatedPluginTitle();
p.Metadata.Description = pluginI18N.GetTranslatedPluginDescription();
PluginManager.UpdatePluginHotkeyInfoTranslations(p);
if (p.Plugin is IPluginHotkey)
{
// Update plugin hotkey name & description
PluginManager.UpdatePluginHotkeyInfoTranslations(p);
}
pluginI18N.OnCultureInfoChanged(CultureInfo.CurrentCulture);
}
catch (Exception e)
@ -386,7 +390,11 @@ namespace Flow.Launcher.Core.Resource
{
p.Metadata.Name = pluginI18N.GetTranslatedPluginTitle();
p.Metadata.Description = pluginI18N.GetTranslatedPluginDescription();
PluginManager.UpdatePluginHotkeyInfoTranslations(p);
if (p.Plugin is IPluginHotkey)
{
// Update plugin hotkey name & description
PluginManager.UpdatePluginHotkeyInfoTranslations(p);
}
pluginI18N.OnCultureInfoChanged(CultureInfo.CurrentCulture);
}
catch (Exception e)