From 81e5eaf10d66370d6a672a8cd0860f64f0380655 Mon Sep 17 00:00:00 2001 From: Yusyuriv Date: Sat, 10 Aug 2024 09:23:47 +0600 Subject: [PATCH 1/3] Fix startup localization issues --- Flow.Launcher.Core/Plugin/PluginManager.cs | 4 ++-- Flow.Launcher.Core/Resource/Internationalization.cs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index f5fa5e51818..2223ceca61b 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -1,4 +1,4 @@ -using Flow.Launcher.Core.ExternalPlugins; +using Flow.Launcher.Core.ExternalPlugins; using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -308,7 +308,7 @@ public static PluginPair GetPluginForId(string id) public static IEnumerable GetPluginsForInterface() where T : IFeatures { - return AllPlugins.Where(p => p.Plugin is T); + return AllPlugins?.Where(p => p.Plugin is T) ?? Array.Empty(); } public static List GetContextMenusForPlugin(Result result) diff --git a/Flow.Launcher.Core/Resource/Internationalization.cs b/Flow.Launcher.Core/Resource/Internationalization.cs index 192ed2e8142..0a68805a761 100644 --- a/Flow.Launcher.Core/Resource/Internationalization.cs +++ b/Flow.Launcher.Core/Resource/Internationalization.cs @@ -58,6 +58,7 @@ internal void AddPluginLanguageDirectories(IEnumerable plugins) private void LoadDefaultLanguage() { + RemoveOldLanguageFiles(); LoadLanguage(AvailableLanguages.English); _oldResources.Clear(); } From 7e3690f007e9240b9adc27b3e762a07a4d6d4ff5 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sun, 11 Aug 2024 20:54:10 +1000 Subject: [PATCH 2/3] add comment --- Flow.Launcher.Core/Resource/Internationalization.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Flow.Launcher.Core/Resource/Internationalization.cs b/Flow.Launcher.Core/Resource/Internationalization.cs index 0a68805a761..f6f35589d8d 100644 --- a/Flow.Launcher.Core/Resource/Internationalization.cs +++ b/Flow.Launcher.Core/Resource/Internationalization.cs @@ -58,6 +58,8 @@ internal void AddPluginLanguageDirectories(IEnumerable plugins) private void LoadDefaultLanguage() { + // Removes language files loaded before any plugins were loaded. + // Prevents the language Flow started in from overwriting English if the user switches back to English RemoveOldLanguageFiles(); LoadLanguage(AvailableLanguages.English); _oldResources.Clear(); From 89e430f41f2cc1f785446de60f7e32f95b3e75ec Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Sun, 11 Aug 2024 20:56:03 +1000 Subject: [PATCH 3/3] add comment --- Flow.Launcher.Core/Plugin/PluginManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index 2223ceca61b..91cb36a0e3c 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -308,6 +308,7 @@ public static PluginPair GetPluginForId(string id) public static IEnumerable GetPluginsForInterface() where T : IFeatures { + // Handle scenario where this is called before all plugins are instantiated, e.g. language change on startup return AllPlugins?.Where(p => p.Plugin is T) ?? Array.Empty(); }