Add plugin title translations

This commit is contained in:
qianlifeng 2015-02-07 20:17:49 +08:00
parent 82d30c6e74
commit 437c1a154c
43 changed files with 433 additions and 218 deletions

View File

@ -213,6 +213,16 @@ namespace Wox.Plugin.CMD
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages");
}
public string GetTranslatedPluginTitle()
{
return context.API.GetTranslation("wox_plugin_cmd_plugin_name");
}
public string GetTranslatedPluginDescription()
{
return context.API.GetTranslation("wox_plugin_cmd_plugin_description");
}
public bool IsInstantQuery(string query)
{
if (query.StartsWith(">")) return true;

View File

@ -4,5 +4,7 @@
<system:String x:Key="wox_plugin_cmd_relace_winr">Replace Win+R</system:String>
<system:String x:Key="wox_plugin_cmd_leave_cmd_open">Do not close Command Prompt after command execution</system:String>
<system:String x:Key="wox_plugin_cmd_plugin_name">Shell</system:String>
<system:String x:Key="wox_plugin_cmd_plugin_description">Provide executing commands from Wox. Commands should start with ></system:String>
</ResourceDictionary>

View File

@ -1,8 +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="wox_plugin_cmd_relace_winr">替换 Win+R</system:String>
<system:String x:Key="wox_plugin_cmd_leave_cmd_open">执行后不关闭命令窗口</system:String>
<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="wox_plugin_cmd_relace_winr">替换 Win+R</system:String>
<system:String x:Key="wox_plugin_cmd_leave_cmd_open">执行后不关闭命令窗口</system:String>
<system:String x:Key="wox_plugin_cmd_plugin_name">命令行</system:String>
<system:String x:Key="wox_plugin_cmd_plugin_description">提供从Wox中执行命令行的能力命令应该以>开头</system:String>
</ResourceDictionary>

View File

@ -1,8 +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="wox_plugin_cmd_relace_winr">替換 Win+R</system:String>
<system:String x:Key="wox_plugin_cmd_leave_cmd_open">執行後不關閉命令窗口</system:String>
<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="wox_plugin_cmd_relace_winr">替換 Win+R</system:String>
<system:String x:Key="wox_plugin_cmd_leave_cmd_open">執行後不關閉命令窗口</system:String>
<system:String x:Key="wox_plugin_cmd_plugin_name">命令行</system:String>
<system:String x:Key="wox_plugin_cmd_plugin_description">提供從Wox中執行命令行的能力命令應該以>開頭</system:String>
</ResourceDictionary>

View File

@ -7,5 +7,8 @@
<system:String x:Key="wox_plugin_everything_copied">Copied</system:String>
<system:String x:Key="wox_plugin_everything_canot_start">Can't start {0}</system:String>
<system:String x:Key="wox_plugin_everything_open_containing_folder">Open containing folder</system:String>
<system:String x:Key="wox_plugin_everything_plugin_name">Everything</system:String>
<system:String x:Key="wox_plugin_everything_plugin_description">Search disk files using Everything</system:String>
</ResourceDictionary>

View File

@ -8,4 +8,7 @@
<system:String x:Key="wox_plugin_everything_canot_start">不能启动 {0}</system:String>
<system:String x:Key="wox_plugin_everything_open_containing_folder">打开所属文件夹</system:String>
<system:String x:Key="wox_plugin_everything_plugin_name">Everything</system:String>
<system:String x:Key="wox_plugin_everything_plugin_description">利用Everything搜索磁盘文件</system:String>
</ResourceDictionary>

View File

@ -8,4 +8,6 @@
<system:String x:Key="wox_plugin_everything_canot_start">不能啟動 {0}</system:String>
<system:String x:Key="wox_plugin_everything_open_containing_folder">打開所屬文件夾</system:String>
<system:String x:Key="wox_plugin_everything_plugin_name">Everything</system:String>
<system:String x:Key="wox_plugin_everything_plugin_description">利用Everything搜索磁盤文件</system:String>
</ResourceDictionary>

View File

@ -211,5 +211,15 @@ namespace Wox.Plugin.Everything
{
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages");
}
public string GetTranslatedPluginTitle()
{
return context.API.GetTranslation("wox_plugin_everything_plugin_name");
}
public string GetTranslatedPluginDescription()
{
return context.API.GetTranslation("wox_plugin_everything_plugin_description");
}
}
}

View File

@ -41,6 +41,7 @@
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />

View File

@ -220,5 +220,15 @@ namespace Wox.Plugin.Folder
{
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages");
}
public string GetTranslatedPluginTitle()
{
return context.API.GetTranslation("wox_plugin_folder_plugin_name");
}
public string GetTranslatedPluginDescription()
{
return context.API.GetTranslation("wox_plugin_folder_plugin_description");
}
}
}

View File

