Use Flow.Launcher.Localization to improve code quality

This commit is contained in:
Jack251970 2025-09-21 11:50:51 +08:00
parent a2c11af82b
commit 78e5bf2a60
16 changed files with 134 additions and 153 deletions

View file

@ -104,7 +104,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" /> <PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
<PackageReference Include="Flow.Launcher.Localization" Version="0.0.5" /> <PackageReference Include="Flow.Launcher.Localization" Version="0.0.6" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.9" /> <PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.9" />
<PackageReference Include="Svg.Skia" Version="3.0.6" /> <PackageReference Include="Svg.Skia" Version="3.0.6" />
<PackageReference Include="SkiaSharp" Version="3.119.0" /> <PackageReference Include="SkiaSharp" Version="3.119.0" />

View file

@ -63,7 +63,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Flow.Launcher.Localization" Version="0.0.5" /> <PackageReference Include="Flow.Launcher.Localization" Version="0.0.6" />
<PackageReference Include="Mages" Version="3.0.0" /> <PackageReference Include="Mages" Version="3.0.0" />
</ItemGroup> </ItemGroup>

View file

@ -66,8 +66,8 @@ namespace Flow.Launcher.Plugin.Explorer
{ {
contextMenus.Add(new Result contextMenus.Add(new Result
{ {
Title = Context.API.GetTranslation("plugin_explorer_add_to_quickaccess_title"), Title = Localize.plugin_explorer_add_to_quickaccess_title(),
SubTitle = Context.API.GetTranslation("plugin_explorer_add_to_quickaccess_subtitle"), SubTitle = Localize.plugin_explorer_add_to_quickaccess_subtitle(),
Action = (context) => Action = (context) =>
{ {
Settings.QuickAccessLinks.Add(new AccessLink Settings.QuickAccessLinks.Add(new AccessLink
@ -77,16 +77,14 @@ namespace Flow.Launcher.Plugin.Explorer
Type = record.Type Type = record.Type
}); });
Context.API.ShowMsg(Context.API.GetTranslation("plugin_explorer_addfilefoldersuccess"), Context.API.ShowMsg(Localize.plugin_explorer_addfilefoldersuccess(),
Context.API.GetTranslation("plugin_explorer_addfilefoldersuccess_detail"), Localize.plugin_explorer_addfilefoldersuccess_detail(),
Constants.ExplorerIconImageFullPath); Constants.ExplorerIconImageFullPath);
return true; return true;
}, },
SubTitleToolTip = Context.API.GetTranslation("plugin_explorer_contextmenu_titletooltip"), SubTitleToolTip = Localize.plugin_explorer_contextmenu_titletooltip(),
TitleToolTip = Context.API.GetTranslation("plugin_explorer_contextmenu_titletooltip"), TitleToolTip = Localize.plugin_explorer_contextmenu_titletooltip(),
IcoPath = Constants.QuickAccessImagePath, IcoPath = Constants.QuickAccessImagePath,
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\ue718"), Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\ue718"),
}); });
@ -95,22 +93,20 @@ namespace Flow.Launcher.Plugin.Explorer
{ {
contextMenus.Add(new Result contextMenus.Add(new Result
{ {
Title = Context.API.GetTranslation("plugin_explorer_remove_from_quickaccess_title"), Title = Localize.plugin_explorer_remove_from_quickaccess_title(),
SubTitle = Context.API.GetTranslation("plugin_explorer_remove_from_quickaccess_subtitle"), SubTitle = Localize.plugin_explorer_remove_from_quickaccess_subtitle(),
Action = (context) => Action = (context) =>
{ {
Settings.QuickAccessLinks.Remove(Settings.QuickAccessLinks.FirstOrDefault(x => string.Equals(x.Path, record.FullPath, StringComparison.OrdinalIgnoreCase))); Settings.QuickAccessLinks.Remove(Settings.QuickAccessLinks.FirstOrDefault(x => string.Equals(x.Path, record.FullPath, StringComparison.OrdinalIgnoreCase)));
Context.API.ShowMsg(Context.API.GetTranslation("plugin_explorer_removefilefoldersuccess"), Context.API.ShowMsg(Localize.plugin_explorer_removefilefoldersuccess(),
Context.API.GetTranslation("plugin_explorer_removefilefoldersuccess_detail"), Localize.plugin_explorer_removefilefoldersuccess_detail(),
Constants.ExplorerIconImageFullPath); Constants.ExplorerIconImageFullPath);
return true; return true;
}, },
SubTitleToolTip = Context.API.GetTranslation("plugin_explorer_contextmenu_remove_titletooltip"), SubTitleToolTip = Localize.plugin_explorer_contextmenu_remove_titletooltip(),
TitleToolTip = Context.API.GetTranslation("plugin_explorer_contextmenu_remove_titletooltip"), TitleToolTip = Localize.plugin_explorer_contextmenu_remove_titletooltip(),
IcoPath = Constants.RemoveQuickAccessImagePath, IcoPath = Constants.RemoveQuickAccessImagePath,
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uecc9") Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uecc9")
}); });
@ -118,8 +114,8 @@ namespace Flow.Launcher.Plugin.Explorer
contextMenus.Add(new Result contextMenus.Add(new Result
{ {
Title = Context.API.GetTranslation("plugin_explorer_copypath"), Title = Localize.plugin_explorer_copypath(),
SubTitle = Context.API.GetTranslation("plugin_explorer_copypath_subtitle"), SubTitle = Localize.plugin_explorer_copypath_subtitle(),
Action = _ => Action = _ =>
{ {
try try
@ -130,7 +126,7 @@ namespace Flow.Launcher.Plugin.Explorer
catch (Exception e) catch (Exception e)
{ {
LogException("Fail to set text in clipboard", e); LogException("Fail to set text in clipboard", e);
Context.API.ShowMsgError(Context.API.GetTranslation("plugin_explorer_fail_to_set_text")); Context.API.ShowMsgError(Localize.plugin_explorer_fail_to_set_text());
return false; return false;
} }
}, },
@ -140,8 +136,8 @@ namespace Flow.Launcher.Plugin.Explorer
contextMenus.Add(new Result contextMenus.Add(new Result
{ {
Title = Context.API.GetTranslation("plugin_explorer_copyname"), Title = Localize.plugin_explorer_copyname(),
SubTitle = Context.API.GetTranslation("plugin_explorer_copyname_subtitle"), SubTitle = Localize.plugin_explorer_copyname_subtitle(),
Action = _ => Action = _ =>
{ {
try try
@ -152,7 +148,7 @@ namespace Flow.Launcher.Plugin.Explorer
catch (Exception e) catch (Exception e)
{ {
LogException("Fail to set text in clipboard", e); LogException("Fail to set text in clipboard", e);
Context.API.ShowMsgError(Context.API.GetTranslation("plugin_explorer_fail_to_set_text")); Context.API.ShowMsgError(Localize.plugin_explorer_fail_to_set_text());
return false; return false;
} }
}, },
@ -162,8 +158,8 @@ namespace Flow.Launcher.Plugin.Explorer
contextMenus.Add(new Result contextMenus.Add(new Result
{ {
Title = Context.API.GetTranslation("plugin_explorer_copyfilefolder"), Title = Localize.plugin_explorer_copyfilefolder(),
SubTitle = isFile ? Context.API.GetTranslation("plugin_explorer_copyfile_subtitle") : Context.API.GetTranslation("plugin_explorer_copyfolder_subtitle"), SubTitle = isFile ? Localize.plugin_explorer_copyfile_subtitle(): Localize.plugin_explorer_copyfolder_subtitle(),
Action = _ => Action = _ =>
{ {
try try
@ -174,28 +170,26 @@ namespace Flow.Launcher.Plugin.Explorer
catch (Exception e) catch (Exception e)
{ {
LogException($"Fail to set file/folder in clipboard", e); LogException($"Fail to set file/folder in clipboard", e);
Context.API.ShowMsgError(Context.API.GetTranslation("plugin_explorer_fail_to_set_files")); Context.API.ShowMsgError(Localize.plugin_explorer_fail_to_set_files());
return false; return false;
} }
}, },
IcoPath = icoPath, IcoPath = icoPath,
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uf12b") Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uf12b")
}); });
if (record.Type is ResultType.File or ResultType.Folder) if (record.Type is ResultType.File or ResultType.Folder)
contextMenus.Add(new Result contextMenus.Add(new Result
{ {
Title = Context.API.GetTranslation("plugin_explorer_deletefilefolder"), Title = Localize.plugin_explorer_deletefilefolder(),
SubTitle = isFile ? Context.API.GetTranslation("plugin_explorer_deletefile_subtitle") : Context.API.GetTranslation("plugin_explorer_deletefolder_subtitle"), SubTitle = isFile ? Localize.plugin_explorer_deletefile_subtitle(): Localize.plugin_explorer_deletefolder_subtitle(),
Action = (context) => Action = (context) =>
{ {
try try
{ {
if (Context.API.ShowMsgBox( if (Context.API.ShowMsgBox(
string.Format(Context.API.GetTranslation("plugin_explorer_delete_folder_link"), record.FullPath), Localize.plugin_explorer_delete_folder_link(record.FullPath),
Context.API.GetTranslation("plugin_explorer_deletefilefolder"), Localize.plugin_explorer_deletefilefolder(),
MessageBoxButton.OKCancel, MessageBoxButton.OKCancel,
MessageBoxImage.Warning) MessageBoxImage.Warning)
== MessageBoxResult.Cancel) == MessageBoxResult.Cancel)
@ -208,15 +202,15 @@ namespace Flow.Launcher.Plugin.Explorer
_ = Task.Run(() => _ = Task.Run(() =>
{ {
Context.API.ShowMsg(Context.API.GetTranslation("plugin_explorer_deletefilefoldersuccess"), Context.API.ShowMsg(Localize.plugin_explorer_deletefilefoldersuccess(),
string.Format(Context.API.GetTranslation("plugin_explorer_deletefilefoldersuccess_detail"), record.FullPath), Localize.plugin_explorer_deletefilefoldersuccess_detail(record.FullPath),
Constants.ExplorerIconImageFullPath); Constants.ExplorerIconImageFullPath);
}); });
} }
catch (Exception e) catch (Exception e)
{ {
LogException($"Fail to delete {record.FullPath}", e); LogException($"Fail to delete {record.FullPath}", e);
Context.API.ShowMsgError(string.Format(Context.API.GetTranslation("plugin_explorer_fail_to_delete"), record.FullPath)); Context.API.ShowMsgError(Localize.plugin_explorer_fail_to_delete(record.FullPath));
return false; return false;
} }
@ -230,7 +224,7 @@ namespace Flow.Launcher.Plugin.Explorer
{ {
contextMenus.Add(new Result() contextMenus.Add(new Result()
{ {
Title = Context.API.GetTranslation("plugin_explorer_show_contextmenu_title"), Title = Localize.plugin_explorer_show_contextmenu_title(),
IcoPath = Constants.ShowContextMenuImagePath, IcoPath = Constants.ShowContextMenuImagePath,
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\ue700"), Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\ue700"),
Action = _ => Action = _ =>
@ -248,8 +242,8 @@ namespace Flow.Launcher.Plugin.Explorer
if (record.Type == ResultType.File && CanRunAsDifferentUser(record.FullPath)) if (record.Type == ResultType.File && CanRunAsDifferentUser(record.FullPath))
contextMenus.Add(new Result contextMenus.Add(new Result
{ {
Title = Context.API.GetTranslation("plugin_explorer_runasdifferentuser"), Title = Localize.plugin_explorer_runasdifferentuser(),
SubTitle = Context.API.GetTranslation("plugin_explorer_runasdifferentuser_subtitle"), SubTitle = Localize.plugin_explorer_runasdifferentuser_subtitle(),
Action = (context) => Action = (context) =>
{ {
try try
@ -259,8 +253,8 @@ namespace Flow.Launcher.Plugin.Explorer
catch (FileNotFoundException e) catch (FileNotFoundException e)
{ {
Context.API.ShowMsgError( Context.API.ShowMsgError(
Context.API.GetTranslation("plugin_explorer_plugin_name"), Localize.plugin_explorer_plugin_name(),
string.Format(Context.API.GetTranslation("plugin_explorer_file_not_found"), e.Message)); Localize.plugin_explorer_file_not_found(e.Message));
return false; return false;
} }
@ -317,8 +311,8 @@ namespace Flow.Launcher.Plugin.Explorer
{ {
return new Result return new Result
{ {
Title = Context.API.GetTranslation("plugin_explorer_opencontainingfolder"), Title = Localize.plugin_explorer_opencontainingfolder(),
SubTitle = Context.API.GetTranslation("plugin_explorer_opencontainingfolder_subtitle"), SubTitle = Localize.plugin_explorer_opencontainingfolder_subtitle(),
Action = _ => Action = _ =>
{ {
try try
@ -328,7 +322,7 @@ namespace Flow.Launcher.Plugin.Explorer
catch (Exception e) catch (Exception e)
{ {
LogException($"Fail to open file at {record.FullPath}", e); LogException($"Fail to open file at {record.FullPath}", e);
Context.API.ShowMsgError(string.Format(Context.API.GetTranslation("plugin_explorer_fail_to_open"), record.FullPath)); Context.API.ShowMsgError(Localize.plugin_explorer_fail_to_open(record.FullPath));
return false; return false;
} }
@ -339,11 +333,9 @@ namespace Flow.Launcher.Plugin.Explorer
}; };
} }
private Result CreateOpenWithEditorResult(SearchResult record, string editorPath) private Result CreateOpenWithEditorResult(SearchResult record, string editorPath)
{ {
var name = $"{Context.API.GetTranslation("plugin_explorer_openwitheditor")} {Path.GetFileNameWithoutExtension(editorPath)}"; var name = $"{Localize.plugin_explorer_openwitheditor()} {Path.GetFileNameWithoutExtension(editorPath)}";
return new Result return new Result
{ {
@ -361,8 +353,7 @@ namespace Flow.Launcher.Plugin.Explorer
} }
catch (Exception e) catch (Exception e)
{ {
var raw_message = Context.API.GetTranslation("plugin_explorer_openwitheditor_error"); var message = Localize.plugin_explorer_openwitheditor_error(record.FullPath, Path.GetFileNameWithoutExtension(editorPath), editorPath);
var message = string.Format(raw_message, record.FullPath, Path.GetFileNameWithoutExtension(editorPath), editorPath);
LogException(message, e); LogException(message, e);
Context.API.ShowMsgError(message); Context.API.ShowMsgError(message);
return false; return false;
@ -377,7 +368,7 @@ namespace Flow.Launcher.Plugin.Explorer
{ {
string shellPath = Settings.ShellPath; string shellPath = Settings.ShellPath;
var name = $"{Context.API.GetTranslation("plugin_explorer_openwithshell")} {Path.GetFileNameWithoutExtension(shellPath)}"; var name = $"{Localize.plugin_explorer_openwithshell()} {Path.GetFileNameWithoutExtension(shellPath)}";
return new Result return new Result
{ {
@ -394,8 +385,7 @@ namespace Flow.Launcher.Plugin.Explorer
} }
catch (Exception e) catch (Exception e)
{ {
var raw_message = Context.API.GetTranslation("plugin_explorer_openwithshell_error"); var message = Localize.plugin_explorer_openwithshell_error(record.FullPath, Path.GetFileNameWithoutExtension(shellPath), shellPath);
var message = string.Format(raw_message, record.FullPath, Path.GetFileNameWithoutExtension(shellPath), shellPath);
LogException(message, e); LogException(message, e);
Context.API.ShowMsgError(message); Context.API.ShowMsgError(message);
return false; return false;
@ -410,8 +400,8 @@ namespace Flow.Launcher.Plugin.Explorer
{ {
return new Result return new Result
{ {
Title = Context.API.GetTranslation("plugin_explorer_excludefromindexsearch"), Title = Localize.plugin_explorer_excludefromindexsearch(),
SubTitle = Context.API.GetTranslation("plugin_explorer_path") + " " + record.FullPath, SubTitle = Localize.plugin_explorer_path()+ " " + record.FullPath,
Action = c_ => Action = c_ =>
{ {
if (!Settings.IndexSearchExcludedSubdirectoryPaths.Any(x => string.Equals(x.Path, record.FullPath, StringComparison.OrdinalIgnoreCase))) if (!Settings.IndexSearchExcludedSubdirectoryPaths.Any(x => string.Equals(x.Path, record.FullPath, StringComparison.OrdinalIgnoreCase)))
@ -422,8 +412,8 @@ namespace Flow.Launcher.Plugin.Explorer
_ = Task.Run(() => _ = Task.Run(() =>
{ {
Context.API.ShowMsg(Context.API.GetTranslation("plugin_explorer_excludedfromindexsearch_msg"), Context.API.ShowMsg(Localize.plugin_explorer_excludedfromindexsearch_msg(),
Context.API.GetTranslation("plugin_explorer_path") + Localize.plugin_explorer_path()+
" " + record.FullPath, Constants.ExplorerIconImageFullPath); " " + record.FullPath, Constants.ExplorerIconImageFullPath);
// so the new path can be persisted to storage and not wait till next ViewModel save. // so the new path can be persisted to storage and not wait till next ViewModel save.
@ -441,8 +431,8 @@ namespace Flow.Launcher.Plugin.Explorer
{ {
return new Result return new Result
{ {
Title = Context.API.GetTranslation("plugin_explorer_openindexingoptions"), Title = Localize.plugin_explorer_openindexingoptions(),
SubTitle = Context.API.GetTranslation("plugin_explorer_openindexingoptions_subtitle"), SubTitle = Localize.plugin_explorer_openindexingoptions_subtitle(),
Action = _ => Action = _ =>
{ {
try try
@ -459,7 +449,7 @@ namespace Flow.Launcher.Plugin.Explorer
} }
catch (Exception e) catch (Exception e)
{ {
var message = Context.API.GetTranslation("plugin_explorer_openindexingoptions_errormsg"); var message = Localize.plugin_explorer_openindexingoptions_errormsg();
LogException(message, e); LogException(message, e);
Context.API.ShowMsgError(message); Context.API.ShowMsgError(message);
return false; return false;
@ -470,12 +460,12 @@ namespace Flow.Launcher.Plugin.Explorer
}; };
} }
private Result CreateOpenWithMenu(SearchResult record) private static Result CreateOpenWithMenu(SearchResult record)
{ {
return new Result return new Result
{ {
Title = Context.API.GetTranslation("plugin_explorer_openwith"), Title = Localize.plugin_explorer_openwith(),
SubTitle = Context.API.GetTranslation("plugin_explorer_openwith_subtitle"), SubTitle = Localize.plugin_explorer_openwith_subtitle(),
Action = _ => Action = _ =>
{ {
Process.Start("rundll32.exe", $"{Path.Combine(Environment.SystemDirectory, "shell32.dll")},OpenAs_RunDLL {record.FullPath}"); Process.Start("rundll32.exe", $"{Path.Combine(Environment.SystemDirectory, "shell32.dll")},OpenAs_RunDLL {record.FullPath}");

View file

@ -48,7 +48,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" /> <PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
<PackageReference Include="Droplex" Version="1.7.0" /> <PackageReference Include="Droplex" Version="1.7.0" />
<PackageReference Include="Flow.Launcher.Localization" Version="0.0.5" /> <PackageReference Include="Flow.Launcher.Localization" Version="0.0.6" />
<PackageReference Include="System.Data.OleDb" Version="9.0.9" /> <PackageReference Include="System.Data.OleDb" Version="9.0.9" />
<PackageReference Include="System.Linq.Async" Version="6.0.3" /> <PackageReference Include="System.Linq.Async" Version="6.0.3" />
<PackageReference Include="tlbimp-Microsoft.Search.Interop" Version="1.0.0" /> <PackageReference Include="tlbimp-Microsoft.Search.Interop" Version="1.0.0" />

View file

@ -24,6 +24,7 @@
<system:String x:Key="plugin_explorer_directoryinfosearch_error">Error occurred during search: {0}</system:String> <system:String x:Key="plugin_explorer_directoryinfosearch_error">Error occurred during search: {0}</system:String>
<system:String x:Key="plugin_explorer_opendir_error">Could not open folder</system:String> <system:String x:Key="plugin_explorer_opendir_error">Could not open folder</system:String>
<system:String x:Key="plugin_explorer_openfile_error">Could not open file</system:String> <system:String x:Key="plugin_explorer_openfile_error">Could not open file</system:String>
<system:String x:Key="plugin_explorer_new_action_keyword_assigned">This new action keyword is already assigned to another plugin, please choose a different one</system:String>
<!-- Controls --> <!-- Controls -->
<system:String x:Key="plugin_explorer_delete">Delete</system:String> <system:String x:Key="plugin_explorer_delete">Delete</system:String>

View file

@ -90,12 +90,12 @@ namespace Flow.Launcher.Plugin.Explorer
public string GetTranslatedPluginTitle() public string GetTranslatedPluginTitle()
{ {
return Context.API.GetTranslation("plugin_explorer_plugin_name"); return Localize.plugin_explorer_plugin_name();
} }
public string GetTranslatedPluginDescription() public string GetTranslatedPluginDescription()
{ {
return Context.API.GetTranslation("plugin_explorer_plugin_description"); return Localize.plugin_explorer_plugin_description();
} }
public void OnCultureInfoChanged(CultureInfo newCulture) public void OnCultureInfoChanged(CultureInfo newCulture)

View file

@ -21,9 +21,9 @@ public static class EverythingDownloadHelper
if (string.IsNullOrEmpty(installedLocation)) if (string.IsNullOrEmpty(installedLocation))
{ {
if (api.ShowMsgBox( if (api.ShowMsgBox(
string.Format(api.GetTranslation("flowlauncher_plugin_everything_installing_select"), Environment.NewLine), Localize.flowlauncher_plugin_everything_installing_select(Environment.NewLine),
api.GetTranslation("flowlauncher_plugin_everything_installing_title"), Localize.flowlauncher_plugin_everything_installing_title(),
MessageBoxButton.YesNo) == MessageBoxResult.Yes) MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{ {
var dlg = new System.Windows.Forms.OpenFileDialog var dlg = new System.Windows.Forms.OpenFileDialog
{ {
@ -41,13 +41,13 @@ public static class EverythingDownloadHelper
return installedLocation; return installedLocation;
} }
api.ShowMsg(api.GetTranslation("flowlauncher_plugin_everything_installing_title"), api.ShowMsg(Localize.flowlauncher_plugin_everything_installing_title(),
api.GetTranslation("flowlauncher_plugin_everything_installing_subtitle"), "", useMainWindowAsOwner: false); Localize.flowlauncher_plugin_everything_installing_subtitle(), "", useMainWindowAsOwner: false);
await DroplexPackage.Drop(App.Everything1_4_1_1009).ConfigureAwait(false); await DroplexPackage.Drop(App.Everything1_4_1_1009).ConfigureAwait(false);
api.ShowMsg(api.GetTranslation("flowlauncher_plugin_everything_installing_title"), api.ShowMsg(Localize.flowlauncher_plugin_everything_installing_title(),
api.GetTranslation("flowlauncher_plugin_everything_installationsuccess_subtitle"), "", useMainWindowAsOwner: false); Localize.flowlauncher_plugin_everything_installationsuccess_subtitle(), "", useMainWindowAsOwner: false);
installedLocation = "C:\\Program Files\\Everything\\Everything.exe"; installedLocation = "C:\\Program Files\\Everything\\Everything.exe";
@ -83,6 +83,5 @@ public static class EverythingDownloadHelper
var scoopInstalledPath = Environment.ExpandEnvironmentVariables(@"%userprofile%\scoop\apps\everything\current\Everything.exe"); var scoopInstalledPath = Environment.ExpandEnvironmentVariables(@"%userprofile%\scoop\apps\everything\current\Everything.exe");
return File.Exists(scoopInstalledPath) ? scoopInstalledPath : string.Empty; return File.Exists(scoopInstalledPath) ? scoopInstalledPath : string.Empty;
} }
} }

View file

@ -27,8 +27,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
if (!await EverythingApi.IsEverythingRunningAsync(token)) if (!await EverythingApi.IsEverythingRunningAsync(token))
throw new EngineNotAvailableException( throw new EngineNotAvailableException(
Enum.GetName(Settings.IndexSearchEngineOption.Everything)!, Enum.GetName(Settings.IndexSearchEngineOption.Everything)!,
Main.Context.API.GetTranslation("flowlauncher_plugin_everything_click_to_launch_or_install"), Localize.flowlauncher_plugin_everything_click_to_launch_or_install(),
Main.Context.API.GetTranslation("flowlauncher_plugin_everything_is_not_running"), Localize.flowlauncher_plugin_everything_is_not_running(),
Constants.EverythingErrorImagePath, Constants.EverythingErrorImagePath,
ClickToInstallEverythingAsync); ClickToInstallEverythingAsync);
} }
@ -38,7 +38,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
Enum.GetName(Settings.IndexSearchEngineOption.Everything)!, Enum.GetName(Settings.IndexSearchEngineOption.Everything)!,
"Please check whether your system is x86 or x64", "Please check whether your system is x86 or x64",
Constants.GeneralSearchErrorImagePath, Constants.GeneralSearchErrorImagePath,
Main.Context.API.GetTranslation("flowlauncher_plugin_everything_sdk_issue")); Localize.flowlauncher_plugin_everything_sdk_issue());
} }
} }
@ -50,7 +50,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
if (installedPath == null) if (installedPath == null)
{ {
Main.Context.API.ShowMsgError(Main.Context.API.GetTranslation("flowlauncher_plugin_everything_not_found")); Main.Context.API.ShowMsgError(Localize.flowlauncher_plugin_everything_not_found());
Main.Context.API.LogError(ClassName, "Unable to find Everything.exe"); Main.Context.API.LogError(ClassName, "Unable to find Everything.exe");
return false; return false;
@ -65,7 +65,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
// Just let the user know that Everything is not installed properly and ask them to install it manually // Just let the user know that Everything is not installed properly and ask them to install it manually
catch (Exception e) catch (Exception e)
{ {
Main.Context.API.ShowMsgError(Main.Context.API.GetTranslation("flowlauncher_plugin_everything_install_issue")); Main.Context.API.ShowMsgError(Localize.flowlauncher_plugin_everything_install_issue());
Main.Context.API.LogException(ClassName, "Failed to install Everything", e); Main.Context.API.LogException(ClassName, "Failed to install Everything", e);
return false; return false;
@ -97,8 +97,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
if (!Settings.EnableEverythingContentSearch) if (!Settings.EnableEverythingContentSearch)
{ {
throw new EngineNotAvailableException(Enum.GetName(Settings.IndexSearchEngineOption.Everything)!, throw new EngineNotAvailableException(Enum.GetName(Settings.IndexSearchEngineOption.Everything)!,
Main.Context.API.GetTranslation("flowlauncher_plugin_everything_enable_content_search"), Localize.flowlauncher_plugin_everything_enable_content_search(),
Main.Context.API.GetTranslation("flowlauncher_plugin_everything_enable_content_search_tips"), Localize.flowlauncher_plugin_everything_enable_content_search_tips(),
Constants.EverythingErrorImagePath, Constants.EverythingErrorImagePath,
_ => _ =>
{ {

View file

@ -1,4 +1,4 @@
using System; using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -124,7 +124,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
} }
catch (Exception ex) catch (Exception ex)
{ {
Context.API.ShowMsgBox(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error")); Context.API.ShowMsgBox(ex.Message, Localize.plugin_explorer_opendir_error());
return false; return false;
} }
} }
@ -138,7 +138,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
} }
catch (Exception ex) catch (Exception ex)
{ {
Context.API.ShowMsgBox(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error")); Context.API.ShowMsgBox(ex.Message, Localize.plugin_explorer_opendir_error());
return false; return false;
} }
} }
@ -153,7 +153,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
} }
catch (Exception ex) catch (Exception ex)
{ {
Context.API.ShowMsgBox(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error")); Context.API.ShowMsgBox(ex.Message, Localize.plugin_explorer_opendir_error());
return false; return false;
} }
} }
@ -166,7 +166,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
return false; return false;
}, },
Score = score, Score = score,
TitleToolTip = Main.Context.API.GetTranslation("plugin_explorer_plugin_ToolTipOpenDirectory"), TitleToolTip = Localize.plugin_explorer_plugin_ToolTipOpenDirectory(),
SubTitleToolTip = Settings.DisplayMoreInformationInToolTip ? GetFolderMoreInfoTooltip(path) : path, SubTitleToolTip = Settings.DisplayMoreInformationInToolTip ? GetFolderMoreInfoTooltip(path) : path,
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = path, WindowsIndexed = windowsIndexed } ContextData = new SearchResult { Type = ResultType.Folder, FullPath = path, WindowsIndexed = windowsIndexed }
}; };
@ -190,7 +190,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
DriveInfo drv = new DriveInfo(driveLetter); DriveInfo drv = new DriveInfo(driveLetter);
var freespace = ToReadableSize(drv.AvailableFreeSpace, 2); var freespace = ToReadableSize(drv.AvailableFreeSpace, 2);
var totalspace = ToReadableSize(drv.TotalSize, 2); var totalspace = ToReadableSize(drv.TotalSize, 2);
var subtitle = string.Format(Context.API.GetTranslation("plugin_explorer_diskfreespace"), freespace, totalspace); var subtitle = Localize.plugin_explorer_diskfreespace(freespace, totalspace);
double usingSize = (Convert.ToDouble(drv.TotalSize) - Convert.ToDouble(drv.AvailableFreeSpace)) / Convert.ToDouble(drv.TotalSize) * 100; double usingSize = (Convert.ToDouble(drv.TotalSize) - Convert.ToDouble(drv.AvailableFreeSpace)) / Convert.ToDouble(drv.TotalSize) * 100;
int? progressValue = Convert.ToInt32(usingSize); int? progressValue = Convert.ToInt32(usingSize);
@ -262,8 +262,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search
return new Result return new Result
{ {
Title = Context.API.GetTranslation("plugin_explorer_openresultfolder"), Title = Localize.plugin_explorer_openresultfolder(),
SubTitle = Context.API.GetTranslation("plugin_explorer_openresultfolder_subtitle"), SubTitle = Localize.plugin_explorer_openresultfolder_subtitle(),
AutoCompleteText = GetPathWithActionKeyword(folderPath, ResultType.Folder, actionKeyword), AutoCompleteText = GetPathWithActionKeyword(folderPath, ResultType.Folder, actionKeyword),
IcoPath = folderPath, IcoPath = folderPath,
Score = 500, Score = 500,
@ -330,12 +330,12 @@ namespace Flow.Launcher.Plugin.Explorer.Search
} }
catch (Exception ex) catch (Exception ex)
{ {
Context.API.ShowMsgBox(ex.Message, Context.API.GetTranslation("plugin_explorer_openfile_error")); Context.API.ShowMsgBox(ex.Message, Localize.plugin_explorer_openfile_error());
} }
return true; return true;
}, },
TitleToolTip = Main.Context.API.GetTranslation("plugin_explorer_plugin_ToolTipOpenContainingFolder"), TitleToolTip = Localize.plugin_explorer_plugin_ToolTipOpenContainingFolder(),
SubTitleToolTip = Settings.DisplayMoreInformationInToolTip ? GetFileMoreInfoTooltip(filePath) : filePath, SubTitleToolTip = Settings.DisplayMoreInformationInToolTip ? GetFileMoreInfoTooltip(filePath) : filePath,
ContextData = new SearchResult { Type = ResultType.File, FullPath = filePath, WindowsIndexed = windowsIndexed } ContextData = new SearchResult { Type = ResultType.File, FullPath = filePath, WindowsIndexed = windowsIndexed }
}; };
@ -374,8 +374,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
var fileSize = PreviewPanel.GetFileSize(filePath); var fileSize = PreviewPanel.GetFileSize(filePath);
var fileCreatedAt = PreviewPanel.GetFileCreatedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel); var fileCreatedAt = PreviewPanel.GetFileCreatedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel);
var fileModifiedAt = PreviewPanel.GetFileLastModifiedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel); var fileModifiedAt = PreviewPanel.GetFileLastModifiedAt(filePath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel);
return string.Format(Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info"), return Localize.plugin_explorer_plugin_tooltip_more_info(filePath, fileSize, fileCreatedAt, fileModifiedAt, Environment.NewLine);
filePath, fileSize, fileCreatedAt, fileModifiedAt, Environment.NewLine);
} }
catch (Exception e) catch (Exception e)
{ {
@ -391,8 +390,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
var folderSize = PreviewPanel.GetFolderSize(folderPath); var folderSize = PreviewPanel.GetFolderSize(folderPath);
var folderCreatedAt = PreviewPanel.GetFolderCreatedAt(folderPath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel); var folderCreatedAt = PreviewPanel.GetFolderCreatedAt(folderPath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel);
var folderModifiedAt = PreviewPanel.GetFolderLastModifiedAt(folderPath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel); var folderModifiedAt = PreviewPanel.GetFolderLastModifiedAt(folderPath, Settings.PreviewPanelDateFormat, Settings.PreviewPanelTimeFormat, Settings.ShowFileAgeInPreviewPanel);
return string.Format(Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info"), return Localize.plugin_explorer_plugin_tooltip_more_info(folderPath, folderSize, folderCreatedAt, folderModifiedAt, Environment.NewLine);
folderPath, folderSize, folderCreatedAt, folderModifiedAt, Environment.NewLine);
} }
catch (Exception e) catch (Exception e)
{ {
@ -403,8 +401,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
private static string GetVolumeMoreInfoTooltip(string volumePath, string freespace, string totalspace) private static string GetVolumeMoreInfoTooltip(string volumePath, string freespace, string totalspace)
{ {
return string.Format(Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_volume"), return Localize.plugin_explorer_plugin_tooltip_more_info_volume(volumePath, freespace, totalspace, Environment.NewLine);
volumePath, freespace, totalspace, Environment.NewLine);
} }
private static readonly string[] MediaExtensions = private static readonly string[] MediaExtensions =

View file

@ -161,8 +161,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search
{ {
new() new()
{ {
Title = Context.API.GetTranslation("flowlauncher_plugin_everything_enable_content_search"), Title = Localize.flowlauncher_plugin_everything_enable_content_search(),
SubTitle = Context.API.GetTranslation("flowlauncher_plugin_everything_enable_content_search_tips"), SubTitle = Localize.flowlauncher_plugin_everything_enable_content_search_tips(),
IcoPath = "Images/index_error.png", IcoPath = "Images/index_error.png",
Action = c => Action = c =>
{ {

View file

@ -105,8 +105,8 @@ namespace Flow.Launcher.Plugin.Explorer.Search.WindowsIndex
throw new EngineNotAvailableException( throw new EngineNotAvailableException(
"Windows Index", "Windows Index",
Main.Context.API.GetTranslation("plugin_explorer_windowsSearchServiceFix"), Localize.plugin_explorer_windowsSearchServiceFix(),
Main.Context.API.GetTranslation("plugin_explorer_windowsSearchServiceNotRunning"), Localize.plugin_explorer_windowsSearchServiceNotRunning(),
Constants.WindowsIndexErrorImagePath, Constants.WindowsIndexErrorImagePath,
c => c =>
{ {

View file

@ -14,9 +14,9 @@ namespace Flow.Launcher.Plugin.Explorer
{ {
public int MaxResult { get; set; } = 100; public int MaxResult { get; set; } = 100;
public ObservableCollection<AccessLink> QuickAccessLinks { get; set; } = new(); public ObservableCollection<AccessLink> QuickAccessLinks { get; set; } = [];
public ObservableCollection<AccessLink> IndexSearchExcludedSubdirectoryPaths { get; set; } = new ObservableCollection<AccessLink>(); public ObservableCollection<AccessLink> IndexSearchExcludedSubdirectoryPaths { get; set; } = [];
public string EditorPath { get; set; } = ""; public string EditorPath { get; set; } = "";
@ -58,7 +58,6 @@ namespace Flow.Launcher.Plugin.Explorer
public bool QuickAccessKeywordEnabled { get; set; } public bool QuickAccessKeywordEnabled { get; set; }
public bool WarnWindowsSearchServiceOff { get; set; } = true; public bool WarnWindowsSearchServiceOff { get; set; } = true;
public bool ShowFileSizeInPreviewPanel { get; set; } = true; public bool ShowFileSizeInPreviewPanel { get; set; } = true;
@ -69,7 +68,6 @@ namespace Flow.Launcher.Plugin.Explorer
public bool ShowFileAgeInPreviewPanel { get; set; } = false; public bool ShowFileAgeInPreviewPanel { get; set; } = false;
public string PreviewPanelDateFormat { get; set; } = "yyyy-MM-dd"; public string PreviewPanelDateFormat { get; set; } = "yyyy-MM-dd";
public string PreviewPanelTimeFormat { get; set; } = "HH:mm"; public string PreviewPanelTimeFormat { get; set; } = "HH:mm";
@ -82,8 +80,8 @@ namespace Flow.Launcher.Plugin.Explorer
private EverythingSearchManager EverythingManagerInstance => _everythingManagerInstance ??= new EverythingSearchManager(this); private EverythingSearchManager EverythingManagerInstance => _everythingManagerInstance ??= new EverythingSearchManager(this);
private WindowsIndexSearchManager WindowsIndexSearchManager => _windowsIndexSearchManager ??= new WindowsIndexSearchManager(this); private WindowsIndexSearchManager WindowsIndexSearchManager => _windowsIndexSearchManager ??= new WindowsIndexSearchManager(this);
public IndexSearchEngineOption IndexSearchEngine { get; set; } = IndexSearchEngineOption.WindowsIndex; public IndexSearchEngineOption IndexSearchEngine { get; set; } = IndexSearchEngineOption.WindowsIndex;
[JsonIgnore] [JsonIgnore]
public IIndexProvider IndexProvider => IndexSearchEngine switch public IIndexProvider IndexProvider => IndexSearchEngine switch
{ {
@ -139,7 +137,6 @@ namespace Flow.Launcher.Plugin.Explorer
#endregion #endregion
#region Everything Settings #region Everything Settings
public string EverythingInstalledPath { get; set; } public string EverythingInstalledPath { get; set; }

View file

@ -296,7 +296,7 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
return; return;
} }
var actionKeywordWindow = new ActionKeywordSetting(actionKeyword, Context.API); var actionKeywordWindow = new ActionKeywordSetting(actionKeyword);
if (!(actionKeywordWindow.ShowDialog() ?? false)) if (!(actionKeywordWindow.ShowDialog() ?? false))
{ {
@ -432,8 +432,8 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
case "QuickAccessLink": case "QuickAccessLink":
if (SelectedQuickAccessLink == null) return; if (SelectedQuickAccessLink == null) return;
if (Context.API.ShowMsgBox( if (Context.API.ShowMsgBox(
Context.API.GetTranslation("plugin_explorer_delete_quick_access_link"), Localize.plugin_explorer_delete_quick_access_link(),
Context.API.GetTranslation("plugin_explorer_delete"), Localize.plugin_explorer_delete(),
MessageBoxButton.OKCancel, MessageBoxButton.OKCancel,
MessageBoxImage.Warning) MessageBoxImage.Warning)
== MessageBoxResult.Cancel) == MessageBoxResult.Cancel)
@ -443,8 +443,8 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
case "IndexSearchExcludedPaths": case "IndexSearchExcludedPaths":
if (SelectedIndexSearchExcludedPath == null) return; if (SelectedIndexSearchExcludedPath == null) return;
if (Context.API.ShowMsgBox( if (Context.API.ShowMsgBox(
Context.API.GetTranslation("plugin_explorer_delete_index_search_excluded_path"), Localize.plugin_explorer_delete_index_search_excluded_path(),
Context.API.GetTranslation("plugin_explorer_delete"), Localize.plugin_explorer_delete(),
MessageBoxButton.OKCancel, MessageBoxButton.OKCancel,
MessageBoxImage.Warning) MessageBoxImage.Warning)
== MessageBoxResult.Cancel) == MessageBoxResult.Cancel)
@ -457,7 +457,7 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
private void ShowUnselectedMessage() private void ShowUnselectedMessage()
{ {
var warning = Context.API.GetTranslation("plugin_explorer_make_selection_warning"); var warning = Localize.plugin_explorer_make_selection_warning();
Context.API.ShowMsgBox(warning); Context.API.ShowMsgBox(warning);
} }

View file

@ -29,13 +29,11 @@ namespace Flow.Launcher.Plugin.Explorer.Views
} }
private string actionKeyword; private string actionKeyword;
private readonly IPublicAPI _api;
private bool _keywordEnabled; private bool _keywordEnabled;
public ActionKeywordSetting(ActionKeywordModel selectedActionKeyword, IPublicAPI api) public ActionKeywordSetting(ActionKeywordModel selectedActionKeyword)
{ {
CurrentActionKeyword = selectedActionKeyword; CurrentActionKeyword = selectedActionKeyword;
_api = api;
ActionKeyword = selectedActionKeyword.Keyword; ActionKeyword = selectedActionKeyword.Keyword;
KeywordEnabled = selectedActionKeyword.Enabled; KeywordEnabled = selectedActionKeyword.Enabled;
@ -60,14 +58,14 @@ namespace Flow.Launcher.Plugin.Explorer.Views
switch (CurrentActionKeyword.KeywordProperty, KeywordEnabled) switch (CurrentActionKeyword.KeywordProperty, KeywordEnabled)
{ {
case (Settings.ActionKeyword.FileContentSearchActionKeyword, true): case (Settings.ActionKeyword.FileContentSearchActionKeyword, true):
_api.ShowMsgBox(_api.GetTranslation("plugin_explorer_globalActionKeywordInvalid")); Main.Context.API.ShowMsgBox(Localize.plugin_explorer_globalActionKeywordInvalid());
return; return;
case (Settings.ActionKeyword.QuickAccessActionKeyword, true): case (Settings.ActionKeyword.QuickAccessActionKeyword, true):
_api.ShowMsgBox(_api.GetTranslation("plugin_explorer_quickaccess_globalActionKeywordInvalid")); Main.Context.API.ShowMsgBox(Localize.plugin_explorer_quickaccess_globalActionKeywordInvalid());
return; return;
} }
if (!KeywordEnabled || !_api.ActionKeywordAssigned(ActionKeyword)) if (!KeywordEnabled || !Main.Context.API.ActionKeywordAssigned(ActionKeyword))
{ {
DialogResult = true; DialogResult = true;
Close(); Close();
@ -75,7 +73,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
} }
// The keyword is not valid, so show message // The keyword is not valid, so show message
_api.ShowMsgBox(_api.GetTranslation("newActionKeywordsHasBeenAssigned")); Main.Context.API.ShowMsgBox(Localize.plugin_explorer_new_action_keyword_assigned());
} }
private void BtnCancel_OnClick(object sender, RoutedEventArgs e) private void BtnCancel_OnClick(object sender, RoutedEventArgs e)

View file

@ -25,7 +25,7 @@ public partial class PreviewPanel : UserControl
public string FileName { get; } public string FileName { get; }
[ObservableProperty] [ObservableProperty]
private string _fileSize = Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); private string _fileSize = Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
[ObservableProperty] [ObservableProperty]
private string _createdAt = ""; private string _createdAt = "";
@ -111,17 +111,17 @@ public partial class PreviewPanel : UserControl
catch (FileNotFoundException) catch (FileNotFoundException)
{ {
Main.Context.API.LogError(ClassName, $"File not found: {filePath}"); Main.Context.API.LogError(ClassName, $"File not found: {filePath}");
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
catch (UnauthorizedAccessException) catch (UnauthorizedAccessException)
{ {
Main.Context.API.LogError(ClassName, $"Access denied to file: {filePath}"); Main.Context.API.LogError(ClassName, $"Access denied to file: {filePath}");
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
catch (Exception e) catch (Exception e)
{ {
Main.Context.API.LogException(ClassName, $"Failed to get file size for {filePath}", e); Main.Context.API.LogException(ClassName, $"Failed to get file size for {filePath}", e);
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
} }
@ -142,17 +142,17 @@ public partial class PreviewPanel : UserControl
catch (FileNotFoundException) catch (FileNotFoundException)
{ {
Main.Context.API.LogError(ClassName, $"File not found: {filePath}"); Main.Context.API.LogError(ClassName, $"File not found: {filePath}");
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
catch (UnauthorizedAccessException) catch (UnauthorizedAccessException)
{ {
Main.Context.API.LogError(ClassName, $"Access denied to file: {filePath}"); Main.Context.API.LogError(ClassName, $"Access denied to file: {filePath}");
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
catch (Exception e) catch (Exception e)
{ {
Main.Context.API.LogException(ClassName, $"Failed to get file created date for {filePath}", e); Main.Context.API.LogException(ClassName, $"Failed to get file created date for {filePath}", e);
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
} }
@ -173,17 +173,17 @@ public partial class PreviewPanel : UserControl
catch (FileNotFoundException) catch (FileNotFoundException)
{ {
Main.Context.API.LogError(ClassName, $"File not found: {filePath}"); Main.Context.API.LogError(ClassName, $"File not found: {filePath}");
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
catch (UnauthorizedAccessException) catch (UnauthorizedAccessException)
{ {
Main.Context.API.LogError(ClassName, $"Access denied to file: {filePath}"); Main.Context.API.LogError(ClassName, $"Access denied to file: {filePath}");
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
catch (Exception e) catch (Exception e)
{ {
Main.Context.API.LogException(ClassName, $"Failed to get file modified date for {filePath}", e); Main.Context.API.LogException(ClassName, $"Failed to get file modified date for {filePath}", e);
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
} }
@ -205,17 +205,17 @@ public partial class PreviewPanel : UserControl
catch (FileNotFoundException) catch (FileNotFoundException)
{ {
Main.Context.API.LogError(ClassName, $"Folder not found: {folderPath}"); Main.Context.API.LogError(ClassName, $"Folder not found: {folderPath}");
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
catch (UnauthorizedAccessException) catch (UnauthorizedAccessException)
{ {
Main.Context.API.LogError(ClassName, $"Access denied to folder: {folderPath}"); Main.Context.API.LogError(ClassName, $"Access denied to folder: {folderPath}");
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
catch (OperationCanceledException) catch (OperationCanceledException)
{ {
Main.Context.API.LogError(ClassName, $"Operation timed out while calculating folder size for {folderPath}"); Main.Context.API.LogError(ClassName, $"Operation timed out while calculating folder size for {folderPath}");
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
// For parallel operations, AggregateException may be thrown if any of the tasks fail // For parallel operations, AggregateException may be thrown if any of the tasks fail
catch (AggregateException ae) catch (AggregateException ae)
@ -224,22 +224,22 @@ public partial class PreviewPanel : UserControl
{ {
case FileNotFoundException: case FileNotFoundException:
Main.Context.API.LogError(ClassName, $"Folder not found: {folderPath}"); Main.Context.API.LogError(ClassName, $"Folder not found: {folderPath}");
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
case UnauthorizedAccessException: case UnauthorizedAccessException:
Main.Context.API.LogError(ClassName, $"Access denied to folder: {folderPath}"); Main.Context.API.LogError(ClassName, $"Access denied to folder: {folderPath}");
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
case OperationCanceledException: case OperationCanceledException:
Main.Context.API.LogError(ClassName, $"Operation timed out while calculating folder size for {folderPath}"); Main.Context.API.LogError(ClassName, $"Operation timed out while calculating folder size for {folderPath}");
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
default: default:
Main.Context.API.LogException(ClassName, $"Failed to get folder size for {folderPath}", ae); Main.Context.API.LogException(ClassName, $"Failed to get folder size for {folderPath}", ae);
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
} }
catch (Exception e) catch (Exception e)
{ {
Main.Context.API.LogException(ClassName, $"Failed to get folder size for {folderPath}", e); Main.Context.API.LogException(ClassName, $"Failed to get folder size for {folderPath}", e);
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
} }
@ -260,17 +260,17 @@ public partial class PreviewPanel : UserControl
catch (FileNotFoundException) catch (FileNotFoundException)
{ {
Main.Context.API.LogError(ClassName, $"Folder not found: {folderPath}"); Main.Context.API.LogError(ClassName, $"Folder not found: {folderPath}");
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
catch (UnauthorizedAccessException) catch (UnauthorizedAccessException)
{ {
Main.Context.API.LogError(ClassName, $"Access denied to folder: {folderPath}"); Main.Context.API.LogError(ClassName, $"Access denied to folder: {folderPath}");
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
catch (Exception e) catch (Exception e)
{ {
Main.Context.API.LogException(ClassName, $"Failed to get folder created date for {folderPath}", e); Main.Context.API.LogException(ClassName, $"Failed to get folder created date for {folderPath}", e);
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
} }
@ -291,17 +291,17 @@ public partial class PreviewPanel : UserControl
catch (FileNotFoundException) catch (FileNotFoundException)
{ {
Main.Context.API.LogError(ClassName, $"Folder not found: {folderPath}"); Main.Context.API.LogError(ClassName, $"Folder not found: {folderPath}");
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
catch (UnauthorizedAccessException) catch (UnauthorizedAccessException)
{ {
Main.Context.API.LogError(ClassName, $"Access denied to folder: {folderPath}"); Main.Context.API.LogError(ClassName, $"Access denied to folder: {folderPath}");
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
catch (Exception e) catch (Exception e)
{ {
Main.Context.API.LogException(ClassName, $"Failed to get folder modified date for {folderPath}", e); Main.Context.API.LogException(ClassName, $"Failed to get folder modified date for {folderPath}", e);
return Main.Context.API.GetTranslation("plugin_explorer_plugin_tooltip_more_info_unknown"); return Localize.plugin_explorer_plugin_tooltip_more_info_unknown();
} }
} }
@ -311,21 +311,20 @@ public partial class PreviewPanel : UserControl
var difference = now - fileDateTime; var difference = now - fileDateTime;
if (difference.TotalDays < 1) if (difference.TotalDays < 1)
return Main.Context.API.GetTranslation("Today"); return Localize.Today();
if (difference.TotalDays < 30) if (difference.TotalDays < 30)
return string.Format(Main.Context.API.GetTranslation("DaysAgo"), (int)difference.TotalDays); return Localize.DaysAgo((int)difference.TotalDays);
var monthsDiff = (now.Year - fileDateTime.Year) * 12 + now.Month - fileDateTime.Month; var monthsDiff = (now.Year - fileDateTime.Year) * 12 + now.Month - fileDateTime.Month;
if (monthsDiff == 1) if (monthsDiff == 1)
return Main.Context.API.GetTranslation("OneMonthAgo"); return Localize.OneMonthAgo();
if (monthsDiff < 12) if (monthsDiff < 12)
return string.Format(Main.Context.API.GetTranslation("MonthsAgo"), monthsDiff); return Localize.MonthsAgo(monthsDiff);
var yearsDiff = now.Year - fileDateTime.Year; var yearsDiff = now.Year - fileDateTime.Year;
if (now.Month < fileDateTime.Month || (now.Month == fileDateTime.Month && now.Day < fileDateTime.Day)) if (now.Month < fileDateTime.Month || (now.Month == fileDateTime.Month && now.Day < fileDateTime.Day))
yearsDiff--; yearsDiff--;
return yearsDiff == 1 ? Main.Context.API.GetTranslation("OneYearAgo") : return yearsDiff == 1 ? Localize.OneYearAgo(): Localize.YearsAgo(yearsDiff);
string.Format(Main.Context.API.GetTranslation("YearsAgo"), yearsDiff);
} }
} }

View file

@ -97,7 +97,7 @@ public partial class QuickAccessLinkSettings
// Validate the input before proceeding // Validate the input before proceeding
if (string.IsNullOrEmpty(SelectedName) || string.IsNullOrEmpty(SelectedPath)) if (string.IsNullOrEmpty(SelectedName) || string.IsNullOrEmpty(SelectedPath))
{ {
var warning = Main.Context.API.GetTranslation("plugin_explorer_quick_access_link_no_folder_selected"); var warning = Localize.plugin_explorer_quick_access_link_no_folder_selected();
Main.Context.API.ShowMsgBox(warning); Main.Context.API.ShowMsgBox(warning);
return; return;
} }
@ -107,7 +107,7 @@ public partial class QuickAccessLinkSettings
x.Path.Equals(SelectedPath, StringComparison.OrdinalIgnoreCase) && x.Path.Equals(SelectedPath, StringComparison.OrdinalIgnoreCase) &&
x.Name.Equals(SelectedName, StringComparison.OrdinalIgnoreCase))) x.Name.Equals(SelectedName, StringComparison.OrdinalIgnoreCase)))
{ {
var warning = Main.Context.API.GetTranslation("plugin_explorer_quick_access_link_path_already_exists"); var warning = Localize.plugin_explorer_quick_access_link_path_already_exists();
Main.Context.API.ShowMsgBox(warning); Main.Context.API.ShowMsgBox(warning);
return; return;
} }