Add translations & Use ShowMsgError

This commit is contained in:
Jack251970 2025-07-20 12:28:55 +08:00
parent aed134f589
commit ba0a113cc9
15 changed files with 39 additions and 35 deletions

View file

@ -719,7 +719,7 @@ namespace Flow.Launcher.Core.Plugin
catch (Exception e)
{
API.LogException(ClassName, $"Failed to delete plugin settings folder for {plugin.Name}", e);
API.ShowMsg(API.GetTranslation("failedToRemovePluginSettingsTitle"),
API.ShowMsgError(API.GetTranslation("failedToRemovePluginSettingsTitle"),
string.Format(API.GetTranslation("failedToRemovePluginSettingsMessage"), plugin.Name));
}
}
@ -735,7 +735,7 @@ namespace Flow.Launcher.Core.Plugin
catch (Exception e)
{
API.LogException(ClassName, $"Failed to delete plugin cache folder for {plugin.Name}", e);
API.ShowMsg(API.GetTranslation("failedToRemovePluginCacheTitle"),
API.ShowMsgError(API.GetTranslation("failedToRemovePluginCacheTitle"),
string.Format(API.GetTranslation("failedToRemovePluginCacheMessage"), plugin.Name));
}
Settings.RemovePluginSettings(plugin.ID);

View file

@ -111,7 +111,7 @@ namespace Flow.Launcher.Core
}
if (!silentUpdate)
_api.ShowMsg(_api.GetTranslation("update_flowlauncher_fail"),
_api.ShowMsgError(_api.GetTranslation("update_flowlauncher_fail"),
_api.GetTranslation("update_flowlauncher_check_connection"));
}
finally

View file

@ -82,7 +82,7 @@ namespace Flow.Launcher.Infrastructure.Http
}
catch (UriFormatException e)
{
API.ShowMsg(API.GetTranslation("pleaseTryAgain"), API.GetTranslation("parseProxyFailed"));
API.ShowMsgError(API.GetTranslation("pleaseTryAgain"), API.GetTranslation("parseProxyFailed"));
Log.Exception(ClassName, "Unable to parse Uri", e);
}
}

View file

@ -267,7 +267,7 @@ namespace Flow.Launcher
// but if it fails (permissions, etc) then don't keep retrying
// this also gives the user a visual indication in the Settings widget
_settings.StartFlowLauncherOnSystemStartup = false;
API.ShowMsg(API.GetTranslation("setAutoStartFailed"), e.Message);
API.ShowMsgError(API.GetTranslation("setAutoStartFailed"), e.Message);
}
}
}

View file

@ -59,7 +59,7 @@ namespace Flow.Launcher.Resources.Pages
}
catch (Exception e)
{
App.API.ShowMsg(App.API.GetTranslation("setAutoStartFailed"), e.Message);
App.API.ShowMsgError(App.API.GetTranslation("setAutoStartFailed"), e.Message);
}
}

View file

@ -64,7 +64,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
}
catch (Exception e)
{
App.API.ShowMsg(App.API.GetTranslation("setAutoStartFailed"), e.Message);
App.API.ShowMsgError(App.API.GetTranslation("setAutoStartFailed"), e.Message);
}
}
}
@ -91,7 +91,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
}
catch (Exception e)
{
App.API.ShowMsg(App.API.GetTranslation("setAutoStartFailed"), e.Message);
App.API.ShowMsgError(App.API.GetTranslation("setAutoStartFailed"), e.Message);
}
}
}
@ -217,7 +217,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
else
{
// Since this is rarely seen text, language support is not provided.
App.API.ShowMsg(App.API.GetTranslation("KoreanImeSettingChangeFailTitle"), App.API.GetTranslation("KoreanImeSettingChangeFailSubTitle"));
App.API.ShowMsgError(App.API.GetTranslation("KoreanImeSettingChangeFailTitle"), App.API.GetTranslation("KoreanImeSettingChangeFailSubTitle"));
}
}
}

View file

@ -7,6 +7,9 @@
<system:String x:Key="flowlauncher_plugin_browserbookmark_plugin_name">Browser Bookmarks</system:String>
<system:String x:Key="flowlauncher_plugin_browserbookmark_plugin_description">Search your browser bookmarks</system:String>
<!-- Main -->
<system:String x:Key="flowlauncher_plugin_browserbookmark_copy_failed">Failed to set url in clipboard</system:String>
"
<!-- Settings -->
<system:String x:Key="flowlauncher_plugin_browserbookmark_bookmarkDataSetting">Bookmark Data</system:String>
<system:String x:Key="flowlauncher_plugin_browserbookmark_settings_openBookmarks">Open bookmarks in:</system:String>

View file

@ -223,11 +223,8 @@ public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContex
}
catch (Exception e)
{
var message = "Failed to set url in clipboard";
_context.API.LogException(ClassName, message, e);
_context.API.ShowMsg(message);
_context.API.LogException(ClassName, "Failed to set url in clipboard", e);
_context.API.ShowMsgError(_context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copy_failed"));
return false;
}
},

