From 9f63291fda08c6cee071e0d578db7110fbba07e1 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 20 Jul 2025 09:35:29 +0800 Subject: [PATCH 01/15] Improve setting dialog command --- Plugins/Flow.Launcher.Plugin.Sys/Main.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs index d2dcf6e5a..4f44c033f 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs @@ -404,6 +404,8 @@ namespace Flow.Launcher.Plugin.Sys IcoPath = "Images\\app.png", Action = c => { + // Hide the window first then open setting dialog because main window can be topmost window which will still display on top of the setting dialog for a while + _context.API.HideMainWindow(); _context.API.OpenSettingDialog(); return true; } From 365dd5ee17baf43a5e00d3720a81b1f048da09b2 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 20 Jul 2025 09:42:32 +0800 Subject: [PATCH 02/15] Use translation for constant strings --- Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml | 2 ++ Plugins/Flow.Launcher.Plugin.Sys/Main.cs | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml index ad3f8553b..3c8e37b53 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml @@ -63,6 +63,8 @@ Are you sure you want to restart the computer? Are you sure you want to restart the computer with Advanced Boot Options? Are you sure you want to log off? + Error + Failed to empty the recycle bin. This might happen if:{0}- A file in the recycle bin is in use{0}- You don't have permission to delete some items{0}Please close any applications that might be using these files and try again. Command Keyword Setting Custom Command Keyword diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs index 4f44c033f..0b45b1524 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs @@ -338,11 +338,9 @@ namespace Flow.Launcher.Plugin.Sys var result = PInvoke.SHEmptyRecycleBin(new(), string.Empty, 0); if (result != HRESULT.S_OK && result != HRESULT.E_UNEXPECTED) { - _context.API.ShowMsgBox("Failed to empty the recycle bin. This might happen if:\n" + - "- A file in the recycle bin is in use\n" + - "- You don't have permission to delete some items\n" + - "Please close any applications that might be using these files and try again.", - "Error", + _context.API.ShowMsgBox( + string.Format(_context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_empty_recycle_bin_failed"), Environment.NewLine), + _context.API.GetTranslation("flowlauncher_plugin_sys_dlgtitle_error"), MessageBoxButton.OK, MessageBoxImage.Error); } From 96e6882ec10bd90af9508be373d82ca2b4fd27dc Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 20 Jul 2025 09:50:07 +0800 Subject: [PATCH 03/15] Improve string resource --- Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml index 3c8e37b53..398724f67 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml @@ -64,7 +64,7 @@ Are you sure you want to restart the computer with Advanced Boot Options? Are you sure you want to log off? Error - Failed to empty the recycle bin. This might happen if:{0}- A file in the recycle bin is in use{0}- You don't have permission to delete some items{0}Please close any applications that might be using these files and try again. + Failed to empty the recycle bin. This might happen if:{0}- Some items are currently in use{0}- Some items can't be deleted due to permission{0}Please close any applications that might be using these files and try again. Command Keyword Setting Custom Command Keyword From b6ecfdcf638b13b63bb4ebb901a56fd32309cb31 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 20 Jul 2025 09:58:30 +0800 Subject: [PATCH 04/15] Remove project reference in Sys plugin to Flow.Launcher.Infrastructure --- Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 12 ++++++++++ Flow.Launcher/PublicAPIInstance.cs | 4 ++++ .../Flow.Launcher.Plugin.Sys.csproj | 1 - Plugins/Flow.Launcher.Plugin.Sys/Main.cs | 22 +++++++++---------- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs index cfa813d3f..0238bdc1d 100644 --- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs +++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs @@ -613,5 +613,17 @@ namespace Flow.Launcher.Plugin /// Invoked when the actual theme of the application has changed. Currently, the plugin will continue to be subscribed even if it is turned off. /// event ActualApplicationThemeChangedEventHandler ActualApplicationThemeChanged; + + /// + /// Get the data directory of Flow Launcher. + /// + /// + string GetDataDirectory(); + + /// + /// Get the log directory of Flow Launcher. + /// + /// + string GetLogDirectory(); } } diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index d865a087b..e0ed105cf 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -599,6 +599,10 @@ namespace Flow.Launcher remove => _mainVM.ActualApplicationThemeChanged -= value; } + public string GetDataDirectory() => DataLocation.DataDirectory(); + + public string GetLogDirectory() => DataLocation.VersionLogDirectory; + #endregion #region Private Methods diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj b/Plugins/Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj index 999003fd8..1e2deb558 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj +++ b/Plugins/Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj @@ -37,7 +37,6 @@ - diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs index 0b45b1524..77278a054 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs @@ -5,8 +5,6 @@ using System.Globalization; using System.Linq; using System.Runtime.InteropServices; using System.Windows; -using Flow.Launcher.Infrastructure; -using Flow.Launcher.Infrastructure.UserSettings; using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.Security; @@ -52,6 +50,8 @@ namespace Flow.Launcher.Plugin.Sys private const SHUTDOWN_REASON REASON = SHUTDOWN_REASON.SHTDN_REASON_MAJOR_OTHER | SHUTDOWN_REASON.SHTDN_REASON_FLAG_PLANNED; + private const string Documentation = "https://flowlauncher.com/docs/#/usage-tips"; + private PluginInitContext _context; private Settings _settings; private ThemeSelector _themeSelector; @@ -445,11 +445,11 @@ namespace Flow.Launcher.Plugin.Sys Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xf12b"), Title = "Open Log Location", IcoPath = "Images\\app.png", - CopyText = DataLocation.VersionLogDirectory, - AutoCompleteText = DataLocation.VersionLogDirectory, + CopyText = _context.API.GetLogDirectory(), + AutoCompleteText = _context.API.GetLogDirectory(), Action = c => { - _context.API.OpenDirectory(DataLocation.VersionLogDirectory); + _context.API.OpenDirectory(_context.API.GetLogDirectory()); return true; } }, @@ -458,11 +458,11 @@ namespace Flow.Launcher.Plugin.Sys Title = "Flow Launcher Tips", Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe897"), IcoPath = "Images\\app.png", - CopyText = Constant.Documentation, - AutoCompleteText = Constant.Documentation, + CopyText = Documentation, + AutoCompleteText = Documentation, Action = c => { - _context.API.OpenUrl(Constant.Documentation); + _context.API.OpenUrl(Documentation); return true; } }, @@ -471,11 +471,11 @@ namespace Flow.Launcher.Plugin.Sys Title = "Flow Launcher UserData Folder", Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xf12b"), IcoPath = "Images\\app.png", - CopyText = DataLocation.DataDirectory(), - AutoCompleteText = DataLocation.DataDirectory(), + CopyText = _context.API.GetDataDirectory(), + AutoCompleteText = _context.API.GetDataDirectory(), Action = c => { - _context.API.OpenDirectory(DataLocation.DataDirectory()); + _context.API.OpenDirectory(_context.API.GetDataDirectory()); return true; } }, From 4652392c71e5510c31f491d5c15197efd5c14011 Mon Sep 17 00:00:00 2001 From: Jack Ye <1160210343@qq.com> Date: Sun, 20 Jul 2025 11:29:15 +0800 Subject: [PATCH 05/15] Update translations Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml index 398724f67..56899eef3 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml @@ -64,7 +64,7 @@ Are you sure you want to restart the computer with Advanced Boot Options? Are you sure you want to log off? Error - Failed to empty the recycle bin. This might happen if:{0}- Some items are currently in use{0}- Some items can't be deleted due to permission{0}Please close any applications that might be using these files and try again. + Failed to empty the recycle bin. This might happen if:{0}- Some items are currently in use{0}- Some items can't be deleted due to permissions{0}Please close any applications that might be using these files and try again. Command Keyword Setting Custom Command Keyword From 2ee53dfbf771ba00dc603dff25851a655e302633 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 20 Jul 2025 15:20:18 +0800 Subject: [PATCH 06/15] Initialize language before portable clean up since it needs translations --- Flow.Launcher.Core/Plugin/PluginManager.cs | 2 +- .../Resource/Internationalization.cs | 116 +++++++++++------- Flow.Launcher/App.xaml.cs | 7 +- 3 files changed, 78 insertions(+), 47 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index 9c54ad7b1..8f134c194 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -43,7 +43,7 @@ namespace Flow.Launcher.Core.Plugin /// /// Directories that will hold Flow Launcher plugin directory /// - private static readonly string[] Directories = + public static readonly string[] Directories = { Constant.PreinstalledDirectory, DataLocation.PluginsDirectory }; diff --git a/Flow.Launcher.Core/Resource/Internationalization.cs b/Flow.Launcher.Core/Resource/Internationalization.cs index 256975654..99bc9a844 100644 --- a/Flow.Launcher.Core/Resource/Internationalization.cs +++ b/Flow.Launcher.Core/Resource/Internationalization.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; -using System.Reflection; using System.Threading; using System.Threading.Tasks; using System.Windows; @@ -35,13 +34,6 @@ namespace Flow.Launcher.Core.Resource public Internationalization(Settings settings) { _settings = settings; - AddFlowLauncherLanguageDirectory(); - } - - private void AddFlowLauncherLanguageDirectory() - { - var directory = Path.Combine(Constant.ProgramDirectory, Folder); - _languageDirectories.Add(directory); } public static void InitSystemLanguageCode() @@ -72,35 +64,6 @@ namespace Flow.Launcher.Core.Resource SystemLanguageCode = DefaultLanguageCode; } - private void AddPluginLanguageDirectories() - { - foreach (var plugin in PluginManager.GetTranslationPlugins()) - { - var location = Assembly.GetAssembly(plugin.Plugin.GetType()).Location; - var dir = Path.GetDirectoryName(location); - if (dir != null) - { - var pluginThemeDirectory = Path.Combine(dir, Folder); - _languageDirectories.Add(pluginThemeDirectory); - } - else - { - API.LogError(ClassName, $"Can't find plugin path <{location}> for <{plugin.Metadata.Name}>"); - } - } - - LoadDefaultLanguage(); - } - - 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(); - } - /// /// Initialize language. Will change app language and plugin language based on settings. /// @@ -116,11 +79,73 @@ namespace Flow.Launcher.Core.Resource // Get language by language code and change language var language = GetLanguageByLanguageCode(languageCode); + // Add Flow Launcher language directory + AddFlowLauncherLanguageDirectory(); + // Add plugin language directories first so that we can load language files from plugins AddPluginLanguageDirectories(); + // Load default language resources + LoadDefaultLanguage(); + // Change language - await ChangeLanguageAsync(language); + await ChangeLanguageAsync(language, false); + } + + private void AddFlowLauncherLanguageDirectory() + { + // Check if Flow Launcher language directory exists + var directory = Path.Combine(Constant.ProgramDirectory, Folder); + if (!Directory.Exists(directory)) + { + API.LogError(ClassName, $"Flow Launcher language directory can't be found <{directory}>"); + return; + } + + // Check if the language directory contains default language file + if (!File.Exists(Path.Combine(directory, DefaultFile))) + { + API.LogError(ClassName, $"Default language file can't be found in path <{directory}>"); + return; + } + + _languageDirectories.Add(directory); + } + + private void AddPluginLanguageDirectories() + { + foreach (var pluginsDir in PluginManager.Directories) + { + if (!Directory.Exists(pluginsDir)) continue; + + // Enumerate all top directories in the plugin directory + foreach (var dir in Directory.GetDirectories(pluginsDir)) + { + // Check if the directory contains a language folder + var pluginLanguageDir = Path.Combine(dir, Folder); + if (!Directory.Exists(pluginLanguageDir)) continue; + + // Check if the language directory contains default language file + if (File.Exists(Path.Combine(pluginLanguageDir, DefaultFile))) + { + // Add the plugin language directory to the list + _languageDirectories.Add(pluginLanguageDir); + } + else + { + API.LogError(ClassName, $"Can't find default language file in path <{pluginLanguageDir}>"); + } + } + } + } + + 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(); } /// @@ -152,7 +177,7 @@ namespace Flow.Launcher.Core.Resource private static Language GetLanguageByLanguageCode(string languageCode) { var lowercase = languageCode.ToLower(); - var language = AvailableLanguages.GetAvailableLanguages().FirstOrDefault(o => o.LanguageCode.ToLower() == lowercase); + var language = AvailableLanguages.GetAvailableLanguages().FirstOrDefault(o => o.LanguageCode.Equals(lowercase, StringComparison.CurrentCultureIgnoreCase)); if (language == null) { API.LogError(ClassName, $"Language code can't be found <{languageCode}>"); @@ -164,7 +189,7 @@ namespace Flow.Launcher.Core.Resource } } - private async Task ChangeLanguageAsync(Language language) + private async Task ChangeLanguageAsync(Language language, bool updateMetadata = true) { // Remove old language files and load language RemoveOldLanguageFiles(); @@ -176,8 +201,11 @@ namespace Flow.Launcher.Core.Resource // Change culture info ChangeCultureInfo(language.LanguageCode); - // Raise event for plugins after culture is set - await Task.Run(UpdatePluginMetadataTranslations); + if (updateMetadata) + { + // Raise event for plugins after culture is set + await Task.Run(UpdatePluginMetadataTranslations); + } } public static void ChangeCultureInfo(string languageCode) @@ -212,7 +240,7 @@ namespace Flow.Launcher.Core.Resource // No other languages should show the following text so just make it hard-coded // "Do you want to search with pinyin?" - string text = languageToSet == AvailableLanguages.Chinese ? "是否启用拼音搜索?" : "是否啓用拼音搜索?" ; + string text = languageToSet == AvailableLanguages.Chinese ? "是否启用拼音搜索?" : "是否啓用拼音搜索?"; if (API.ShowMsgBox(text, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No) return false; @@ -276,7 +304,7 @@ namespace Flow.Launcher.Core.Resource } } - private void UpdatePluginMetadataTranslations() + public static void UpdatePluginMetadataTranslations() { // Update plugin metadata name & description foreach (var p in PluginManager.GetTranslationPlugins()) diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index 93fd88e4f..f48829bb3 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -191,6 +191,9 @@ namespace Flow.Launcher // Enable Win32 dark mode if the system is in dark mode before creating all windows Win32Helper.EnableWin32DarkMode(_settings.ColorScheme); + // Initialize language before portable clean up since it needs translations + await Ioc.Default.GetRequiredService().InitializeLanguageAsync(); + Ioc.Default.GetRequiredService().PreStartCleanUpAfterPortabilityUpdate(); API.LogInfo(ClassName, "Begin Flow Launcher startup ----------------------------------------------------"); @@ -216,8 +219,8 @@ namespace Flow.Launcher await PluginManager.InitializePluginsAsync(); - // Change language after all plugins are initialized because we need to update plugin title based on their api - await Ioc.Default.GetRequiredService().InitializeLanguageAsync(); + // Update plugin titles after plugins are initialized with their api instances + Internationalization.UpdatePluginMetadataTranslations(); await imageLoadertask; From 634bdc5bd685c717b6e44b393b9d14a69eacfe99 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 20 Jul 2025 15:26:07 +0800 Subject: [PATCH 07/15] Do not check Flow Launcher default language file since it is binary embedded --- Flow.Launcher.Core/Resource/Internationalization.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Internationalization.cs b/Flow.Launcher.Core/Resource/Internationalization.cs index 99bc9a844..5500f5421 100644 --- a/Flow.Launcher.Core/Resource/Internationalization.cs +++ b/Flow.Launcher.Core/Resource/Internationalization.cs @@ -102,13 +102,6 @@ namespace Flow.Launcher.Core.Resource return; } - // Check if the language directory contains default language file - if (!File.Exists(Path.Combine(directory, DefaultFile))) - { - API.LogError(ClassName, $"Default language file can't be found in path <{directory}>"); - return; - } - _languageDirectories.Add(directory); } From 5e8acf7d747990a76067b636aa773ddecbfbdab3 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 20 Jul 2025 15:29:27 +0800 Subject: [PATCH 08/15] Use OrdinalIgnoreCase --- Flow.Launcher.Core/Resource/Internationalization.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Core/Resource/Internationalization.cs b/Flow.Launcher.Core/Resource/Internationalization.cs index 5500f5421..bd138b179 100644 --- a/Flow.Launcher.Core/Resource/Internationalization.cs +++ b/Flow.Launcher.Core/Resource/Internationalization.cs @@ -170,7 +170,7 @@ namespace Flow.Launcher.Core.Resource private static Language GetLanguageByLanguageCode(string languageCode) { var lowercase = languageCode.ToLower(); - var language = AvailableLanguages.GetAvailableLanguages().FirstOrDefault(o => o.LanguageCode.Equals(lowercase, StringComparison.CurrentCultureIgnoreCase)); + var language = AvailableLanguages.GetAvailableLanguages().FirstOrDefault(o => o.LanguageCode.Equals(lowercase, StringComparison.OrdinalIgnoreCase)); if (language == null) { API.LogError(ClassName, $"Language code can't be found <{languageCode}>"); From ac7da2d2d61092eacc7e1cdee618cef619c3f0ef Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 20 Jul 2025 17:26:14 +0800 Subject: [PATCH 09/15] Do not check if the language directory contains default language file --- Flow.Launcher.Core/Resource/Internationalization.cs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Internationalization.cs b/Flow.Launcher.Core/Resource/Internationalization.cs index bd138b179..10258f080 100644 --- a/Flow.Launcher.Core/Resource/Internationalization.cs +++ b/Flow.Launcher.Core/Resource/Internationalization.cs @@ -118,16 +118,8 @@ namespace Flow.Launcher.Core.Resource var pluginLanguageDir = Path.Combine(dir, Folder); if (!Directory.Exists(pluginLanguageDir)) continue; - // Check if the language directory contains default language file - if (File.Exists(Path.Combine(pluginLanguageDir, DefaultFile))) - { - // Add the plugin language directory to the list - _languageDirectories.Add(pluginLanguageDir); - } - else - { - API.LogError(ClassName, $"Can't find default language file in path <{pluginLanguageDir}>"); - } + // Check if the language directory contains default language file since it will be checked later + _languageDirectories.Add(pluginLanguageDir); } } } From f77f14b0ee19bf0b83f21167cf459e00b80e1a42 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 20 Jul 2025 17:35:07 +0800 Subject: [PATCH 10/15] Improve code quality --- .../Resource/Internationalization.cs | 115 +++++++++++------- 1 file changed, 73 insertions(+), 42 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Internationalization.cs b/Flow.Launcher.Core/Resource/Internationalization.cs index 10258f080..c1e1dbe79 100644 --- a/Flow.Launcher.Core/Resource/Internationalization.cs +++ b/Flow.Launcher.Core/Resource/Internationalization.cs @@ -27,8 +27,8 @@ namespace Flow.Launcher.Core.Resource private const string DefaultFile = "en.xaml"; private const string Extension = ".xaml"; private readonly Settings _settings; - private readonly List _languageDirectories = new(); - private readonly List _oldResources = new(); + private readonly List _languageDirectories = []; + private readonly List _oldResources = []; private static string SystemLanguageCode; public Internationalization(Settings settings) @@ -36,6 +36,11 @@ namespace Flow.Launcher.Core.Resource _settings = settings; } + #region Initialization + + /// + /// Initialize the system language code based on the current culture. + /// public static void InitSystemLanguageCode() { var availableLanguages = AvailableLanguages.GetAvailableLanguages(); @@ -133,6 +138,10 @@ namespace Flow.Launcher.Core.Resource _oldResources.Clear(); } + #endregion + + #region Change Language + /// /// Change language during runtime. Will change app language and plugin language & save settings. /// @@ -213,6 +222,10 @@ namespace Flow.Launcher.Core.Resource thread.CurrentUICulture = currentCulture; } + #endregion + + #region Prompt Pinyin + public bool PromptShouldUsePinyin(string languageCodeToSet) { var languageToSet = GetLanguageByLanguageCode(languageCodeToSet); @@ -233,6 +246,10 @@ namespace Flow.Launcher.Core.Resource return true; } + #endregion + + #region Language Resources Management + private void RemoveOldLanguageFiles() { var dicts = Application.Current.Resources.MergedDictionaries; @@ -268,46 +285,6 @@ namespace Flow.Launcher.Core.Resource } } - public List LoadAvailableLanguages() - { - var list = AvailableLanguages.GetAvailableLanguages(); - list.Insert(0, new Language(Constant.SystemLanguageCode, AvailableLanguages.GetSystemTranslation(SystemLanguageCode))); - return list; - } - - public static string GetTranslation(string key) - { - var translation = Application.Current.TryFindResource(key); - if (translation is string) - { - return translation.ToString(); - } - else - { - API.LogError(ClassName, $"No Translation for key {key}"); - return $"No Translation for key {key}"; - } - } - - public static void UpdatePluginMetadataTranslations() - { - // Update plugin metadata name & description - foreach (var p in PluginManager.GetTranslationPlugins()) - { - if (p.Plugin is not IPluginI18n pluginI18N) return; - try - { - p.Metadata.Name = pluginI18N.GetTranslatedPluginTitle(); - p.Metadata.Description = pluginI18N.GetTranslatedPluginDescription(); - pluginI18N.OnCultureInfoChanged(CultureInfo.CurrentCulture); - } - catch (Exception e) - { - API.LogException(ClassName, $"Failed for <{p.Metadata.Name}>", e); - } - } - } - private static string LanguageFile(string folder, string language) { if (Directory.Exists(folder)) @@ -337,5 +314,59 @@ namespace Flow.Launcher.Core.Resource return string.Empty; } } + + #endregion + + #region Available Languages + + public List LoadAvailableLanguages() + { + var list = AvailableLanguages.GetAvailableLanguages(); + list.Insert(0, new Language(Constant.SystemLanguageCode, AvailableLanguages.GetSystemTranslation(SystemLanguageCode))); + return list; + } + + #endregion + + #region Get Translations + + public static string GetTranslation(string key) + { + var translation = Application.Current.TryFindResource(key); + if (translation is string) + { + return translation.ToString(); + } + else + { + API.LogError(ClassName, $"No Translation for key {key}"); + return $"No Translation for key {key}"; + } + } + + #endregion + + #region Update Metadata + + public static void UpdatePluginMetadataTranslations() + { + // Update plugin metadata name & description + foreach (var p in PluginManager.GetTranslationPlugins()) + { + if (p.Plugin is not IPluginI18n pluginI18N) return; + try + { + p.Metadata.Name = pluginI18N.GetTranslatedPluginTitle(); + p.Metadata.Description = pluginI18N.GetTranslatedPluginDescription(); + pluginI18N.OnCultureInfoChanged(CultureInfo.CurrentCulture); + } + catch (Exception e) + { + API.LogException(ClassName, $"Failed for <{p.Metadata.Name}>", e); + } + } + } + + #endregion } } From fea899d09aa362b2a5285db9ce8936c44a36baa6 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 20 Jul 2025 17:37:12 +0800 Subject: [PATCH 11/15] No need to get lower for language code --- Flow.Launcher.Core/Resource/Internationalization.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Internationalization.cs b/Flow.Launcher.Core/Resource/Internationalization.cs index c1e1dbe79..d2ab2d028 100644 --- a/Flow.Launcher.Core/Resource/Internationalization.cs +++ b/Flow.Launcher.Core/Resource/Internationalization.cs @@ -170,8 +170,8 @@ namespace Flow.Launcher.Core.Resource private static Language GetLanguageByLanguageCode(string languageCode) { - var lowercase = languageCode.ToLower(); - var language = AvailableLanguages.GetAvailableLanguages().FirstOrDefault(o => o.LanguageCode.Equals(lowercase, StringComparison.OrdinalIgnoreCase)); + var language = AvailableLanguages.GetAvailableLanguages(). + FirstOrDefault(o => o.LanguageCode.Equals(languageCode, StringComparison.OrdinalIgnoreCase)); if (language == null) { API.LogError(ClassName, $"Language code can't be found <{languageCode}>"); From b7096ddc321f556f803a240853a468e3fd88759a Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 20 Jul 2025 19:22:14 +0800 Subject: [PATCH 12/15] Fix uri exception in Report window --- Flow.Launcher/ReportWindow.xaml.cs | 43 +++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/Flow.Launcher/ReportWindow.xaml.cs b/Flow.Launcher/ReportWindow.xaml.cs index 24801cf52..ae0767934 100644 --- a/Flow.Launcher/ReportWindow.xaml.cs +++ b/Flow.Launcher/ReportWindow.xaml.cs @@ -1,15 +1,15 @@ -using Flow.Launcher.Core.ExternalPlugins; -using System; +using System; using System.Globalization; using System.IO; -using System.Text; using System.Linq; +using System.Text; using System.Windows; using System.Windows.Documents; +using Flow.Launcher.Core.ExternalPlugins; using Flow.Launcher.Helper; using Flow.Launcher.Infrastructure; -using Flow.Launcher.Plugin.SharedCommands; using Flow.Launcher.Infrastructure.UserSettings; +using Flow.Launcher.Plugin.SharedCommands; namespace Flow.Launcher { @@ -44,7 +44,7 @@ namespace Flow.Launcher var websiteUrl = exception switch { - FlowPluginException pluginException =>GetIssuesUrl(pluginException.Metadata.Website), + FlowPluginException pluginException => GetIssuesUrl(pluginException.Metadata.Website), _ => Constant.IssuesUrl }; @@ -73,17 +73,36 @@ namespace Flow.Launcher Margin = new Thickness(0) }; - var link = new Hyperlink + Hyperlink link = null; + try { - IsEnabled = true - }; - link.Inlines.Add(url); - link.NavigateUri = new Uri(url); - link.Click += (s, e) => SearchWeb.OpenInBrowserTab(url); + var uri = new Uri(url); + + link = new Hyperlink + { + IsEnabled = true + }; + link.Inlines.Add(url); + link.NavigateUri = uri; + link.Click += (s, e) => SearchWeb.OpenInBrowserTab(url); + } + catch (Exception) + { + // Leave link as null if the URL is invalid + } paragraph.Inlines.Add(textBeforeUrl); paragraph.Inlines.Add(" "); - paragraph.Inlines.Add(link); + if (link is null) + { + // Add the URL as plain text if it is invalid + paragraph.Inlines.Add(url); + } + else + { + // Add the hyperlink if it is valid + paragraph.Inlines.Add(link); + } paragraph.Inlines.Add("\n"); return paragraph; From df0f8e01b95568a8bad0653b9aa5b2f267040c78 Mon Sep 17 00:00:00 2001 From: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com> Date: Mon, 21 Jul 2025 08:58:12 +0800 Subject: [PATCH 13/15] Fix typo --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 39e2a114c..a4a8e6f16 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -76,7 +76,7 @@ deploy: This build includes new changes from commit: $(APPVEYOR_REPO_COMMIT_MESSAGE) - See all changes in this early access by going to the [milstones](https://github.com/Flow-Launcher/Flow.Launcher/milestones?sort=title&direction=asc) section and choosing the upcoming milestone. + See all changes in this early access by going to the [milestones](https://github.com/Flow-Launcher/Flow.Launcher/milestones?sort=title&direction=asc) section and choosing the upcoming milestone. For latest production release visit [here](https://github.com/Flow-Launcher/Flow.Launcher/releases/latest) Please report any bugs or issues over at the [main repository](https://github.com/Flow-Launcher/Flow.Launcher/issues)' From d8740768c72885f6fa4726e4f716e381173f2f67 Mon Sep 17 00:00:00 2001 From: Jeremy Wu Date: Mon, 21 Jul 2025 21:33:57 +1000 Subject: [PATCH 14/15] wording --- Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs index 0238bdc1d..dcccaebeb 100644 --- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs +++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs @@ -615,7 +615,7 @@ namespace Flow.Launcher.Plugin event ActualApplicationThemeChangedEventHandler ActualApplicationThemeChanged; /// - /// Get the data directory of Flow Launcher. + /// Get the user data directory of Flow Launcher. /// /// string GetDataDirectory(); From ea7833efe463213c7ee6ff633816bf2d1dfa9deb Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Tue, 22 Jul 2025 19:15:54 +0800 Subject: [PATCH 15/15] Add glyph for dialog jump hotkey card item --- Flow.Launcher/SettingPages/Views/SettingsPaneHotkey.xaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneHotkey.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneHotkey.xaml index c69053629..d82d6baa0 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneHotkey.xaml +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneHotkey.xaml @@ -76,6 +76,7 @@