@@ -24,28 +24,26 @@ internal PluginsManager(PluginInitContext context)
24
24
}
25
25
internal void InstallOrUpdate ( UserPlugin plugin )
26
26
{
27
- if ( PluginExists ( plugin . ID ) )
27
+ if ( PluginExists ( plugin . ID ) )
28
28
{
29
- var updateMessage = $ "Do you want to update following plugin?{ Environment . NewLine } { Environment . NewLine } " +
30
- $ "Name: { plugin . Name } { Environment . NewLine } " +
31
- $ "{ Environment . NewLine } New Version: { plugin . Version } " +
32
- $ "{ Environment . NewLine } Author: { plugin . Author } ";
33
-
34
- throw new NotImplementedException ( ) ;
29
+ Context . API . ShowMsg ( "Plugin already installed" ) ;
30
+ return ;
35
31
}
36
32
37
- var message = $ "Do you want to install following plugin?{ Environment . NewLine } { Environment . NewLine } " +
38
- $ "Name: { plugin . Name } { Environment . NewLine } " +
39
- $ "Version: { plugin . Version } { Environment . NewLine } " +
40
- $ "Author: { plugin . Author } ";
33
+ var message = string . Format ( Context . API . GetTranslation ( "plugin_pluginsmanager_install_prompt" ) ,
34
+ Environment . NewLine , Environment . NewLine ,
35
+ plugin . Name , plugin . Author ) ;
41
36
42
- if ( MessageBox . Show ( message , "Install plugin" , MessageBoxButton . YesNo ) == MessageBoxResult . No )
37
+ if ( MessageBox . Show ( message , Context . API . GetTranslation ( "plugin_pluginsmanager_install_title" ) , MessageBoxButton . YesNo ) == MessageBoxResult . No )
43
38
return ;
44
39
45
40
var filePath = Path . Combine ( DataLocation . PluginsDirectory , $ "{ plugin . Name } { plugin . ID } .zip") ;
46
41
47
42
try
48
43
{
44
+ Context . API . ShowMsg ( Context . API . GetTranslation ( "plugin_pluginsmanager_downloading_plugin" ) ,
45
+ Context . API . GetTranslation ( "plugin_pluginsmanager_please_wait" ) ) ;
46
+
49
47
Utilities . Download ( plugin . UrlDownload , filePath ) ;
50
48
51
49
Context . API . ShowMsg ( Context . API . GetTranslation ( "plugin_pluginsmanager_downloading_plugin" ) ,
@@ -103,8 +101,6 @@ internal List<Result> RequestInstallOrUpdate(string searchName)
103
101
IcoPath = icoPath ,
104
102
Action = e =>
105
103
{
106
- Context . API . ShowMsg ( Context . API . GetTranslation ( "plugin_pluginsmanager_downloading_plugin" ) ,
107
- Context . API . GetTranslation ( "plugin_pluginsmanager_please_wait" ) ) ;
108
104
Application . Current . MainWindow . Hide ( ) ;
109
105
InstallOrUpdate ( x ) ;
110
106
@@ -142,17 +138,18 @@ private void Install(UserPlugin plugin, string downloadedFilePath)
142
138
143
139
if ( string . IsNullOrEmpty ( metadataJsonFilePath ) || string . IsNullOrEmpty ( pluginFolderPath ) )
144
140
{
145
- MessageBox . Show ( "Install failed: unable to find the plugin.json metadata file from the new plugin" ) ;
141
+ MessageBox . Show ( Context . API . GetTranslation ( "plugin_pluginsmanager_install_errormetadatafile" ) ) ;
146
142
return ;
147
143
}
148
144
149
145
string newPluginPath = Path . Combine ( DataLocation . PluginsDirectory , $ "{ plugin . Name } { plugin . ID } ") ;
150
146
151
147
Directory . Move ( pluginFolderPath , newPluginPath ) ;
152
148
153
- if ( MessageBox . Show ( $ "You have installed plugin { plugin . Name } successfully.{ Environment . NewLine } " +
154
- "Restart Flow Launcher to take effect?" ,
155
- "Install plugin" , MessageBoxButton . YesNo , MessageBoxImage . Question ) == MessageBoxResult . Yes )
149
+ if ( MessageBox . Show ( string . Format ( Context . API . GetTranslation ( "plugin_pluginsmanager_install_successandrestart" ) ,
150
+ plugin . Name , Environment . NewLine ) ,
151
+ Context . API . GetTranslation ( "plugin_pluginsmanager_install_title" ) ,
152
+ MessageBoxButton . YesNo , MessageBoxImage . Question ) == MessageBoxResult . Yes )
156
153
Context . API . RestartApp ( ) ;
157
154
}
158
155
@@ -181,18 +178,19 @@ internal List<Result> RequestUninstall(string search)
181
178
182
179
private void Uninstall ( PluginMetadata plugin )
183
180
{
184
- string message = Context . API . GetTranslation ( "plugin_pluginsmanager_uninstall_prompt" ) +
185
- $ " { Environment . NewLine } { Environment . NewLine } " +
186
- $ " { plugin . Name } by { plugin . Author } " ;
181
+ string message = string . Format ( Context . API . GetTranslation ( "plugin_pluginsmanager_uninstall_prompt" ) ,
182
+ Environment . NewLine , Environment . NewLine ,
183
+ plugin . Name , plugin . Author ) ;
187
184
188
- if ( MessageBox . Show ( message , "Flow Launcher" , MessageBoxButton . YesNo ) == MessageBoxResult . Yes )
185
+ if ( MessageBox . Show ( message , Context . API . GetTranslation ( "plugin_pluginsmanager_uninstall_title" ) ,
186
+ MessageBoxButton . YesNo ) == MessageBoxResult . Yes )
189
187
{
190
188
using var _ = File . CreateText ( Path . Combine ( plugin . PluginDirectory , "NeedDelete.txt" ) ) ;
191
189
192
- var result = MessageBox . Show ( $ "You have uninstalled plugin { plugin . Name } successfully. { Environment . NewLine } " +
193
- "Restart Flow Launcher to take effect?" ,
194
- "Install plugin" , MessageBoxButton . YesNo , MessageBoxImage . Question ) ;
195
- if ( result == MessageBoxResult . Yes )
190
+ if ( MessageBox . Show ( string . Format ( Context . API . GetTranslation ( "plugin_pluginsmanager_uninstall_successandrestart" ) ,
191
+ plugin . Name , Environment . NewLine ) ,
192
+ Context . API . GetTranslation ( "plugin_pluginsmanager_uninstall_title" ) ,
193
+ MessageBoxButton . YesNo , MessageBoxImage . Question ) == MessageBoxResult . Yes )
196
194
Context . API . RestartApp ( ) ;
197
195
}
198
196
}
0 commit comments