@ -8,5 +8,8 @@
<system:String x:Key="wox_plugin_folder_folder_path">Folder Path</system:String>
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">Please select a folder link</system:String>
<system:String x:Key="wox_plugin_folder_delete_folder_link">Are your sure to delete {0}?</system:String>
<system:String x:Key="wox_plugin_folder_plugin_name">Folder</system:String>
<system:String x:Key="wox_plugin_folder_plugin_description">Open favorite folder from wox directorily</system:String>
</ResourceDictionary>

View File

@ -1,12 +1,15 @@
<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="wox_plugin_folder_delete">删除</system:String>
<system:String x:Key="wox_plugin_folder_edit">编辑</system:String>
<system:String x:Key="wox_plugin_folder_add">添加</system:String>
<system:String x:Key="wox_plugin_folder_folder_path">文件夹路径</system:String>
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">请选择一个文件夹</system:String>
<system:String x:Key="wox_plugin_folder_delete_folder_link">你确定要删除{0}吗?</system:String>
<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="wox_plugin_folder_delete">删除</system:String>
<system:String x:Key="wox_plugin_folder_edit">编辑</system:String>
<system:String x:Key="wox_plugin_folder_add">添加</system:String>
<system:String x:Key="wox_plugin_folder_folder_path">文件夹路径</system:String>
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">请选择一个文件夹</system:String>
<system:String x:Key="wox_plugin_folder_delete_folder_link">你确定要删除{0}吗?</system:String>
<system:String x:Key="wox_plugin_folder_plugin_name">文件夹</system:String>
<system:String x:Key="wox_plugin_folder_plugin_description">在Wox中直接打开收藏的文件夹</system:String>
</ResourceDictionary>

View File

@ -1,12 +1,15 @@
<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="wox_plugin_folder_delete">刪除</system:String>
<system:String x:Key="wox_plugin_folder_edit">編輯</system:String>
<system:String x:Key="wox_plugin_folder_add">添加</system:String>
<system:String x:Key="wox_plugin_folder_folder_path">文件夾路徑</system:String>
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">請選擇一個文件夾</system:String>
<system:String x:Key="wox_plugin_folder_delete_folder_link">你確認要刪除{0}嗎?</system:String>
<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="wox_plugin_folder_delete">刪除</system:String>
<system:String x:Key="wox_plugin_folder_edit">編輯</system:String>
<system:String x:Key="wox_plugin_folder_add">添加</system:String>
<system:String x:Key="wox_plugin_folder_folder_path">文件夾路徑</system:String>
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">請選擇一個文件夾</system:String>
<system:String x:Key="wox_plugin_folder_delete_folder_link">你確認要刪除{0}嗎?</system:String>
<system:String x:Key="wox_plugin_folder_plugin_name">文件夾</system:String>
<system:String x:Key="wox_plugin_folder_plugin_description">在Wox中直接打開收藏的文件夾</system:String>
</ResourceDictionary>

View File

@ -2,7 +2,7 @@
"ID":"B4D3B69656E14D44865C8D818EAE47C4",
"ActionKeyword":"*",
"Name":"Folder",
"Description":"Provide opening folder from wox directorily. You can add your favorite folders.",
"Description":"Open favorite folder from wox directorily",
"Author":"qianlifeng",
"Version":"1.0.0",
"Language":"csharp",

View File

@ -22,5 +22,8 @@
<system:String x:Key="wox_plugin_program_run_as_administrator">Run As Administrator</system:String>
<system:String x:Key="wox_plugin_program_open_containing_folder">Open containing folder</system:String>
<system:String x:Key="wox_plugin_program_plugin_name">Program</system:String>
<system:String x:Key="wox_plugin_program_plugin_description">Search programs in Wox</system:String>
</ResourceDictionary>

View File

@ -24,4 +24,7 @@
<system:String x:Key="wox_plugin_program_run_as_administrator">以管理员身份运行</system:String>
<system:String x:Key="wox_plugin_program_open_containing_folder">打开所属文件夹</system:String>
<system:String x:Key="wox_plugin_program_plugin_name">程序</system:String>
<system:String x:Key="wox_plugin_program_plugin_description">在Wox中搜索程序</system:String>
</ResourceDictionary>

View File

@ -23,4 +23,7 @@
<system:String x:Key="wox_plugin_program_run_as_administrator">以管理員身份運行</system:String>
<system:String x:Key="wox_plugin_program_open_containing_folder">打開所屬文件夾</system:String>
<system:String x:Key="wox_plugin_program_plugin_name">程序</system:String>
<system:String x:Key="wox_plugin_program_plugin_description">在Wox中搜索程序</system:String>
</ResourceDictionary>

View File

@ -223,5 +223,14 @@ namespace Wox.Plugin.Program
{
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages");
}
public string GetTranslatedPluginTitle()
{
return context.API.GetTranslation("wox_plugin_program_plugin_name");
}
public string GetTranslatedPluginDescription()
{
return context.API.GetTranslation("wox_plugin_program_plugin_description");
}
}
}

View File

