mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-21 16:33:05 +08:00
Add plugin title translations
This commit is contained in:
parent
82d30c6e74
commit
437c1a154c
@ -213,6 +213,16 @@ namespace Wox.Plugin.CMD
|
|||||||
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages");
|
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)
|
public bool IsInstantQuery(string query)
|
||||||
{
|
{
|
||||||
if (query.StartsWith(">")) return true;
|
if (query.StartsWith(">")) return true;
|
||||||
|
@ -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_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_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>
|
</ResourceDictionary>
|
@ -4,5 +4,7 @@
|
|||||||
|
|
||||||
<system:String x:Key="wox_plugin_cmd_relace_winr">替换 Win+R</system:String>
|
<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_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>
|
</ResourceDictionary>
|
@ -4,5 +4,7 @@
|
|||||||
|
|
||||||
<system:String x:Key="wox_plugin_cmd_relace_winr">替換 Win+R</system:String>
|
<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_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>
|
</ResourceDictionary>
|
@ -8,4 +8,7 @@
|
|||||||
<system:String x:Key="wox_plugin_everything_canot_start">Can't start {0}</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_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>
|
</ResourceDictionary>
|
@ -8,4 +8,7 @@
|
|||||||
<system:String x:Key="wox_plugin_everything_canot_start">不能启动 {0}</system:String>
|
<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_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>
|
</ResourceDictionary>
|
@ -8,4 +8,6 @@
|
|||||||
<system:String x:Key="wox_plugin_everything_canot_start">不能啟動 {0}</system:String>
|
<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_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>
|
</ResourceDictionary>
|
@ -211,5 +211,15 @@ namespace Wox.Plugin.Everything
|
|||||||
{
|
{
|
||||||
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages");
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
|
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="PresentationCore" />
|
<Reference Include="PresentationCore" />
|
||||||
|
<Reference Include="PresentationFramework" />
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
@ -220,5 +220,15 @@ namespace Wox.Plugin.Folder
|
|||||||
{
|
{
|
||||||
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages");
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,4 +9,7 @@
|
|||||||
<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_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_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>
|
</ResourceDictionary>
|
@ -9,4 +9,7 @@
|
|||||||
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">请选择一个文件夹</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_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>
|
</ResourceDictionary>
|
@ -9,4 +9,7 @@
|
|||||||
<system:String x:Key="wox_plugin_folder_select_folder_link_warning">請選擇一個文件夾</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_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>
|
</ResourceDictionary>
|
@ -2,7 +2,7 @@
|
|||||||
"ID":"B4D3B69656E14D44865C8D818EAE47C4",
|
"ID":"B4D3B69656E14D44865C8D818EAE47C4",
|
||||||
"ActionKeyword":"*",
|
"ActionKeyword":"*",
|
||||||
"Name":"Folder",
|
"Name":"Folder",
|
||||||
"Description":"Provide opening folder from wox directorily. You can add your favorite folders.",
|
"Description":"Open favorite folder from wox directorily",
|
||||||
"Author":"qianlifeng",
|
"Author":"qianlifeng",
|
||||||
"Version":"1.0.0",
|
"Version":"1.0.0",
|
||||||
"Language":"csharp",
|
"Language":"csharp",
|
||||||
|
@ -23,4 +23,7 @@
|
|||||||
<system:String x:Key="wox_plugin_program_run_as_administrator">Run As Administrator</system:String>
|
<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_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>
|
</ResourceDictionary>
|
@ -24,4 +24,7 @@
|
|||||||
<system:String x:Key="wox_plugin_program_run_as_administrator">以管理员身份运行</system:String>
|
<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_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>
|
</ResourceDictionary>
|
@ -23,4 +23,7 @@
|
|||||||
|
|
||||||
<system:String x:Key="wox_plugin_program_run_as_administrator">以管理員身份運行</system:String>
|
<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_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>
|
</ResourceDictionary>
|
@ -223,5 +223,14 @@ namespace Wox.Plugin.Program
|
|||||||
{
|
{
|
||||||
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages");
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"ID":"791FC278BA414111B8D1886DFE447410",
|
"ID":"791FC278BA414111B8D1886DFE447410",
|
||||||
"ActionKeyword":"*",
|
"ActionKeyword":"*",
|
||||||
"Name":"Program",
|
"Name":"Program",
|
||||||
"Description":"Provide programs search for Wox.",
|
"Description":"Search programs in Wox",
|
||||||
"Author":"qianlifeng",
|
"Author":"qianlifeng",
|
||||||
"Version":"1.0.0",
|
"Version":"1.0.0",
|
||||||
"Language":"csharp",
|
"Language":"csharp",
|
||||||
|
@ -12,4 +12,7 @@
|
|||||||
<system:String x:Key="wox_plugin_sys_restart">Restart 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_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>
|
</ResourceDictionary>
|
@ -12,4 +12,7 @@
|
|||||||
<system:String x:Key="wox_plugin_sys_restart">重启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_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>
|
</ResourceDictionary>
|
@ -12,4 +12,7 @@
|
|||||||
<system:String x:Key="wox_plugin_sys_restart">重啟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_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>
|
</ResourceDictionary>
|
@ -4,6 +4,7 @@ using System.IO;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using Wox.Infrastructure;
|
||||||
|
|
||||||
namespace Wox.Plugin.Sys
|
namespace Wox.Plugin.Sys
|
||||||
{
|
{
|
||||||
@ -42,7 +43,7 @@ namespace Wox.Plugin.Sys
|
|||||||
List<Result> results = new List<Result>();
|
List<Result> results = new List<Result>();
|
||||||
foreach (Result availableResult in availableResults)
|
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);
|
results.Add(availableResult);
|
||||||
}
|
}
|
||||||
@ -142,5 +143,15 @@ namespace Wox.Plugin.Sys
|
|||||||
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages");
|
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 |
11
Plugins/Wox.Plugin.Url/Languages/en.xaml
Normal file
11
Plugins/Wox.Plugin.Url/Languages/en.xaml
Normal 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>
|
11
Plugins/Wox.Plugin.Url/Languages/zh-cn.xaml
Normal file
11
Plugins/Wox.Plugin.Url/Languages/zh-cn.xaml
Normal 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>
|
11
Plugins/Wox.Plugin.Url/Languages/zh-tw.xaml
Normal file
11
Plugins/Wox.Plugin.Url/Languages/zh-tw.xaml
Normal 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>
|
@ -1,15 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace Wox.Plugin.Url
|
namespace Wox.Plugin.Url
|
||||||
{
|
{
|
||||||
public class UrlPlugin : IPlugin
|
public class UrlPlugin : IPlugin, IPluginI18n
|
||||||
{
|
{
|
||||||
//based on https://gist.github.com/dperini/729294
|
//based on https://gist.github.com/dperini/729294
|
||||||
private const string urlPattern ="^" +
|
private const string urlPattern = "^" +
|
||||||
// protocol identifier
|
// protocol identifier
|
||||||
"(?:(?:https?|ftp)://|)" +
|
"(?:(?:https?|ftp)://|)" +
|
||||||
// user:pass authentication
|
// user:pass authentication
|
||||||
@ -42,6 +44,7 @@ namespace Wox.Plugin.Url
|
|||||||
"(?:/\\S*)?" +
|
"(?:/\\S*)?" +
|
||||||
"$";
|
"$";
|
||||||
Regex reg = new Regex(urlPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
Regex reg = new Regex(urlPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
|
private PluginInitContext context;
|
||||||
|
|
||||||
public List<Result> Query(Query query)
|
public List<Result> Query(Query query)
|
||||||
{
|
{
|
||||||
@ -53,7 +56,7 @@ namespace Wox.Plugin.Url
|
|||||||
new Result
|
new Result
|
||||||
{
|
{
|
||||||
Title = raw,
|
Title = raw,
|
||||||
SubTitle = "Open " + raw,
|
SubTitle = string.Format(context.API.GetTranslation("wox_plugin_url_open_url"),raw),
|
||||||
IcoPath = "Images/url.png",
|
IcoPath = "Images/url.png",
|
||||||
Score = 8,
|
Score = 8,
|
||||||
Action = _ =>
|
Action = _ =>
|
||||||
@ -69,7 +72,7 @@ namespace Wox.Plugin.Url
|
|||||||
}
|
}
|
||||||
catch(Exception ex)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,7 +101,22 @@ namespace Wox.Plugin.Url
|
|||||||
|
|
||||||
public void Init(PluginInitContext context)
|
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -64,6 +64,27 @@
|
|||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</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" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- 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.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"ID":"0308FD86DE0A4DEE8D62B9B535370992",
|
"ID":"0308FD86DE0A4DEE8D62B9B535370992",
|
||||||
"ActionKeyword":"*",
|
"ActionKeyword":"*",
|
||||||
"Name":"URL handler",
|
"Name":"URL",
|
||||||
"Description":"Provide Opening the typed URL from Wox.",
|
"Description":"Open the typed URL from Wox",
|
||||||
"Author":"qianlifeng",
|
"Author":"qianlifeng",
|
||||||
"Version":"1.0.0",
|
"Version":"1.0.0",
|
||||||
"Language":"csharp",
|
"Language":"csharp",
|
||||||
|
@ -25,4 +25,7 @@
|
|||||||
<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_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_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>
|
</ResourceDictionary>
|
@ -25,4 +25,7 @@
|
|||||||
<system:String x:Key="wox_plugin_websearch_action_keyword_exist">触发关键字已经存在,请选择一个新的关键字</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_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>
|
</ResourceDictionary>
|
@ -25,4 +25,7 @@
|
|||||||
<system:String x:Key="wox_plugin_websearch_action_keyword_exist">觸發關鍵字已經存在,請選擇一個新的關鍵字</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_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>
|
</ResourceDictionary>
|
@ -103,6 +103,16 @@ namespace Wox.Plugin.WebSearch
|
|||||||
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages");
|
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)
|
public bool IsInstantQuery(string query)
|
||||||
{
|
{
|
||||||
var strings = query.Split(' ');
|
var strings = query.Split(' ');
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"ID":"565B73353DBF4806919830B9202EE3BF",
|
"ID":"565B73353DBF4806919830B9202EE3BF",
|
||||||
"ActionKeyword":"*",
|
"ActionKeyword":"*",
|
||||||
"Name":"Web Searches",
|
"Name":"Web Searches",
|
||||||
"Description":"Provide the web search ability.",
|
"Description":"Provide the web search ability",
|
||||||
"Author":"qianlifeng",
|
"Author":"qianlifeng",
|
||||||
"Version":"1.0.0",
|
"Version":"1.0.0",
|
||||||
"Language":"csharp",
|
"Language":"csharp",
|
||||||
|
57
Wox.Core/AssemblyHelper.cs
Normal file
57
Wox.Core/AssemblyHelper.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Wox.Core.Exception;
|
using Wox.Core.Exception;
|
||||||
|
using Wox.Core.i18n;
|
||||||
using Wox.Core.UI;
|
using Wox.Core.UI;
|
||||||
using Wox.Core.UserSettings;
|
using Wox.Core.UserSettings;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
@ -23,7 +24,7 @@ namespace Wox.Core.Plugin
|
|||||||
{
|
{
|
||||||
public const string ActionKeywordWildcardSign = "*";
|
public const string ActionKeywordWildcardSign = "*";
|
||||||
private static List<PluginMetadata> pluginMetadatas;
|
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;
|
private static List<KeyValuePair<PluginPair, IExclusiveQuery>> exclusiveSearchPlugins;
|
||||||
|
|
||||||
public static String DebuggerMode { get; private set; }
|
public static String DebuggerMode { get; private set; }
|
||||||
@ -99,6 +100,7 @@ namespace Wox.Core.Plugin
|
|||||||
sw.Stop();
|
sw.Stop();
|
||||||
DebugHelper.WriteLine(string.Format("Plugin init:{0} - {1}", pair.Metadata.Name, sw.ElapsedMilliseconds));
|
DebugHelper.WriteLine(string.Format("Plugin init:{0} - {1}", pair.Metadata.Name, sw.ElapsedMilliseconds));
|
||||||
pair.InitTime = 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
|
//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 &&
|
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)
|
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;
|
if (instantSearches != null) return instantSearches;
|
||||||
|
|
||||||
instantSearches = new List<KeyValuePair<PluginMetadata, IInstantQuery>>();
|
instantSearches = AssemblyHelper.LoadPluginInterfaces<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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return instantSearches;
|
return instantSearches;
|
||||||
}
|
}
|
||||||
@ -261,38 +235,7 @@ namespace Wox.Core.Plugin
|
|||||||
internal static List<KeyValuePair<PluginPair, IExclusiveQuery>> LoadExclusiveSearchPlugins()
|
internal static List<KeyValuePair<PluginPair, IExclusiveQuery>> LoadExclusiveSearchPlugins()
|
||||||
{
|
{
|
||||||
if (exclusiveSearchPlugins != null) return exclusiveSearchPlugins;
|
if (exclusiveSearchPlugins != null) return exclusiveSearchPlugins;
|
||||||
|
exclusiveSearchPlugins = AssemblyHelper.LoadPluginInterfaces<IExclusiveQuery>();
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return exclusiveSearchPlugins;
|
return exclusiveSearchPlugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Wox.Core.i18n;
|
using Wox.Core.i18n;
|
||||||
|
using Wox.Core.Plugin;
|
||||||
using Wox.Core.Theme;
|
using Wox.Core.Theme;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
|
|
||||||
@ -9,38 +11,28 @@ namespace Wox.Core.UI
|
|||||||
{
|
{
|
||||||
public class ResourceMerger
|
public class ResourceMerger
|
||||||
{
|
{
|
||||||
public static void ApplyResources()
|
internal static void ApplyResources()
|
||||||
{
|
{
|
||||||
Application.Current.Resources.MergedDictionaries.Clear();
|
Application.Current.Resources.MergedDictionaries.Clear();
|
||||||
ApplyPluginLanguages();
|
ApplyPluginLanguages();
|
||||||
ApplyThemeAndLanguageResources();
|
ApplyThemeAndLanguageResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ApplyThemeAndLanguageResources()
|
internal static void ApplyThemeAndLanguageResources()
|
||||||
{
|
{
|
||||||
var UIResourceType = typeof(IUIResource);
|
var UIResources = AssemblyHelper.LoadInterfacesFromAppDomain<IUIResource>();
|
||||||
var UIResources = AppDomain.CurrentDomain.GetAssemblies()
|
|
||||||
.SelectMany(s => s.GetTypes())
|
|
||||||
.Where(p => p.IsClass && !p.IsAbstract && UIResourceType.IsAssignableFrom(p));
|
|
||||||
|
|
||||||
foreach (var uiResource in UIResources)
|
foreach (var uiResource in UIResources)
|
||||||
{
|
{
|
||||||
Application.Current.Resources.MergedDictionaries.Add(
|
Application.Current.Resources.MergedDictionaries.Add(uiResource.GetResourceDictionary());
|
||||||
((IUIResource)Activator.CreateInstance(uiResource)).GetResourceDictionary());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ApplyPluginLanguages()
|
internal static void ApplyPluginLanguages()
|
||||||
{
|
{
|
||||||
var pluginI18nType = typeof(IPluginI18n);
|
var pluginI18ns = AssemblyHelper.LoadInterfacesFromAppDomain<IPluginI18n>();
|
||||||
var pluginI18ns = AppDomain.CurrentDomain.GetAssemblies()
|
|
||||||
.SelectMany(s => s.GetTypes())
|
|
||||||
.Where(p => p.IsClass && !p.IsAbstract && pluginI18nType.IsAssignableFrom(p));
|
|
||||||
|
|
||||||
foreach (var pluginI18n in pluginI18ns)
|
foreach (var pluginI18n in pluginI18ns)
|
||||||
{
|
{
|
||||||
string languageFile = InternationalizationManager.Instance.GetLanguageFile(
|
string languageFile = InternationalizationManager.Instance.GetLanguageFile(pluginI18n.GetLanguagesFolder());
|
||||||
((IPluginI18n)Activator.CreateInstance(pluginI18n)).GetLanguagesFolder());
|
|
||||||
if (!string.IsNullOrEmpty(languageFile))
|
if (!string.IsNullOrEmpty(languageFile))
|
||||||
{
|
{
|
||||||
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary
|
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary
|
||||||
@ -50,5 +42,7 @@ namespace Wox.Core.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -69,6 +69,7 @@
|
|||||||
<Compile Include="Exception\WoxI18nException.cs" />
|
<Compile Include="Exception\WoxI18nException.cs" />
|
||||||
<Compile Include="Exception\WoxJsonRPCException.cs" />
|
<Compile Include="Exception\WoxJsonRPCException.cs" />
|
||||||
<Compile Include="Exception\WoxPluginException.cs" />
|
<Compile Include="Exception\WoxPluginException.cs" />
|
||||||
|
<Compile Include="AssemblyHelper.cs" />
|
||||||
<Compile Include="Plugin\QueryDispatcher\BaseQueryDispatcher.cs" />
|
<Compile Include="Plugin\QueryDispatcher\BaseQueryDispatcher.cs" />
|
||||||
<Compile Include="Updater\Release.cs" />
|
<Compile Include="Updater\Release.cs" />
|
||||||
<Compile Include="Updater\UpdaterManager.cs" />
|
<Compile Include="Updater\UpdaterManager.cs" />
|
||||||
|
@ -9,6 +9,7 @@ using Wox.Core.Exception;
|
|||||||
using Wox.Core.UI;
|
using Wox.Core.UI;
|
||||||
using Wox.Core.UserSettings;
|
using Wox.Core.UserSettings;
|
||||||
using Wox.Infrastructure.Logger;
|
using Wox.Infrastructure.Logger;
|
||||||
|
using Wox.Plugin;
|
||||||
|
|
||||||
namespace Wox.Core.i18n
|
namespace Wox.Core.i18n
|
||||||
{
|
{
|
||||||
@ -40,6 +41,7 @@ namespace Wox.Core.i18n
|
|||||||
{
|
{
|
||||||
Language language = GetLanguageByLanguageCode(languageCode);
|
Language language = GetLanguageByLanguageCode(languageCode);
|
||||||
ChangeLanguage(language);
|
ChangeLanguage(language);
|
||||||
|
UpdateAllPluginMetadataTranslations();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Language GetLanguageByLanguageCode(string languageCode)
|
private Language GetLanguageByLanguageCode(string languageCode)
|
||||||
@ -109,6 +111,36 @@ namespace Wox.Core.i18n
|
|||||||
return GetLanguagePath(language);
|
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)
|
private string GetLanguagePath(Language language)
|
||||||
{
|
{
|
||||||
string path = Path.Combine(DefaultLanguageDirectory, language.LanguageCode + ".xaml");
|
string path = Path.Combine(DefaultLanguageDirectory, language.LanguageCode + ".xaml");
|
||||||
|
@ -12,5 +12,9 @@ namespace Wox.Plugin
|
|||||||
public interface IPluginI18n
|
public interface IPluginI18n
|
||||||
{
|
{
|
||||||
string GetLanguagesFolder();
|
string GetLanguagesFolder();
|
||||||
|
|
||||||
|
string GetTranslatedPluginTitle();
|
||||||
|
|
||||||
|
string GetTranslatedPluginDescription();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -831,7 +831,7 @@ namespace Wox
|
|||||||
PluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
|
PluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
|
||||||
Action = _ =>
|
Action = _ =>
|
||||||
{
|
{
|
||||||
TopMostRecordStorage.Instance.Add(result);
|
TopMostRecordStorage.Instance.AddOrUpdate(result);
|
||||||
ShowMsg("Succeed", "", "");
|
ShowMsg("Succeed", "", "");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,8 @@ namespace Wox.Storage
|
|||||||
{
|
{
|
||||||
return records.Any(o => o.Value.Title == result.Title
|
return records.Any(o => o.Value.Title == result.Title
|
||||||
&& o.Value.SubTitle == result.SubTitle
|
&& 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)
|
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))
|
if (records.ContainsKey(result.OriginQuery.RawQuery))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user