Skip to content

Commit 8fbf3a3

Browse files
make file/folder translatble
1 parent 3b6c8b8 commit 8fbf3a3

File tree

2 files changed

+32
-26
lines changed

2 files changed

+32
-26
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ public List<Result> LoadContextMenus(Result selectedResult)
5959
}
6060

6161
var icoPath = (record.Type == ResultType.File) ? Constants.FileImagePath : Constants.FolderImagePath;
62-
var fileOrFolder = (record.Type == ResultType.File) ? "file" : "folder";
62+
bool isFile = record.Type == ResultType.File;
6363

6464
if (Settings.QuickAccessLinks.All(x => !x.Path.Equals(record.FullPath, StringComparison.OrdinalIgnoreCase)))
6565
{
6666
contextMenus.Add(new Result
6767
{
6868
Title = Context.API.GetTranslation("plugin_explorer_add_to_quickaccess_title"),
69-
SubTitle = string.Format(Context.API.GetTranslation("plugin_explorer_add_to_quickaccess_subtitle"), fileOrFolder),
69+
SubTitle = Context.API.GetTranslation("plugin_explorer_add_to_quickaccess_subtitle"),
7070
Action = (context) =>
7171
{
7272
Settings.QuickAccessLinks.Add(new AccessLink
@@ -75,10 +75,8 @@ public List<Result> LoadContextMenus(Result selectedResult)
7575
});
7676

7777
Context.API.ShowMsg(Context.API.GetTranslation("plugin_explorer_addfilefoldersuccess"),
78-
string.Format(
7978
Context.API.GetTranslation("plugin_explorer_addfilefoldersuccess_detail"),
80-
fileOrFolder),
81-
Constants.ExplorerIconImageFullPath);
79+
Constants.ExplorerIconImageFullPath);
8280

8381
ViewModel.Save();
8482

@@ -95,16 +93,14 @@ public List<Result> LoadContextMenus(Result selectedResult)
9593
contextMenus.Add(new Result
9694
{
9795
Title = Context.API.GetTranslation("plugin_explorer_remove_from_quickaccess_title"),
98-
SubTitle = string.Format(Context.API.GetTranslation("plugin_explorer_remove_from_quickaccess_subtitle"), fileOrFolder),
96+
SubTitle = Context.API.GetTranslation("plugin_explorer_remove_from_quickaccess_subtitle"),
9997
Action = (context) =>
10098
{
10199
Settings.QuickAccessLinks.Remove(Settings.QuickAccessLinks.FirstOrDefault(x => string.Equals(x.Path, record.FullPath, StringComparison.OrdinalIgnoreCase)));
102100

103101
Context.API.ShowMsg(Context.API.GetTranslation("plugin_explorer_removefilefoldersuccess"),
104-
string.Format(
105102
Context.API.GetTranslation("plugin_explorer_removefilefoldersuccess_detail"),
106-
fileOrFolder),
107-
Constants.ExplorerIconImageFullPath);
103+
Constants.ExplorerIconImageFullPath);
108104

109105
ViewModel.Save();
110106

@@ -120,7 +116,7 @@ public List<Result> LoadContextMenus(Result selectedResult)
120116
contextMenus.Add(new Result
121117
{
122118
Title = Context.API.GetTranslation("plugin_explorer_copypath"),
123-
SubTitle = $"Copy the current {fileOrFolder} path to clipboard",
119+
SubTitle = Context.API.GetTranslation("plugin_explorer_copypath_subtitle"),
124120
Action = _ =>
125121
{
126122
try
@@ -142,8 +138,8 @@ public List<Result> LoadContextMenus(Result selectedResult)
142138

143139
contextMenus.Add(new Result
144140
{
145-
Title = Context.API.GetTranslation("plugin_explorer_copyfilefolder") + $" {fileOrFolder}",
146-
SubTitle = $"Copy the {fileOrFolder} to clipboard",
141+
Title = isFile ? Context.API.GetTranslation("plugin_explorer_copyfile") : Context.API.GetTranslation("plugin_explorer_copyfolder"),
142+
SubTitle = isFile ? Context.API.GetTranslation("plugin_explorer_copyfile_subtitle") : Context.API.GetTranslation("plugin_explorer_copyfolder_subtitle"),
147143
Action = _ =>
148144
{
149145
try
@@ -156,7 +152,7 @@ public List<Result> LoadContextMenus(Result selectedResult)
156152
}
157153
catch (Exception e)
158154
{
159-
var message = $"Fail to set {fileOrFolder} in clipboard";
155+
var message = $"Fail to set file/folder in clipboard";
160156
LogException(message, e);
161157
Context.API.ShowMsg(message);
162158
return false;
@@ -171,35 +167,35 @@ public List<Result> LoadContextMenus(Result selectedResult)
171167
if (record.Type is ResultType.File or ResultType.Folder)
172168
contextMenus.Add(new Result
173169
{
174-
Title = Context.API.GetTranslation("plugin_explorer_deletefilefolder") + $" {fileOrFolder}",
175-
SubTitle = Context.API.GetTranslation("plugin_explorer_deletefilefolder_subtitle") + $" {fileOrFolder}",
170+
Title = isFile ? Context.API.GetTranslation("plugin_explorer_deletefile") : Context.API.GetTranslation("plugin_explorer_deletefolder"),
171+
SubTitle = isFile ? Context.API.GetTranslation("plugin_explorer_deletefile_subtitle") : Context.API.GetTranslation("plugin_explorer_deletefolder_subtitle"),
176172
Action = (context) =>
177173
{
178174
try
179175
{
180176
if (MessageBox.Show(
181-
string.Format(Context.API.GetTranslation("plugin_explorer_deletefilefolderconfirm"), fileOrFolder),
177+
Context.API.GetTranslation("plugin_explorer_deletefilefolderconfirm"),
182178
string.Empty,
183179
MessageBoxButton.YesNo,
184180
MessageBoxIcon.Warning)
185181
== DialogResult.No)
186182
return false;
187183

188-
if (record.Type == ResultType.File)
184+
if (isFile)
189185
File.Delete(record.FullPath);
190186
else
191187
Directory.Delete(record.FullPath, true);
192188

193189
_ = Task.Run(() =>
194190
{
195191
Context.API.ShowMsg(Context.API.GetTranslation("plugin_explorer_deletefilefoldersuccess"),
196-
string.Format(Context.API.GetTranslation("plugin_explorer_deletefilefoldersuccess_detail"), fileOrFolder),
192+
string.Format(Context.API.GetTranslation("plugin_explorer_deletefilefoldersuccess_detail"), record.FullPath),
197193
Constants.ExplorerIconImageFullPath);
198194
});
199195
}
200196
catch (Exception e)
201197
{
202-
var message = $"Fail to delete {fileOrFolder} at {record.FullPath}";
198+
var message = $"Fail to delete {record.FullPath}";
203199
LogException(message, e);
204200
Context.API.ShowMsgError(message);
205201
return false;
@@ -256,7 +252,7 @@ public List<Result> LoadContextMenus(Result selectedResult)
256252
},
257253
});
258254
}
259-
"" == ""
255+
260256
if (record.Type == ResultType.File && CanRunAsDifferentUser(record.FullPath))
261257
contextMenus.Add(new Result
262258
{

Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
<system:String x:Key="plugin_explorer_make_selection_warning">Please make a selection first</system:String>
77
<system:String x:Key="plugin_explorer_select_folder_link_warning">Please select a folder link</system:String>
88
<system:String x:Key="plugin_explorer_delete_folder_link">Are you sure you want to delete {0}?</system:String>
9-
<system:String x:Key="plugin_explorer_deletefilefolderconfirm">Are you sure you want to permanently delete this {0}?</system:String>
9+
<system:String x:Key="plugin_explorer_deletefolderconfirm">Are you sure you want to permanently delete this folder?</system:String>
10+
<system:String x:Key="plugin_explorer_deletefileconfirm">Are you sure you want to permanently delete this file?</system:String>
1011
<system:String x:Key="plugin_explorer_deletefilefoldersuccess">Deletion successful</system:String>
11-
<system:String x:Key="plugin_explorer_deletefilefoldersuccess_detail">Successfully deleted the {0}</system:String>
12+
<system:String x:Key="plugin_explorer_deletefilefoldersuccess_detail">Successfully deleted {0}</system:String>
1213
<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>
1314
<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>
1415
<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 @@
6263

6364
<!-- Context menu items -->
6465
<system:String x:Key="plugin_explorer_copypath">Copy path</system:String>
66+
<system:String x:Key="plugin_explorer_copypath_subtitle">Copy path of current result to clipboard</system:String>
6567
<system:String x:Key="plugin_explorer_copyfilefolder">Copy</system:String>
68+
<system:String x:Key="plugin_explorer_copyfile">Copy file</system:String>
69+
<system:String x:Key="plugin_explorer_copyfile_subtitle">Copy current file to clipboard</system:String>
70+
<system:String x:Key="plugin_explorer_copyfolder">Copy folder</system:String>
71+
<system:String x:Key="plugin_explorer_copyfolder_subtitle">Copy current folder to clipboard</system:String>
6672
<system:String x:Key="plugin_explorer_deletefilefolder">Delete</system:String>
73+
<system:String x:Key="plugin_explorer_deletefile">Delete file</system:String>
74+
<system:String x:Key="plugin_explorer_deletefile_subtitle">Permanently delete current file</system:String>
75+
<system:String x:Key="plugin_explorer_deletefolder">Delete folder</system:String>
76+
<system:String x:Key="plugin_explorer_deletefolder_subtitle">Permanently delete current folder</system:String>
6777
<system:String x:Key="plugin_explorer_path">Path:</system:String>
6878
<system:String x:Key="plugin_explorer_deletefilefolder_subtitle">Delete the selected</system:String>
6979
<system:String x:Key="plugin_explorer_runasdifferentuser">Run as different user</system:String>
@@ -80,19 +90,19 @@
8090
<system:String x:Key="plugin_explorer_openindexingoptions_subtitle">Manage indexed files and folders</system:String>
8191
<system:String x:Key="plugin_explorer_openindexingoptions_errormsg">Failed to open Windows Indexing Options</system:String>
8292
<system:String x:Key="plugin_explorer_add_to_quickaccess_title">Add to Quick Access</system:String>
83-
<system:String x:Key="plugin_explorer_add_to_quickaccess_subtitle">Add the current {0} to Quick Access</system:String>
93+
<system:String x:Key="plugin_explorer_add_to_quickaccess_subtitle">Add current result to Quick Access</system:String>
8494
<system:String x:Key="plugin_explorer_addfilefoldersuccess">Successfully Added</system:String>
8595
<system:String x:Key="plugin_explorer_addfilefoldersuccess_detail">Successfully added to Quick Access</system:String>
8696
<system:String x:Key="plugin_explorer_removefilefoldersuccess">Successfully Removed</system:String>
8797
<system:String x:Key="plugin_explorer_removefilefoldersuccess_detail">Successfully removed from Quick Access</system:String>
8898
<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>
8999
<system:String x:Key="plugin_explorer_contextmenu_remove_titletooltip">Remove from Quick Access</system:String>
90100
<system:String x:Key="plugin_explorer_remove_from_quickaccess_title">Remove from Quick Access</system:String>
91-
<system:String x:Key="plugin_explorer_remove_from_quickaccess_subtitle">Remove the current {0} from Quick Access</system:String>
101+
<system:String x:Key="plugin_explorer_remove_from_quickaccess_subtitle">Remove current result from Quick Access</system:String>
92102
<system:String x:Key="plugin_explorer_show_contextmenu_title">Show Windows Context Menu</system:String>
93-
103+
94104
<!-- Everything -->
95-
<system:String x:Key="flowlauncher_plugin_everything_sdk_issue">Everything SDK Loaded Fail</system:String>
105+
<system:String x:Key="flowlauncher_plugin_everything_sdk_issue">Failed to load Everything SDK</system:String>
96106
<system:String x:Key="flowlauncher_plugin_everything_is_not_running">Warning: Everything service is not running</system:String>
97107
<system:String x:Key="flowlauncher_plugin_everything_query_error">Error while querying Everything</system:String>
98108
<system:String x:Key="flowlauncher_plugin_everything_sort_by">Sort By</system:String>

0 commit comments

Comments
 (0)