@ -2,7 +2,7 @@
"ID":"791FC278BA414111B8D1886DFE447410",
"ActionKeyword":"*",
"Name":"Program",
"Description":"Provide programs search for Wox.",
"Description":"Search programs in Wox",
"Author":"qianlifeng",
"Version":"1.0.0",
"Language":"csharp",

View File

@ -11,5 +11,8 @@
<system:String x:Key="wox_plugin_sys_exit">Close Wox</system:String>
<system:String x:Key="wox_plugin_sys_restart">Restart Wox</system:String>
<system:String x:Key="wox_plugin_sys_setting">Tweak this app</system:String>
<system:String x:Key="wox_plugin_sys_plugin_name">System Commands</system:String>
<system:String x:Key="wox_plugin_sys_plugin_description">Provide System related commands. e.g. shutdown,lock,setting etc.</system:String>
</ResourceDictionary>

View File

@ -1,15 +1,18 @@
<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="wox_plugin_sys_command">命令</system:String>
<system:String x:Key="wox_plugin_sys_desc">描述</system:String>
<system:String x:Key="wox_plugin_sys_shutdown_computer">关闭电脑</system:String>
<system:String x:Key="wox_plugin_sys_log_off">注销</system:String>
<system:String x:Key="wox_plugin_sys_lock">锁定这台电脑</system:String>
<system:String x:Key="wox_plugin_sys_exit">退出Wox</system:String>
<system:String x:Key="wox_plugin_sys_restart">重启Wox</system:String>
<system:String x:Key="wox_plugin_sys_setting">设置</system:String>
<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="wox_plugin_sys_command">命令</system:String>
<system:String x:Key="wox_plugin_sys_desc">描述</system:String>
<system:String x:Key="wox_plugin_sys_shutdown_computer">关闭电脑</system:String>
<system:String x:Key="wox_plugin_sys_log_off">注销</system:String>
<system:String x:Key="wox_plugin_sys_lock">锁定这台电脑</system:String>
<system:String x:Key="wox_plugin_sys_exit">退出Wox</system:String>
<system:String x:Key="wox_plugin_sys_restart">重启Wox</system:String>
<system:String x:Key="wox_plugin_sys_setting">设置</system:String>
<system:String x:Key="wox_plugin_sys_plugin_name">系统命令</system:String>
<system:String x:Key="wox_plugin_sys_plugin_description">系统系统相关的命令。例如,关机,锁定,设置等</system:String>
</ResourceDictionary>

View File

@ -1,15 +1,18 @@
<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="wox_plugin_sys_command">命令</system:String>
<system:String x:Key="wox_plugin_sys_desc">描述</system:String>
<system:String x:Key="wox_plugin_sys_shutdown_computer">關閉電腦</system:String>
<system:String x:Key="wox_plugin_sys_log_off">註銷</system:String>
<system:String x:Key="wox_plugin_sys_lock">鎖定這臺電腦</system:String>
<system:String x:Key="wox_plugin_sys_exit">退出Wox</system:String>
<system:String x:Key="wox_plugin_sys_restart">重啟Wox</system:String>
<system:String x:Key="wox_plugin_sys_setting">設置</system:String>
<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="wox_plugin_sys_command">命令</system:String>
<system:String x:Key="wox_plugin_sys_desc">描述</system:String>
<system:String x:Key="wox_plugin_sys_shutdown_computer">關閉電腦</system:String>
<system:String x:Key="wox_plugin_sys_log_off">註銷</system:String>
<system:String x:Key="wox_plugin_sys_lock">鎖定這臺電腦</system:String>
<system:String x:Key="wox_plugin_sys_exit">退出Wox</system:String>
<system:String x:Key="wox_plugin_sys_restart">重啟Wox</system:String>
<system:String x:Key="wox_plugin_sys_setting">設置</system:String>
<system:String x:Key="wox_plugin_sys_plugin_name">系統命令</system:String>
<system:String x:Key="wox_plugin_sys_plugin_description">系統系統相關的命令。例如,關機,鎖定,設置等</system:String>
</ResourceDictionary>

View File

