diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs index 01ff3d64f..f7f05bf3d 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs @@ -181,21 +181,21 @@ namespace Flow.Launcher.Plugin.Explorer }); contextMenus.Add(new Result { - Title = Context.API.GetTranslation("plugin_explorer_rename_a_file"), - SubTitle = Context.API.GetTranslation("plugin_explorer_rename_subtitle"), + Title = Localize.plugin_explorer_rename_a_file(), + SubTitle = Localize.plugin_explorer_rename_subtitle(), Action = _ => { RenameFile window; switch (record.Type) { case ResultType.Folder: - window = new RenameFile(Context.API, new DirectoryInfo(record.FullPath)); + window = new RenameFile(new DirectoryInfo(record.FullPath)); break; case ResultType.File: - window = new RenameFile(Context.API, new FileInfo(record.FullPath)); + window = new RenameFile(new FileInfo(record.FullPath)); break; default: - Context.API.ShowMsgError(Context.API.GetTranslation("plugin_explorer_cannot_rename")); + Context.API.ShowMsgError(Localize.plugin_explorer_cannot_rename()); return false; } window.ShowDialog(); diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Helper/RenameThing.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Helper/RenameThing.cs index 82b9be818..2711d2e92 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Helper/RenameThing.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Helper/RenameThing.cs @@ -59,12 +59,12 @@ public static class RenameThing /// The requested new name /// The or representing the old file /// An instance of so this can create msgboxes - public static void Rename(string NewFileName, FileSystemInfo oldInfo, IPublicAPI api) + public static void Rename(string NewFileName, FileSystemInfo oldInfo) { // if it's just whitespace and nothing else - if (NewFileName.Trim() == "" || NewFileName == "") + if (string.IsNullOrEmpty(NewFileName.Trim()) || string.IsNullOrEmpty(NewFileName)) { - api.ShowMsgError(string.Format(api.GetTranslation("plugin_explorer_field_may_not_be_empty"), "New file name")); + Main.Context.API.ShowMsgError(Localize.plugin_explorer_field_may_not_be_empty()); return; } @@ -77,33 +77,34 @@ public static class RenameThing switch (exception) { case FileNotFoundException: - api.ShowMsgError(string.Format(api.GetTranslation("plugin_explorer_item_not_found"), oldInfo.FullName)); + Main.Context.API.ShowMsgError(Localize.plugin_explorer_item_not_found(oldInfo.FullName)); return; case NotANewNameException: - api.ShowMsgError(string.Format(api.GetTranslation("plugin_explorer_not_a_new_name"), NewFileName)); + Main.Context.API.ShowMsgError(Localize.plugin_explorer_not_a_new_name(NewFileName)); return; case InvalidNameException: - api.ShowMsgError(string.Format(api.GetTranslation("plugin_explorer_invalid_name"), NewFileName)); + Main.Context.API.ShowMsgError(Localize.plugin_explorer_invalid_name(NewFileName)); return; case ElementAlreadyExistsException: - api.ShowMsgError(string.Format(api.GetTranslation("plugin_explorer_element_already_exists"), NewFileName)); + Main.Context.API.ShowMsgError(Localize.plugin_explorer_element_already_exists(NewFileName)); return; default: string msg = exception.Message; if (!string.IsNullOrEmpty(msg)) { - api.ShowMsgError(string.Format(api.GetTranslation("plugin_explorer_exception"), exception.Message)); + Main.Context.API.ShowMsgError(Localize.plugin_explorer_exception(exception.Message)); return; } else { - api.ShowMsgError(api.GetTranslation("plugin_explorer_no_reason_given_exception")); + Main.Context.API.ShowMsgError(Localize.plugin_explorer_no_reason_given_exception()); } return; } } - api.ShowMsg(string.Format(api.GetTranslation("plugin_explorer_successful_rename"), NewFileName)); + + Main.Context.API.ShowMsg(Localize.plugin_explorer_successful_rename(NewFileName)); } } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index bc8821594..d53ec31f5 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -217,7 +217,7 @@ Rename Rename The given name: {0} was not new. - {0} may not be empty. + New file name should not be empty. {0} is an invalid name. The specified item: {0} was not found Open a dialog to rename file or folder diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs index 5375d8100..3a7d036dc 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs @@ -139,8 +139,8 @@ namespace Flow.Launcher.Plugin.Explorer new SearchWindowPluginHotkey() { Id = 0, - Name = Context.API.GetTranslation("plugin_explorer_opencontainingfolder"), - Description = Context.API.GetTranslation("plugin_explorer_opencontainingfolder_subtitle"), + Name = Localize.plugin_explorer_opencontainingfolder(), + Description = Localize.plugin_explorer_opencontainingfolder_subtitle(), Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\ue838"), DefaultHotkey = "Ctrl+Enter", Editable = false, @@ -163,7 +163,7 @@ namespace Flow.Launcher.Plugin.Explorer { var message = $"Fail to open file at {record.FullPath}"; Context.API.LogException(ClassName, message, e); - Context.API.ShowMsgBox(e.Message, Context.API.GetTranslation("plugin_explorer_opendir_error")); + Context.API.ShowMsgBox(e.Message, Localize.plugin_explorer_opendir_error()); return false; } @@ -177,7 +177,7 @@ namespace Flow.Launcher.Plugin.Explorer new SearchWindowPluginHotkey() { Id = 1, - Name = Context.API.GetTranslation("plugin_explorer_show_contextmenu_title"), + Name = Localize.plugin_explorer_show_contextmenu_title(), Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\ue700"), DefaultHotkey = "Alt+Enter", Editable = false, @@ -203,7 +203,7 @@ namespace Flow.Launcher.Plugin.Explorer new SearchWindowPluginHotkey() { Id = 2, - Name = Context.API.GetTranslation("plugin_explorer_run_as_administrator"), + Name = Localize.plugin_explorer_run_as_administrator(), Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE7EF"), DefaultHotkey = "Ctrl+Shift+Enter", Editable = false, @@ -228,7 +228,7 @@ namespace Flow.Launcher.Plugin.Explorer { var message = $"Fail to open file at {record.FullPath}"; Context.API.LogException(ClassName, message, 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; } } @@ -241,8 +241,8 @@ namespace Flow.Launcher.Plugin.Explorer new SearchWindowPluginHotkey() { Id = 3, - Name = Context.API.GetTranslation("plugin_explorer_rename_a_file"), - Description = Context.API.GetTranslation("plugin_explorer_rename_subtitle"), + Name = Localize.plugin_explorer_rename_a_file(), + Description = Localize.plugin_explorer_rename_subtitle(), Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\ue8ac"), DefaultHotkey = "F2", Editable = true, @@ -255,13 +255,13 @@ namespace Flow.Launcher.Plugin.Explorer switch (record.Type) { case ResultType.Folder: - window = new RenameFile(Context.API, new DirectoryInfo(record.FullPath)); + window = new RenameFile(new DirectoryInfo(record.FullPath)); break; case ResultType.File: - window = new RenameFile(Context.API, new FileInfo(record.FullPath)); + window = new RenameFile(new FileInfo(record.FullPath)); break; default: - Context.API.ShowMsgError(Context.API.GetTranslation("plugin_explorer_cannot_rename")); + Context.API.ShowMsgError(Localize.plugin_explorer_cannot_rename()); return false; } window.ShowDialog(); diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/RenameFile.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/RenameFile.xaml.cs index 323bb912f..23bdfd92a 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/RenameFile.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/RenameFile.xaml.cs @@ -23,14 +23,12 @@ namespace Flow.Launcher.Plugin.Explorer.Views private string _newFileName; - private readonly IPublicAPI _api; private readonly string _oldFilePath; private readonly FileSystemInfo _info; - public RenameFile(IPublicAPI api, FileSystemInfo info) + public RenameFile(FileSystemInfo info) { - _api = api; _info = info; _oldFilePath = _info.FullName; NewFileName = _info.Name; @@ -70,7 +68,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views private void OnDoneButtonClick(object sender, RoutedEventArgs e) { - RenameThing.Rename(NewFileName, _info, _api); + RenameThing.Rename(NewFileName, _info); Close(); }