ProcessKiller: add i18n support

This commit is contained in:
Ioannis G 2020-07-03 01:16:33 +03:00
parent a52575cc17
commit 563bf4d797
No known key found for this signature in database
GPG key ID: EAC0E4E5E36AC49E
3 changed files with 34 additions and 6 deletions

View file

@ -37,6 +37,11 @@
<Content Include="Images\app.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Languages\en.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="plugin.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

View file

@ -0,0 +1,10 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="flowlauncher_plugin_processkiller_plugin_name">Process Killer</system:String>
<system:String x:Key="flowlauncher_plugin_processkiller_plugin_description">Kill running processes from Flow Launcher</system:String>
<system:String x:Key="flowlauncher_plugin_processkiller_kill_all">kill all "{0}" processes</system:String>
</ResourceDictionary>

View file

@ -10,7 +10,7 @@ using Flow.Launcher.Infrastructure.Logger;
namespace Flow.Launcher.Plugin.ProcessKiller
{
public class Main : IPlugin
public class Main : IPlugin, IPluginI18n
{
private readonly HashSet<string> _systemProcessList = new HashSet<string>(){
"conhost",
@ -28,6 +28,13 @@ namespace Flow.Launcher.Plugin.ProcessKiller
"spoolsv",
"explorer"};
private static PluginInitContext _context;
public void Init(PluginInitContext context)
{
_context = context;
}
public List<Result> Query(Query query)
{
var termToSearch = query.Terms.Length == 1
@ -41,6 +48,16 @@ namespace Flow.Launcher.Plugin.ProcessKiller
: CreateResultsFromProcesses(processlist, termToSearch);
}
public string GetTranslatedPluginTitle()
{
return _context.API.GetTranslation("flowlauncher_plugin_processkiller_plugin_name");
}
public string GetTranslatedPluginDescription()
{
return _context.API.GetTranslation("flowlauncher_plugin_processkiller_plugin_description");
}
private List<Result> CreateResultsFromProcesses(List<ProcessResult> processlist, string termToSearch)
{
var results = new List<Result>();
@ -69,7 +86,7 @@ namespace Flow.Launcher.Plugin.ProcessKiller
results.Insert(0, new Result()
{
IcoPath = "Images\\app.png",
Title = "kill all \"" + termToSearch + "\" processes",
Title = string.Format(_context.API.GetTranslation("flowlauncher_plugin_processkiller_kill_all"), termToSearch),
SubTitle = "",
Score = 200,
Action = (c) =>
@ -158,10 +175,6 @@ namespace Flow.Launcher.Plugin.ProcessKiller
}
}
public void Init(PluginInitContext context)
{
}
[Flags]
private enum ProcessAccessFlags : uint
{