@ -4,6 +4,7 @@ using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Wox.Infrastructure;
namespace Wox.Plugin.Sys
{
@ -42,7 +43,7 @@ namespace Wox.Plugin.Sys
List<Result> results = new List<Result>();
foreach (Result availableResult in availableResults)
{
if (availableResult.Title.ToLower().StartsWith(query.Search.ToLower()))
if (StringMatcher.IsMatch(availableResult.Title, query.Search) || StringMatcher.IsMatch(availableResult.SubTitle, query.Search))
{
results.Add(availableResult);
}
@ -142,5 +143,15 @@ namespace Wox.Plugin.Sys
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages");
}
}
public string GetTranslatedPluginTitle()
{
return context.API.GetTranslation("wox_plugin_sys_plugin_name");
}
public string GetTranslatedPluginDescription()
{
return context.API.GetTranslation("wox_plugin_sys_plugin_description");
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -0,0 +1,11 @@
<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="wox_plugin_url_open_url">Open url:{0}</system:String>
<system:String x:Key="wox_plugin_url_canot_open_url">Can't open url:{0}</system:String>
<system:String x:Key="wox_plugin_url_plugin_name">URL</system:String>
<system:String x:Key="wox_plugin_url_plugin_description">Open the typed URL from Wox</system:String>
</ResourceDictionary>

View File

@ -0,0 +1,11 @@
<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="wox_plugin_url_open_url">打开链接:{0}</system:String>
<system:String x:Key="wox_plugin_url_canot_open_url">无法打开链接:{0}</system:String>
<system:String x:Key="wox_plugin_url_plugin_name">URL</system:String>
<system:String x:Key="wox_plugin_url_plugin_description">从Wox打开链接</system:String>
</ResourceDictionary>

View File

@ -0,0 +1,11 @@
<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="wox_plugin_url_open_url">打開鏈接:{0}</system:String>
<system:String x:Key="wox_plugin_url_canot_open_url">無法打開鏈接:{0}</system:String>
<system:String x:Key="wox_plugin_url_plugin_name">URL</system:String>
<system:String x:Key="wox_plugin_url_plugin_description">從Wox打開鏈接</system:String>
</ResourceDictionary>

View File

@ -1,15 +1,17 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Windows;
namespace Wox.Plugin.Url
{
public class UrlPlugin : IPlugin
public class UrlPlugin : IPlugin, IPluginI18n
{
//based on https://gist.github.com/dperini/729294
private const string urlPattern ="^" +
private const string urlPattern = "^" +
// protocol identifier
"(?:(?:https?|ftp)://|)" +
// user:pass authentication
@ -42,6 +44,7 @@ namespace Wox.Plugin.Url
"(?:/\\S*)?" +
"$";
Regex reg = new Regex(urlPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
private PluginInitContext context;
public List<Result> Query(Query query)
{
@ -53,7 +56,7 @@ namespace Wox.Plugin.Url
new Result
{
Title = raw,
SubTitle = "Open " + raw,
SubTitle = string.Format(context.API.GetTranslation("wox_plugin_url_open_url"),raw),
IcoPath = "Images/url.png",
Score = 8,
Action = _ =>
@ -69,7 +72,7 @@ namespace Wox.Plugin.Url
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Could not open " + raw);
context.API.ShowMsg(string.Format(context.API.GetTranslation("wox_plugin_url_canot_open_url"), raw));
return false;
}
}
@ -98,7 +101,22 @@ namespace Wox.Plugin.Url
public void Init(PluginInitContext context)
{
this.context = context;
}
public string GetLanguagesFolder()
{
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages");
}
public string GetTranslatedPluginTitle()
{
return context.API.GetTranslation("wox_plugin_url_plugin_name");
}
public string GetTranslatedPluginDescription()
{
return context.API.GetTranslation("wox_plugin_url_plugin_description");
}
}
}

View File

@ -64,6 +64,27 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="Languages\en.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="Languages\zh-cn.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="Languages\zh-tw.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -1,8 +1,8 @@
{
"ID":"0308FD86DE0A4DEE8D62B9B535370992",
"ActionKeyword":"*",
"Name":"URL handler",
"Description":"Provide Opening the typed URL from Wox.",
"Name":"URL",
"Description":"Open the typed URL from Wox",
"Author":"qianlifeng",
"Version":"1.0.0",
"Language":"csharp",

View File

@ -24,5 +24,8 @@
<system:String x:Key="wox_plugin_websearch_input_url">Please input URL</system:String>
<system:String x:Key="wox_plugin_websearch_action_keyword_exist">ActionWord has existed, please input a new one</system:String>
<system:String x:Key="wox_plugin_websearch_succeed">Succeed</system:String>
<system:String x:Key="wox_plugin_websearch_plugin_name">Web Searches</system:String>
<system:String x:Key="wox_plugin_websearch_plugin_description">Provide the web search ability</system:String>
</ResourceDictionary>

View File

@ -1,28 +1,31 @@
<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="wox_plugin_websearch_delete">删除</system:String>
<system:String x:Key="wox_plugin_websearch_edit">编辑</system:String>
<system:String x:Key="wox_plugin_websearch_add">添加</system:String>
<system:String x:Key="wox_plugin_websearch_action_keyword">触发关键字</system:String>
<system:String x:Key="wox_plugin_websearch_url">URL</system:String>
<system:String x:Key="wox_plugin_websearch_enable_suggestion">启用搜索建议</system:String>
<system:String x:Key="wox_plugin_websearch_pls_select_web_search">请选择一项</system:String>
<system:String x:Key="wox_plugin_websearch_delete_warning">你确定要删除 {0} 吗?</system:String>
<!--web search edit-->
<system:String x:Key="wox_plugin_websearch_title">标题</system:String>
<system:String x:Key="wox_plugin_websearch_enable">启用</system:String>
<system:String x:Key="wox_plugin_websearch_icon">图标</system:String>
<system:String x:Key="wox_plugin_websearch_select_icon">选择图标</system:String>
<system:String x:Key="wox_plugin_websearch_cancel">取消</system:String>
<system:String x:Key="wox_plugin_websearch_invalid_web_search">非法的网页搜索</system:String>
<system:String x:Key="wox_plugin_websearch_input_title">请输入标题</system:String>
<system:String x:Key="wox_plugin_websearch_input_action_keyword">请输入触发关键字</system:String>
<system:String x:Key="wox_plugin_websearch_input_url">请输入URL</system:String>
<system:String x:Key="wox_plugin_websearch_action_keyword_exist">触发关键字已经存在,请选择一个新的关键字</system:String>
<system:String x:Key="wox_plugin_websearch_succeed">操作成功</system:String>
<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="wox_plugin_websearch_delete">删除</system:String>
<system:String x:Key="wox_plugin_websearch_edit">编辑</system:String>
<system:String x:Key="wox_plugin_websearch_add">添加</system:String>
<system:String x:Key="wox_plugin_websearch_action_keyword">触发关键字</system:String>
<system:String x:Key="wox_plugin_websearch_url">URL</system:String>
<system:String x:Key="wox_plugin_websearch_enable_suggestion">启用搜索建议</system:String>
<system:String x:Key="wox_plugin_websearch_pls_select_web_search">请选择一项</system:String>
<system:String x:Key="wox_plugin_websearch_delete_warning">你确定要删除 {0} 吗?</system:String>
<!--web search edit-->
<system:String x:Key="wox_plugin_websearch_title">标题</system:String>
<system:String x:Key="wox_plugin_websearch_enable">启用</system:String>
<system:String x:Key="wox_plugin_websearch_icon">图标</system:String>
<system:String x:Key="wox_plugin_websearch_select_icon">选择图标</system:String>
<system:String x:Key="wox_plugin_websearch_cancel">取消</system:String>
<system:String x:Key="wox_plugin_websearch_invalid_web_search">非法的网页搜索</system:String>
<system:String x:Key="wox_plugin_websearch_input_title">请输入标题</system:String>
<system:String x:Key="wox_plugin_websearch_input_action_keyword">请输入触发关键字</system:String>
<system:String x:Key="wox_plugin_websearch_input_url">请输入URL</system:String>
<system:String x:Key="wox_plugin_websearch_action_keyword_exist">触发关键字已经存在,请选择一个新的关键字</system:String>
<system:String x:Key="wox_plugin_websearch_succeed">操作成功</system:String>
<system:String x:Key="wox_plugin_websearch_plugin_name">网页搜索</system:String>
<system:String x:Key="wox_plugin_websearch_plugin_description">提供网页搜索能力</system:String>
</ResourceDictionary>

View File

@ -1,28 +1,31 @@
<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="wox_plugin_websearch_delete">刪除</system:String>
<system:String x:Key="wox_plugin_websearch_edit">編輯</system:String>
<system:String x:Key="wox_plugin_websearch_add">添加</system:String>
<system:String x:Key="wox_plugin_websearch_action_keyword">觸發關鍵字</system:String>
<system:String x:Key="wox_plugin_websearch_url">URL</system:String>
<system:String x:Key="wox_plugin_websearch_enable_suggestion">啟用搜索建議</system:String>
<system:String x:Key="wox_plugin_websearch_pls_select_web_search">請選擇一項</system:String>
<system:String x:Key="wox_plugin_websearch_delete_warning">你確定要刪除 {0} 嗎?</system:String>
<!--web search edit-->
<system:String x:Key="wox_plugin_websearch_title">標題</system:String>
<system:String x:Key="wox_plugin_websearch_enable">啟用</system:String>
<system:String x:Key="wox_plugin_websearch_icon">圖標</system:String>
<system:String x:Key="wox_plugin_websearch_select_icon">選擇圖標</system:String>
<system:String x:Key="wox_plugin_websearch_cancel">取消</system:String>
<system:String x:Key="wox_plugin_websearch_invalid_web_search">非法的網頁搜索</system:String>
<system:String x:Key="wox_plugin_websearch_input_title">請輸入標題</system:String>
<system:String x:Key="wox_plugin_websearch_input_action_keyword">請輸入觸發關鍵字</system:String>
<system:String x:Key="wox_plugin_websearch_input_url">請輸入URL</system:String>
<system:String x:Key="wox_plugin_websearch_action_keyword_exist">觸發關鍵字已經存在,請選擇一個新的關鍵字</system:String>
<system:String x:Key="wox_plugin_websearch_succeed">操作成功</system:String>
<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="wox_plugin_websearch_delete">刪除</system:String>
<system:String x:Key="wox_plugin_websearch_edit">編輯</system:String>
<system:String x:Key="wox_plugin_websearch_add">添加</system:String>
<system:String x:Key="wox_plugin_websearch_action_keyword">觸發關鍵字</system:String>
<system:String x:Key="wox_plugin_websearch_url">URL</system:String>
<system:String x:Key="wox_plugin_websearch_enable_suggestion">啟用搜索建議</system:String>
<system:String x:Key="wox_plugin_websearch_pls_select_web_search">請選擇一項</system:String>
<system:String x:Key="wox_plugin_websearch_delete_warning">你確定要刪除 {0} 嗎?</system:String>
<!--web search edit-->
<system:String x:Key="wox_plugin_websearch_title">標題</system:String>
<system:String x:Key="wox_plugin_websearch_enable">啟用</system:String>
<system:String x:Key="wox_plugin_websearch_icon">圖標</system:String>
<system:String x:Key="wox_plugin_websearch_select_icon">選擇圖標</system:String>
<system:String x:Key="wox_plugin_websearch_cancel">取消</system:String>
<system:String x:Key="wox_plugin_websearch_invalid_web_search">非法的網頁搜索</system:String>
<system:String x:Key="wox_plugin_websearch_input_title">請輸入標題</system:String>
<system:String x:Key="wox_plugin_websearch_input_action_keyword">請輸入觸發關鍵字</system:String>
<system:String x:Key="wox_plugin_websearch_input_url">請輸入URL</system:String>
<system:String x:Key="wox_plugin_websearch_action_keyword_exist">觸發關鍵字已經存在,請選擇一個新的關鍵字</system:String>
<system:String x:Key="wox_plugin_websearch_succeed">操作成功</system:String>
<system:String x:Key="wox_plugin_websearch_plugin_name">網頁搜索</system:String>
<system:String x:Key="wox_plugin_websearch_plugin_description">提供網頁搜索能力</system:String>
</ResourceDictionary>

View File

@ -103,6 +103,16 @@ namespace Wox.Plugin.WebSearch
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages");
}
public string GetTranslatedPluginTitle()
{
return context.API.GetTranslation("wox_plugin_websearch_plugin_name");
}
public string GetTranslatedPluginDescription()
{
return context.API.GetTranslation("wox_plugin_websearch_plugin_description");
}
public bool IsInstantQuery(string query)
{
var strings = query.Split(' ');

View File

@ -2,7 +2,7 @@
"ID":"565B73353DBF4806919830B9202EE3BF",
"ActionKeyword":"*",
"Name":"Web Searches",
"Description":"Provide the web search ability.",
"Description":"Provide the web search ability",
"Author":"qianlifeng",
"Version":"1.0.0",
"Language":"csharp",

View File

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Wox.Core.Plugin;
using Wox.Infrastructure.Logger;
using Wox.Plugin;
namespace Wox.Core
{
internal class AssemblyHelper
{
public static List<KeyValuePair<PluginPair, T>> LoadPluginInterfaces<T>() where T : class
{
List<PluginMetadata> CSharpPluginMetadatas = PluginManager.AllPlugins.Select(o => o.Metadata).Where(o => o.Language.ToUpper() == AllowedLanguage.CSharp.ToUpper()).ToList();
List<KeyValuePair<PluginPair, T>> plugins = new List<KeyValuePair<PluginPair, T>>();
foreach (PluginMetadata metadata in CSharpPluginMetadatas)
{
try
{
Assembly asm = Assembly.Load(AssemblyName.GetAssemblyName(metadata.ExecuteFilePath));
List<Type> types = asm.GetTypes().Where(o => o.IsClass && !o.IsAbstract && o.GetInterfaces().Contains(typeof(T))).ToList();
if (types.Count == 0)
{
continue;
}
foreach (Type type in types)
{
plugins.Add(new KeyValuePair<PluginPair, T>(PluginManager.AllPlugins.First(o => o.Metadata.ID == metadata.ID),
Activator.CreateInstance(type) as T));
}
}
catch (System.Exception e)
{
Log.Error(string.Format("Couldn't load plugin {0}: {1}", metadata.Name, e.Message));
#if (DEBUG)
{
throw;
}
#endif
}
}
return plugins;
}
public static List<T> LoadInterfacesFromAppDomain<T>() where T : class
{
var interfaceObjects = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(s => s.GetTypes())
.Where(p => p.IsClass && !p.IsAbstract && p.GetInterfaces().Contains(typeof(T)));
return interfaceObjects.Select(interfaceObject => (T) Activator.CreateInstance(interfaceObject)).ToList();
}
}
}

View File

@ -6,6 +6,7 @@ using System.Linq;
using System.Reflection;
using System.Threading;
using Wox.Core.Exception;
using Wox.Core.i18n;
using Wox.Core.UI;
using Wox.Core.UserSettings;
using Wox.Infrastructure;
@ -23,7 +24,7 @@ namespace Wox.Core.Plugin
{
public const string ActionKeywordWildcardSign = "*";
private static List<PluginMetadata> pluginMetadatas;
private static List<KeyValuePair<PluginMetadata, IInstantQuery>> instantSearches;
private static List<KeyValuePair<PluginPair, IInstantQuery>> instantSearches;
private static List<KeyValuePair<PluginPair, IExclusiveQuery>> exclusiveSearchPlugins;
public static String DebuggerMode { get; private set; }
@ -99,6 +100,7 @@ namespace Wox.Core.Plugin
sw.Stop();
DebugHelper.WriteLine(string.Format("Plugin init:{0} - {1}", pair.Metadata.Name, sw.ElapsedMilliseconds));
pair.InitTime = sw.ElapsedMilliseconds;
InternationalizationManager.Instance.UpdatePluginMetadataTranslations(pair);
});
}
@ -178,7 +180,7 @@ namespace Wox.Core.Plugin
{
//todo:to improve performance, any instant search plugin that takes long than 200ms will not consider a instant plugin anymore
return pluginMetadata.Language.ToUpper() == AllowedLanguage.CSharp &&
LoadInstantSearches().Any(o => o.Key.ID == pluginMetadata.ID);
LoadInstantSearches().Any(o => o.Key.Metadata.ID == pluginMetadata.ID);
}
internal static void ExecutePluginQuery(PluginPair pair, Query query)
@ -211,39 +213,11 @@ namespace Wox.Core.Plugin
}
}
private static List<KeyValuePair<PluginMetadata, IInstantQuery>> LoadInstantSearches()
private static List<KeyValuePair<PluginPair, IInstantQuery>> LoadInstantSearches()
{
if (instantSearches != null) return instantSearches;
instantSearches = new List<KeyValuePair<PluginMetadata, IInstantQuery>>();
List<PluginMetadata> CSharpPluginMetadatas = pluginMetadatas.Where(o => o.Language.ToUpper() == AllowedLanguage.CSharp.ToUpper()).ToList();
foreach (PluginMetadata metadata in CSharpPluginMetadatas)
{
try
{
Assembly asm = Assembly.Load(AssemblyName.GetAssemblyName(metadata.ExecuteFilePath));
List<Type> types = asm.GetTypes().Where(o => o.IsClass && !o.IsAbstract && o.GetInterfaces().Contains(typeof(IInstantQuery))).ToList();
if (types.Count == 0)
{
continue;
}
foreach (Type type in types)
{
instantSearches.Add(new KeyValuePair<PluginMetadata, IInstantQuery>(metadata, Activator.CreateInstance(type) as IInstantQuery));
}
}
catch (System.Exception e)
{
Log.Error(string.Format("Couldn't load plugin {0}: {1}", metadata.Name, e.Message));
#if (DEBUG)
{
throw;
}
#endif
}
}
instantSearches = AssemblyHelper.LoadPluginInterfaces<IInstantQuery>();
return instantSearches;
}
@ -261,38 +235,7 @@ namespace Wox.Core.Plugin
internal static List<KeyValuePair<PluginPair, IExclusiveQuery>> LoadExclusiveSearchPlugins()
{
if (exclusiveSearchPlugins != null) return exclusiveSearchPlugins;
exclusiveSearchPlugins = new List<KeyValuePair<PluginPair, IExclusiveQuery>>();
List<PluginMetadata> CSharpPluginMetadatas = pluginMetadatas.Where(o => o.Language.ToUpper() == AllowedLanguage.CSharp.ToUpper()).ToList();
foreach (PluginMetadata metadata in CSharpPluginMetadatas)
{
try
{
Assembly asm = Assembly.Load(AssemblyName.GetAssemblyName(metadata.ExecuteFilePath));
List<Type> types = asm.GetTypes().Where(o => o.IsClass && !o.IsAbstract && o.GetInterfaces().Contains(typeof(IExclusiveQuery))).ToList();
if (types.Count == 0)
{
continue;
}
foreach (Type type in types)
{
exclusiveSearchPlugins.Add(new KeyValuePair<PluginPair, IExclusiveQuery>(AllPlugins.First(o => o.Metadata.ID == metadata.ID),
Activator.CreateInstance(type) as IExclusiveQuery));
}
}
catch (System.Exception e)
{
Log.Error(string.Format("Couldn't load plugin {0}: {1}", metadata.Name, e.Message));
#if (DEBUG)
{
throw;
}
#endif
}
}
exclusiveSearchPlugins = AssemblyHelper.LoadPluginInterfaces<IExclusiveQuery>();
return exclusiveSearchPlugins;
}

