make file/folder translatble

This commit is contained in:
Vic 2022-12-21 14:01:09 +08:00
parent 3b6c8b882b
commit 8fbf3a3f92
2 changed files with 32 additions and 26 deletions

View file

@ -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
{

View file

@ -6,9 +6,10 @@
<system:String x:Key="plugin_explorer_make_selection_warning">Please make a selection first</system:String>
<system:String x:Key="plugin_explorer_select_folder_link_warning">Please select a folder link</system:String>
<system:String x:Key="plugin_explorer_delete_folder_link">Are you sure you want to delete {0}?</system:String>
<system:String x:Key="plugin_explorer_deletefilefolderconfirm">Are you sure you want to permanently delete this {0}?</system:String>
<system:String x:Key="plugin_explorer_deletefolderconfirm">Are you sure you want to permanently delete this folder?</system:String>
<system:String x:Key="plugin_explorer_deletefileconfirm">Are you sure you want to permanently delete this file?</system:String>
<system:String x:Key="plugin_explorer_deletefilefoldersuccess">Deletion successful</system:String>
<system:String x:Key="plugin_explorer_deletefilefoldersuccess_detail">Successfully deleted the {0}</system:String>
<system:String x:Key="plugin_explorer_deletefilefoldersuccess_detail">Successfully deleted {0}</system:String>
<system:String x:Key="plugin_explorer_globalActionKeywordInvalid">Assigning the global action keyword could bring up too many results during search. Please choose a specific action keyword</system:String>
<system:String x:Key="plugin_explorer_quickaccess_globalActionKeywordInvalid">Quick Access can not be set to the global action keyword when enabled. Please choose a specific action keyword</system:String>
<system:String x:Key="plugin_explorer_windowsSearchServiceNotRunning">The required service for Windows Index Search does not appear to be running</system:String>
@ -62,8 +63,17 @@
<!-- Context menu items -->
<system:String x:Key="plugin_explorer_copypath">Copy path</system:String>
<system:String x:Key="plugin_explorer_copypath_subtitle">Copy path of current result to clipboard</system:String>
<system:String x:Key="plugin_explorer_copyfilefolder">Copy</system:String>
<system:String x:Key="plugin_explorer_copyfile">Copy file</system:String>
<system:String x:Key="plugin_explorer_copyfile_subtitle">Copy current file to clipboard</system:String>
<system:String x:Key="plugin_explorer_copyfolder">Copy folder</system:String>
<system:String x:Key="plugin_explorer_copyfolder_subtitle">Copy current folder to clipboard</system:String>
<system:String x:Key="plugin_explorer_deletefilefolder">Delete</system:String>
<system:String x:Key="plugin_explorer_deletefile">Delete file</system:String>
<system:String x:Key="plugin_explorer_deletefile_subtitle">Permanently delete current file</system:String>
<system:String x:Key="plugin_explorer_deletefolder">Delete folder</system:String>
<system:String x:Key="plugin_explorer_deletefolder_subtitle">Permanently delete current folder</system:String>
<system:String x:Key="plugin_explorer_path">Path:</system:String>
<system:String x:Key="plugin_explorer_deletefilefolder_subtitle">Delete the selected</system:String>
<system:String x:Key="plugin_explorer_runasdifferentuser">Run as different user</system:String>
@ -80,7 +90,7 @@
<system:String x:Key="plugin_explorer_openindexingoptions_subtitle">Manage indexed files and folders</system:String>
<system:String x:Key="plugin_explorer_openindexingoptions_errormsg">Failed to open Windows Indexing Options</system:String>
<system:String x:Key="plugin_explorer_add_to_quickaccess_title">Add to Quick Access</system:String>
<system:String x:Key="plugin_explorer_add_to_quickaccess_subtitle">Add the current {0} to Quick Access</system:String>
<system:String x:Key="plugin_explorer_add_to_quickaccess_subtitle">Add current result to Quick Access</system:String>
<system:String x:Key="plugin_explorer_addfilefoldersuccess">Successfully Added</system:String>
<system:String x:Key="plugin_explorer_addfilefoldersuccess_detail">Successfully added to Quick Access</system:String>
<system:String x:Key="plugin_explorer_removefilefoldersuccess">Successfully Removed</system:String>
@ -88,11 +98,11 @@
<system:String x:Key="plugin_explorer_contextmenu_titletooltip">Add to Quick Access so it can be opened with Explorer's Search Activation action keyword</system:String>
<system:String x:Key="plugin_explorer_contextmenu_remove_titletooltip">Remove from Quick Access</system:String>
<system:String x:Key="plugin_explorer_remove_from_quickaccess_title">Remove from Quick Access</system:String>
<system:String x:Key="plugin_explorer_remove_from_quickaccess_subtitle">Remove the current {0} from Quick Access</system:String>
<system:String x:Key="plugin_explorer_remove_from_quickaccess_subtitle">Remove current result from Quick Access</system:String>
<system:String x:Key="plugin_explorer_show_contextmenu_title">Show Windows Context Menu</system:String>
<!-- Everything -->
<system:String x:Key="flowlauncher_plugin_everything_sdk_issue">Everything SDK Loaded Fail</system:String>
<system:String x:Key="flowlauncher_plugin_everything_sdk_issue">Failed to load Everything SDK</system:String>
<system:String x:Key="flowlauncher_plugin_everything_is_not_running">Warning: Everything service is not running</system:String>
<system:String x:Key="flowlauncher_plugin_everything_query_error">Error while querying Everything</system:String>
<system:String x:Key="flowlauncher_plugin_everything_sort_by">Sort By</system:String>