View file

@ -132,9 +132,8 @@ namespace Flow.Launcher.Plugin.Explorer
}
catch (Exception e)
{
var message = "Fail to set text in clipboard";
LogException(message, e);
Context.API.ShowMsg(message);
LogException("Fail to set text in clipboard", e);
Context.API.ShowMsgError(Context.API.GetTranslation("plugin_explorer_fail_to_set_text"));
return false;
}
},
@ -155,9 +154,8 @@ namespace Flow.Launcher.Plugin.Explorer
}
catch (Exception e)
{
var message = "Fail to set text in clipboard";
LogException(message, e);
Context.API.ShowMsg(message);
LogException("Fail to set text in clipboard", e);
Context.API.ShowMsgError(Context.API.GetTranslation("plugin_explorer_fail_to_set_text"));
return false;
}
},
@ -178,9 +176,8 @@ namespace Flow.Launcher.Plugin.Explorer
}
catch (Exception e)
{
var message = $"Fail to set file/folder in clipboard";
LogException(message, e);
Context.API.ShowMsg(message);
LogException($"Fail to set file/folder in clipboard", e);
Context.API.ShowMsgError(Context.API.GetTranslation("plugin_explorer_fail_to_set_files"));
return false;
}

View file

@ -135,6 +135,8 @@
<system:String x:Key="plugin_explorer_fail_to_delete">Fail to delete {0}</system:String>
<system:String x:Key="plugin_explorer_file_not_found">File not found: {0}</system:String>
<system:String x:Key="plugin_explorer_fail_to_open">Fail to open {0}</system:String>
<system:String x:Key="plugin_explorer_fail_to_set_text">Fail to set text in clipboard</system:String>
<system:String x:Key="plugin_explorer_fail_to_set_files">Fail to set files/folders in clipboard</system:String>
<!-- Special Results -->
<system:String x:Key="plugin_explorer_diskfreespace">{0} free of {1}</system:String>

View file

@ -446,7 +446,7 @@ namespace Flow.Launcher.Plugin.Program
var title = Context.API.GetTranslation("flowlauncher_plugin_program_disable_dlgtitle_error");
var message = string.Format(Context.API.GetTranslation("flowlauncher_plugin_program_run_failed"),
info.FileName);
Context.API.ShowMsg(title, string.Format(message, info.FileName), string.Empty);
Context.API.ShowMsgError(title, string.Format(message, info.FileName));
}
}

View file

@ -462,7 +462,7 @@ namespace Flow.Launcher.Plugin.Program.Programs
var message =
api.GetTranslation(
"flowlauncher_plugin_program_run_as_administrator_not_supported_message");
api.ShowMsg(title, message, string.Empty);
api.ShowMsgError(title, message);
}
return true;

View file

@ -1,6 +1,7 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="flowlauncher_plugin_cmd_relace_winr">Replace Win+R</system:String>
<system:String x:Key="flowlauncher_plugin_cmd_close_cmd_after_press">Close Command Prompt after pressing any key</system:String>
@ -16,4 +17,6 @@
<system:String x:Key="flowlauncher_plugin_cmd_run_as_administrator">Run As Administrator</system:String>
<system:String x:Key="flowlauncher_plugin_cmd_copy">Copy the command</system:String>
<system:String x:Key="flowlauncher_plugin_cmd_history">Only show number of most used commands:</system:String>
<system:String x:Key="flowlauncher_plugin_cmd_command_not_found">Command not found: {0}</system:String>
<system:String x:Key="flowlauncher_plugin_cmd_error_running_command">Error running the command: {0}"</system:String>
</ResourceDictionary>

View file

@ -335,15 +335,17 @@ namespace Flow.Launcher.Plugin.Shell
}
catch (FileNotFoundException e)
{
var name = "Plugin: Shell";
var message = $"Command not found: {e.Message}";
Context.API.ShowMsg(name, message);
Context.API.ShowMsgError(GetTranslatedPluginTitle(),
string.Format(Context.API.GetTranslation("flowlauncher_plugin_cmd_command_not_found"), e.Message));
}
catch (Win32Exception e)
{
var name = "Plugin: Shell";
var message = $"Error running the command: {e.Message}";
Context.API.ShowMsg(name, message);
Context.API.ShowMsgError(GetTranslatedPluginTitle(),
string.Format(Context.API.GetTranslation("flowlauncher_plugin_cmd_error_running_command"), e.Message));
}
catch (Exception e)
{
Context.API.LogException(ClassName, $"Error executing command: {info.FileName} {string.Join(" ", info.ArgumentList)}", e);
}
}

View file

@ -70,7 +70,7 @@ namespace Flow.Launcher.Plugin.Url
}
catch(Exception)
{
context.API.ShowMsg(string.Format(context.API.GetTranslation("flowlauncher_plugin_url_cannot_open_url"), raw));
context.API.ShowMsgError(string.Format(context.API.GetTranslation("flowlauncher_plugin_url_cannot_open_url"), raw));
return false;
}
}