View File

@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using Wox.Core.i18n;
using Wox.Core.Plugin;
using Wox.Core.Theme;
using Wox.Plugin;
@ -9,38 +11,28 @@ namespace Wox.Core.UI
{
public class ResourceMerger
{
public static void ApplyResources()
internal static void ApplyResources()
{
Application.Current.Resources.MergedDictionaries.Clear();
ApplyPluginLanguages();
ApplyThemeAndLanguageResources();
}
private static void ApplyThemeAndLanguageResources()
internal static void ApplyThemeAndLanguageResources()
{
var UIResourceType = typeof(IUIResource);
var UIResources = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(s => s.GetTypes())
.Where(p => p.IsClass && !p.IsAbstract && UIResourceType.IsAssignableFrom(p));
var UIResources = AssemblyHelper.LoadInterfacesFromAppDomain<IUIResource>();
foreach (var uiResource in UIResources)
{
Application.Current.Resources.MergedDictionaries.Add(
((IUIResource)Activator.CreateInstance(uiResource)).GetResourceDictionary());
Application.Current.Resources.MergedDictionaries.Add(uiResource.GetResourceDictionary());
}
}
public static void ApplyPluginLanguages()
internal static void ApplyPluginLanguages()
{
var pluginI18nType = typeof(IPluginI18n);
var pluginI18ns = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(s => s.GetTypes())
.Where(p => p.IsClass && !p.IsAbstract && pluginI18nType.IsAssignableFrom(p));
var pluginI18ns = AssemblyHelper.LoadInterfacesFromAppDomain<IPluginI18n>();
foreach (var pluginI18n in pluginI18ns)
{
string languageFile = InternationalizationManager.Instance.GetLanguageFile(
((IPluginI18n)Activator.CreateInstance(pluginI18n)).GetLanguagesFolder());
string languageFile = InternationalizationManager.Instance.GetLanguageFile(pluginI18n.GetLanguagesFolder());
if (!string.IsNullOrEmpty(languageFile))
{
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary
@ -50,5 +42,7 @@ namespace Wox.Core.UI
}
}
}
}
}

