From 8fbf3a3f925b7f8f2ee506733acb8c5d40c9edfa Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Wed, 21 Dec 2022 14:01:09 +0800 Subject: [PATCH] make file/folder translatble --- .../ContextMenu.cs | 36 +++++++++---------- .../Languages/en.xaml | 22 ++++++++---- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs index 8f9cc9524..af5439d04 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs @@ -59,14 +59,14 @@ namespace Flow.Launcher.Plugin.Explorer } var icoPath = (record.Type == ResultType.File) ? Constants.FileImagePath : Constants.FolderImagePath; - var fileOrFolder = (record.Type == ResultType.File) ? "file" : "folder"; + bool isFile = record.Type == ResultType.File; if (Settings.QuickAccessLinks.All(x => !x.Path.Equals(record.FullPath, StringComparison.OrdinalIgnoreCase))) { contextMenus.Add(new Result { Title = Context.API.GetTranslation("plugin_explorer_add_to_quickaccess_title"), - SubTitle = string.Format(Context.API.GetTranslation("plugin_explorer_add_to_quickaccess_subtitle"), fileOrFolder), + SubTitle = Context.API.GetTranslation("plugin_explorer_add_to_quickaccess_subtitle"), Action = (context) => { Settings.QuickAccessLinks.Add(new AccessLink @@ -75,10 +75,8 @@ namespace Flow.Launcher.Plugin.Explorer }); Context.API.ShowMsg(Context.API.GetTranslation("plugin_explorer_addfilefoldersuccess"), - string.Format( Context.API.GetTranslation("plugin_explorer_addfilefoldersuccess_detail"), - fileOrFolder), - Constants.ExplorerIconImageFullPath); + Constants.ExplorerIconImageFullPath); ViewModel.Save(); @@ -95,16 +93,14 @@ namespace Flow.Launcher.Plugin.Explorer contextMenus.Add(new Result { Title = Context.API.GetTranslation("plugin_explorer_remove_from_quickaccess_title"), - SubTitle = string.Format(Context.API.GetTranslation("plugin_explorer_remove_from_quickaccess_subtitle"), fileOrFolder), + SubTitle = Context.API.GetTranslation("plugin_explorer_remove_from_quickaccess_subtitle"), Action = (context) => { Settings.QuickAccessLinks.Remove(Settings.QuickAccessLinks.FirstOrDefault(x => string.Equals(x.Path, record.FullPath, StringComparison.OrdinalIgnoreCase))); Context.API.ShowMsg(Context.API.GetTranslation("plugin_explorer_removefilefoldersuccess"), - string.Format( Context.API.GetTranslation("plugin_explorer_removefilefoldersuccess_detail"), - fileOrFolder), - Constants.ExplorerIconImageFullPath); + Constants.ExplorerIconImageFullPath); ViewModel.Save(); @@ -120,7 +116,7 @@ namespace Flow.Launcher.Plugin.Explorer contextMenus.Add(new Result { Title = Context.API.GetTranslation("plugin_explorer_copypath"), - SubTitle = $"Copy the current {fileOrFolder} path to clipboard", + SubTitle = Context.API.GetTranslation("plugin_explorer_copypath_subtitle"), Action = _ => { try @@ -142,8 +138,8 @@ namespace Flow.Launcher.Plugin.Explorer contextMenus.Add(new Result { - Title = Context.API.GetTranslation("plugin_explorer_copyfilefolder") + $" {fileOrFolder}", - SubTitle = $"Copy the {fileOrFolder} to clipboard", + Title = isFile ? Context.API.GetTranslation("plugin_explorer_copyfile") : Context.API.GetTranslation("plugin_explorer_copyfolder"), + SubTitle = isFile ? Context.API.GetTranslation("plugin_explorer_copyfile_subtitle") : Context.API.GetTranslation("plugin_explorer_copyfolder_subtitle"), Action = _ => { try @@ -156,7 +152,7 @@ namespace Flow.Launcher.Plugin.Explorer } catch (Exception e) { - var message = $"Fail to set {fileOrFolder} in clipboard"; + var message = $"Fail to set file/folder in clipboard"; LogException(message, e); Context.API.ShowMsg(message); return false; @@ -171,21 +167,21 @@ namespace Flow.Launcher.Plugin.Explorer if (record.Type is ResultType.File or ResultType.Folder) contextMenus.Add(new Result { - Title = Context.API.GetTranslation("plugin_explorer_deletefilefolder") + $" {fileOrFolder}", - SubTitle = Context.API.GetTranslation("plugin_explorer_deletefilefolder_subtitle") + $" {fileOrFolder}", + Title = isFile ? Context.API.GetTranslation("plugin_explorer_deletefile") : Context.API.GetTranslation("plugin_explorer_deletefolder"), + SubTitle = isFile ? Context.API.GetTranslation("plugin_explorer_deletefile_subtitle") : Context.API.GetTranslation("plugin_explorer_deletefolder_subtitle"), Action = (context) => { try { if (MessageBox.Show( - string.Format(Context.API.GetTranslation("plugin_explorer_deletefilefolderconfirm"), fileOrFolder), + Context.API.GetTranslation("plugin_explorer_deletefilefolderconfirm"), string.Empty, MessageBoxButton.YesNo, MessageBoxIcon.Warning) == DialogResult.No) return false; - if (record.Type == ResultType.File) + if (isFile) File.Delete(record.FullPath); else Directory.Delete(record.FullPath, true); @@ -193,13 +189,13 @@ namespace Flow.Launcher.Plugin.Explorer _ = Task.Run(() => { Context.API.ShowMsg(Context.API.GetTranslation("plugin_explorer_deletefilefoldersuccess"), - string.Format(Context.API.GetTranslation("plugin_explorer_deletefilefoldersuccess_detail"), fileOrFolder), + string.Format(Context.API.GetTranslation("plugin_explorer_deletefilefoldersuccess_detail"), record.FullPath), Constants.ExplorerIconImageFullPath); }); } catch (Exception e) { - var message = $"Fail to delete {fileOrFolder} at {record.FullPath}"; + var message = $"Fail to delete {record.FullPath}"; LogException(message, e); Context.API.ShowMsgError(message); return false; @@ -256,7 +252,7 @@ namespace Flow.Launcher.Plugin.Explorer }, }); } - "" == "" + if (record.Type == ResultType.File && CanRunAsDifferentUser(record.FullPath)) contextMenus.Add(new Result { diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index bd950a2aa..3aa9e9271 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -6,9 +6,10 @@ Please make a selection first Please select a folder link Are you sure you want to delete {0}? - Are you sure you want to permanently delete this {0}? + Are you sure you want to permanently delete this folder? + Are you sure you want to permanently delete this file? Deletion successful - Successfully deleted the {0} + Successfully deleted {0} Assigning the global action keyword could bring up too many results during search. Please choose a specific action keyword Quick Access can not be set to the global action keyword when enabled. Please choose a specific action keyword The required service for Windows Index Search does not appear to be running @@ -62,8 +63,17 @@ Copy path + Copy path of current result to clipboard Copy + Copy file + Copy current file to clipboard + Copy folder + Copy current folder to clipboard Delete + Delete file + Permanently delete current file + Delete folder + Permanently delete current folder Path: Delete the selected Run as different user @@ -80,7 +90,7 @@ Manage indexed files and folders Failed to open Windows Indexing Options Add to Quick Access - Add the current {0} to Quick Access + Add current result to Quick Access Successfully Added Successfully added to Quick Access Successfully Removed @@ -88,11 +98,11 @@ Add to Quick Access so it can be opened with Explorer's Search Activation action keyword Remove from Quick Access Remove from Quick Access - Remove the current {0} from Quick Access + Remove current result from Quick Access Show Windows Context Menu - + - Everything SDK Loaded Fail + Failed to load Everything SDK Warning: Everything service is not running Error while querying Everything Sort By