Skip to content

Commit 563bf4d

Browse files
committed
ProcessKiller: add i18n support
1 parent a52575c commit 563bf4d

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

Plugins/Flow.Launcher.Plugin.ProcessKiller/Flow.Launcher.Plugin.ProcessKiller.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
<Content Include="Images\app.png">
3838
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3939
</Content>
40+
<Content Include="Languages\en.xaml">
41+
<SubType>Designer</SubType>
42+
<Generator>MSBuild:Compile</Generator>
43+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
44+
</Content>
4045
<Content Include="plugin.json">
4146
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
4247
</Content>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:system="clr-namespace:System;assembly=mscorlib">
4+
5+
<system:String x:Key="flowlauncher_plugin_processkiller_plugin_name">Process Killer</system:String>
6+
<system:String x:Key="flowlauncher_plugin_processkiller_plugin_description">Kill running processes from Flow Launcher</system:String>
7+
8+
<system:String x:Key="flowlauncher_plugin_processkiller_kill_all">kill all "{0}" processes</system:String>
9+
10+
</ResourceDictionary>

Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace Flow.Launcher.Plugin.ProcessKiller
1212
{
13-
public class Main : IPlugin
13+
public class Main : IPlugin, IPluginI18n
1414
{
1515
private readonly HashSet<string> _systemProcessList = new HashSet<string>(){
1616
"conhost",
@@ -28,6 +28,13 @@ public class Main : IPlugin
2828
"spoolsv",
2929
"explorer"};
3030

31+
private static PluginInitContext _context;
32+
33+
public void Init(PluginInitContext context)
34+
{
35+
_context = context;
36+
}
37+
3138
public List<Result> Query(Query query)
3239
{
3340
var termToSearch = query.Terms.Length == 1
@@ -41,6 +48,16 @@ public List<Result> Query(Query query)
4148
: CreateResultsFromProcesses(processlist, termToSearch);
4249
}
4350

51+
public string GetTranslatedPluginTitle()
52+
{
53+
return _context.API.GetTranslation("flowlauncher_plugin_processkiller_plugin_name");
54+
}
55+
56+
public string GetTranslatedPluginDescription()
57+
{
58+
return _context.API.GetTranslation("flowlauncher_plugin_processkiller_plugin_description");
59+
}
60+
4461
private List<Result> CreateResultsFromProcesses(List<ProcessResult> processlist, string termToSearch)
4562
{
4663
var results = new List<Result>();
@@ -69,7 +86,7 @@ private List<Result> CreateResultsFromProcesses(List<ProcessResult> processlist,
6986
results.Insert(0, new Result()
7087
{
7188
IcoPath = "Images\\app.png",
72-
Title = "kill all \"" + termToSearch + "\" processes",
89+
Title = string.Format(_context.API.GetTranslation("flowlauncher_plugin_processkiller_kill_all"), termToSearch),
7390
SubTitle = "",
7491
Score = 200,
7592
Action = (c) =>
@@ -158,10 +175,6 @@ private string GetPath(Process p)
158175
}
159176
}
160177

161-
public void Init(PluginInitContext context)
162-
{
163-
}
164-
165178
[Flags]
166179
private enum ProcessAccessFlags : uint
167180
{

0 commit comments

Comments
 (0)