View File

@ -69,6 +69,7 @@
<Compile Include="Exception\WoxI18nException.cs" />
<Compile Include="Exception\WoxJsonRPCException.cs" />
<Compile Include="Exception\WoxPluginException.cs" />
<Compile Include="AssemblyHelper.cs" />
<Compile Include="Plugin\QueryDispatcher\BaseQueryDispatcher.cs" />
<Compile Include="Updater\Release.cs" />
<Compile Include="Updater\UpdaterManager.cs" />

View File

@ -9,6 +9,7 @@ using Wox.Core.Exception;
using Wox.Core.UI;
using Wox.Core.UserSettings;
using Wox.Infrastructure.Logger;
using Wox.Plugin;
namespace Wox.Core.i18n
{
@ -40,6 +41,7 @@ namespace Wox.Core.i18n
{
Language language = GetLanguageByLanguageCode(languageCode);
ChangeLanguage(language);
UpdateAllPluginMetadataTranslations();
}
private Language GetLanguageByLanguageCode(string languageCode)
@ -109,6 +111,36 @@ namespace Wox.Core.i18n
return GetLanguagePath(language);
}
internal void UpdateAllPluginMetadataTranslations()
{
List<KeyValuePair<PluginPair, IPluginI18n>> plugins = AssemblyHelper.LoadPluginInterfaces<IPluginI18n>();
foreach (var plugin in plugins)
{
UpdatePluginMetadataTranslations(plugin.Key);
}
}
internal void UpdatePluginMetadataTranslations(PluginPair pluginPair)
{
var pluginI18n = pluginPair.Plugin as IPluginI18n;
if (pluginI18n == null) return;
try
{
pluginPair.Metadata.Name = pluginI18n.GetTranslatedPluginTitle();
pluginPair.Metadata.Description = pluginI18n.GetTranslatedPluginDescription();
}
catch (System.Exception e)
{
Log.Warn("Update Plugin metadata translation failed:" + e.Message);
#if (DEBUG)
{
throw;
}
#endif
}
}
private string GetLanguagePath(Language language)
{
string path = Path.Combine(DefaultLanguageDirectory, language.LanguageCode + ".xaml");

View File

@ -12,5 +12,9 @@ namespace Wox.Plugin
public interface IPluginI18n
{
string GetLanguagesFolder();
string GetTranslatedPluginTitle();
string GetTranslatedPluginDescription();
}
}
}

View File

@ -831,7 +831,7 @@ namespace Wox
PluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
Action = _ =>
{
TopMostRecordStorage.Instance.Add(result);
TopMostRecordStorage.Instance.AddOrUpdate(result);
ShowMsg("Succeed", "", "");
return false;
}

View File

@ -26,7 +26,8 @@ namespace Wox.Storage
{
return records.Any(o => o.Value.Title == result.Title
&& o.Value.SubTitle == result.SubTitle
&& o.Value.PluginID == result.PluginID);
&& o.Value.PluginID == result.PluginID
&& o.Key == result.OriginQuery.RawQuery);
}
internal void Remove(Plugin.Result result)
@ -38,7 +39,7 @@ namespace Wox.Storage
}
}
internal void Add(Plugin.Result result)
internal void AddOrUpdate(Plugin.Result result)
{
if (records.ContainsKey(result.OriginQuery.RawQuery))
{