From 437c1a154caa857fd12f1d7cccdd3ffa5db2fd5b Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Sat, 7 Feb 2015 20:17:49 +0800 Subject: [PATCH] Add plugin title translations --- Plugins/Wox.Plugin.CMD/CMD.cs | 10 +++ Plugins/Wox.Plugin.CMD/Languages/en.xaml | 2 + Plugins/Wox.Plugin.CMD/Languages/zh-cn.xaml | 16 ++-- Plugins/Wox.Plugin.CMD/Languages/zh-tw.xaml | 16 ++-- .../Wox.Plugin.Everything/Languages/en.xaml | 3 + .../Languages/zh-cn.xaml | 3 + .../Languages/zh-tw.xaml | 2 + Plugins/Wox.Plugin.Everything/Main.cs | 10 +++ .../Wox.Plugin.Everything.csproj | 1 + Plugins/Wox.Plugin.Folder/FolderPlugin.cs | 10 +++ Plugins/Wox.Plugin.Folder/Languages/en.xaml | 5 +- .../Wox.Plugin.Folder/Languages/zh-cn.xaml | 25 +++--- .../Wox.Plugin.Folder/Languages/zh-tw.xaml | 25 +++--- Plugins/Wox.Plugin.Folder/plugin.json | 2 +- Plugins/Wox.Plugin.Program/Languages/en.xaml | 5 +- .../Wox.Plugin.Program/Languages/zh-cn.xaml | 3 + .../Wox.Plugin.Program/Languages/zh-tw.xaml | 3 + Plugins/Wox.Plugin.Program/Programs.cs | 9 +++ Plugins/Wox.Plugin.Program/plugin.json | 2 +- Plugins/Wox.Plugin.Sys/Languages/en.xaml | 5 +- Plugins/Wox.Plugin.Sys/Languages/zh-cn.xaml | 31 ++++---- Plugins/Wox.Plugin.Sys/Languages/zh-tw.xaml | 31 ++++---- Plugins/Wox.Plugin.Sys/Sys.cs | 15 +++- Plugins/Wox.Plugin.Url/Images/url.png | Bin 3174 -> 3831 bytes Plugins/Wox.Plugin.Url/Languages/en.xaml | 11 +++ Plugins/Wox.Plugin.Url/Languages/zh-cn.xaml | 11 +++ Plugins/Wox.Plugin.Url/Languages/zh-tw.xaml | 11 +++ Plugins/Wox.Plugin.Url/UrlPlugin.cs | 26 ++++++- Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj | 21 ++++++ Plugins/Wox.Plugin.Url/plugin.json | 4 +- .../Wox.Plugin.WebSearch/Languages/en.xaml | 5 +- .../Wox.Plugin.WebSearch/Languages/zh-cn.xaml | 57 +++++++------- .../Wox.Plugin.WebSearch/Languages/zh-tw.xaml | 57 +++++++------- .../Wox.Plugin.WebSearch/WebQueryPlugin.cs | 10 +++ Plugins/Wox.Plugin.WebSearch/plugin.json | 2 +- Wox.Core/AssemblyHelper.cs | 57 ++++++++++++++ Wox.Core/Plugin/PluginManager.cs | 71 ++---------------- Wox.Core/UI/ResourceMerger.cs | 28 +++---- Wox.Core/Wox.Core.csproj | 1 + Wox.Core/i18n/Internationalization.cs | 32 ++++++++ Wox.Plugin/IPluginI18n.cs | 6 +- Wox/MainWindow.xaml.cs | 2 +- Wox/Storage/TopMostRecordStorage.cs | 5 +- 43 files changed, 433 insertions(+), 218 deletions(-) create mode 100644 Plugins/Wox.Plugin.Url/Languages/en.xaml create mode 100644 Plugins/Wox.Plugin.Url/Languages/zh-cn.xaml create mode 100644 Plugins/Wox.Plugin.Url/Languages/zh-tw.xaml create mode 100644 Wox.Core/AssemblyHelper.cs diff --git a/Plugins/Wox.Plugin.CMD/CMD.cs b/Plugins/Wox.Plugin.CMD/CMD.cs index da5877c67f..f2ed269ee7 100644 --- a/Plugins/Wox.Plugin.CMD/CMD.cs +++ b/Plugins/Wox.Plugin.CMD/CMD.cs @@ -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; diff --git a/Plugins/Wox.Plugin.CMD/Languages/en.xaml b/Plugins/Wox.Plugin.CMD/Languages/en.xaml index 309a4867db..a37ee02a93 100644 --- a/Plugins/Wox.Plugin.CMD/Languages/en.xaml +++ b/Plugins/Wox.Plugin.CMD/Languages/en.xaml @@ -4,5 +4,7 @@ Replace Win+R Do not close Command Prompt after command execution + Shell + Provide executing commands from Wox. Commands should start with > \ No newline at end of file diff --git a/Plugins/Wox.Plugin.CMD/Languages/zh-cn.xaml b/Plugins/Wox.Plugin.CMD/Languages/zh-cn.xaml index 0847dda6ce..9693f5f3cc 100644 --- a/Plugins/Wox.Plugin.CMD/Languages/zh-cn.xaml +++ b/Plugins/Wox.Plugin.CMD/Languages/zh-cn.xaml @@ -1,8 +1,10 @@ - - - 替换 Win+R - 执行后不关闭命令窗口 - + + + 替换 Win+R + 执行后不关闭命令窗口 + 命令行 + 提供从Wox中执行命令行的能力,命令应该以>开头 + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.CMD/Languages/zh-tw.xaml b/Plugins/Wox.Plugin.CMD/Languages/zh-tw.xaml index 8ac28c3639..7d318ff0bc 100644 --- a/Plugins/Wox.Plugin.CMD/Languages/zh-tw.xaml +++ b/Plugins/Wox.Plugin.CMD/Languages/zh-tw.xaml @@ -1,8 +1,10 @@ - - - 替換 Win+R - 執行後不關閉命令窗口 - + + + 替換 Win+R + 執行後不關閉命令窗口 + 命令行 + 提供從Wox中執行命令行的能力,命令應該以>開頭 + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Everything/Languages/en.xaml b/Plugins/Wox.Plugin.Everything/Languages/en.xaml index 18c583ae0e..abb592bb7f 100644 --- a/Plugins/Wox.Plugin.Everything/Languages/en.xaml +++ b/Plugins/Wox.Plugin.Everything/Languages/en.xaml @@ -7,5 +7,8 @@ Copied Can't start {0} Open containing folder + + Everything + Search disk files using Everything \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Everything/Languages/zh-cn.xaml b/Plugins/Wox.Plugin.Everything/Languages/zh-cn.xaml index 50d3f189c1..d9f3dd7092 100644 --- a/Plugins/Wox.Plugin.Everything/Languages/zh-cn.xaml +++ b/Plugins/Wox.Plugin.Everything/Languages/zh-cn.xaml @@ -8,4 +8,7 @@ 不能启动 {0} 打开所属文件夹 + Everything + 利用Everything搜索磁盘文件 + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Everything/Languages/zh-tw.xaml b/Plugins/Wox.Plugin.Everything/Languages/zh-tw.xaml index c61e4ffec7..46aac0db99 100644 --- a/Plugins/Wox.Plugin.Everything/Languages/zh-tw.xaml +++ b/Plugins/Wox.Plugin.Everything/Languages/zh-tw.xaml @@ -8,4 +8,6 @@ 不能啟動 {0} 打開所屬文件夾 + Everything + 利用Everything搜索磁盤文件 \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Everything/Main.cs b/Plugins/Wox.Plugin.Everything/Main.cs index 86862097c0..8e36ec9257 100644 --- a/Plugins/Wox.Plugin.Everything/Main.cs +++ b/Plugins/Wox.Plugin.Everything/Main.cs @@ -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"); + } } } diff --git a/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj b/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj index 6eef11c31b..0c677c0d26 100644 --- a/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj +++ b/Plugins/Wox.Plugin.Everything/Wox.Plugin.Everything.csproj @@ -41,6 +41,7 @@ ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll + diff --git a/Plugins/Wox.Plugin.Folder/FolderPlugin.cs b/Plugins/Wox.Plugin.Folder/FolderPlugin.cs index 7e7c641021..622acac0d3 100644 --- a/Plugins/Wox.Plugin.Folder/FolderPlugin.cs +++ b/Plugins/Wox.Plugin.Folder/FolderPlugin.cs @@ -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"); + } } } \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Folder/Languages/en.xaml b/Plugins/Wox.Plugin.Folder/Languages/en.xaml index f9bbd6b3b9..cee4e4d808 100644 --- a/Plugins/Wox.Plugin.Folder/Languages/en.xaml +++ b/Plugins/Wox.Plugin.Folder/Languages/en.xaml @@ -8,5 +8,8 @@ Folder Path Please select a folder link Are your sure to delete {0}? - + + Folder + Open favorite folder from wox directorily + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Folder/Languages/zh-cn.xaml b/Plugins/Wox.Plugin.Folder/Languages/zh-cn.xaml index 559b9f4906..01b435ec41 100644 --- a/Plugins/Wox.Plugin.Folder/Languages/zh-cn.xaml +++ b/Plugins/Wox.Plugin.Folder/Languages/zh-cn.xaml @@ -1,12 +1,15 @@ - - - 删除 - 编辑 - 添加 - 文件夹路径 - 请选择一个文件夹 - 你确定要删除{0}吗? - + + + 删除 + 编辑 + 添加 + 文件夹路径 + 请选择一个文件夹 + 你确定要删除{0}吗? + + 文件夹 + 在Wox中直接打开收藏的文件夹 + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Folder/Languages/zh-tw.xaml b/Plugins/Wox.Plugin.Folder/Languages/zh-tw.xaml index 27ac719140..c2f6cd8edd 100644 --- a/Plugins/Wox.Plugin.Folder/Languages/zh-tw.xaml +++ b/Plugins/Wox.Plugin.Folder/Languages/zh-tw.xaml @@ -1,12 +1,15 @@ - - - 刪除 - 編輯 - 添加 - 文件夾路徑 - 請選擇一個文件夾 - 你確認要刪除{0}嗎? - + + + 刪除 + 編輯 + 添加 + 文件夾路徑 + 請選擇一個文件夾 + 你確認要刪除{0}嗎? + + 文件夾 + 在Wox中直接打開收藏的文件夾 + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Folder/plugin.json b/Plugins/Wox.Plugin.Folder/plugin.json index d9129e4d34..cd08d56e8c 100644 --- a/Plugins/Wox.Plugin.Folder/plugin.json +++ b/Plugins/Wox.Plugin.Folder/plugin.json @@ -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", diff --git a/Plugins/Wox.Plugin.Program/Languages/en.xaml b/Plugins/Wox.Plugin.Program/Languages/en.xaml index c0b194f017..84a3e064f4 100644 --- a/Plugins/Wox.Plugin.Program/Languages/en.xaml +++ b/Plugins/Wox.Plugin.Program/Languages/en.xaml @@ -22,5 +22,8 @@ Run As Administrator Open containing folder - + + Program + Search programs in Wox + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Program/Languages/zh-cn.xaml b/Plugins/Wox.Plugin.Program/Languages/zh-cn.xaml index 288e3ba13a..39e5f3b32a 100644 --- a/Plugins/Wox.Plugin.Program/Languages/zh-cn.xaml +++ b/Plugins/Wox.Plugin.Program/Languages/zh-cn.xaml @@ -24,4 +24,7 @@ 以管理员身份运行 打开所属文件夹 + 程序 + 在Wox中搜索程序 + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Program/Languages/zh-tw.xaml b/Plugins/Wox.Plugin.Program/Languages/zh-tw.xaml index 36b4cb42fc..93cf54cb9f 100644 --- a/Plugins/Wox.Plugin.Program/Languages/zh-tw.xaml +++ b/Plugins/Wox.Plugin.Program/Languages/zh-tw.xaml @@ -23,4 +23,7 @@ 以管理員身份運行 打開所屬文件夾 + + 程序 + 在Wox中搜索程序 \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Program/Programs.cs b/Plugins/Wox.Plugin.Program/Programs.cs index 63280d12a2..8ec7599416 100644 --- a/Plugins/Wox.Plugin.Program/Programs.cs +++ b/Plugins/Wox.Plugin.Program/Programs.cs @@ -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"); + } } } diff --git a/Plugins/Wox.Plugin.Program/plugin.json b/Plugins/Wox.Plugin.Program/plugin.json index 9185aa7fe8..9f374dded5 100644 --- a/Plugins/Wox.Plugin.Program/plugin.json +++ b/Plugins/Wox.Plugin.Program/plugin.json @@ -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", diff --git a/Plugins/Wox.Plugin.Sys/Languages/en.xaml b/Plugins/Wox.Plugin.Sys/Languages/en.xaml index 280d5ff506..a80f951b72 100644 --- a/Plugins/Wox.Plugin.Sys/Languages/en.xaml +++ b/Plugins/Wox.Plugin.Sys/Languages/en.xaml @@ -11,5 +11,8 @@ Close Wox Restart Wox Tweak this app - + + System Commands + Provide System related commands. e.g. shutdown,lock,setting etc. + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Sys/Languages/zh-cn.xaml b/Plugins/Wox.Plugin.Sys/Languages/zh-cn.xaml index 5abec64ce5..ef7d495266 100644 --- a/Plugins/Wox.Plugin.Sys/Languages/zh-cn.xaml +++ b/Plugins/Wox.Plugin.Sys/Languages/zh-cn.xaml @@ -1,15 +1,18 @@ - - - 命令 - 描述 - - 关闭电脑 - 注销 - 锁定这台电脑 - 退出Wox - 重启Wox - 设置 - + + + 命令 + 描述 + + 关闭电脑 + 注销 + 锁定这台电脑 + 退出Wox + 重启Wox + 设置 + + 系统命令 + 系统系统相关的命令。例如,关机,锁定,设置等 + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Sys/Languages/zh-tw.xaml b/Plugins/Wox.Plugin.Sys/Languages/zh-tw.xaml index e393f0d8bd..55abdbf433 100644 --- a/Plugins/Wox.Plugin.Sys/Languages/zh-tw.xaml +++ b/Plugins/Wox.Plugin.Sys/Languages/zh-tw.xaml @@ -1,15 +1,18 @@ - - - 命令 - 描述 - - 關閉電腦 - 註銷 - 鎖定這臺電腦 - 退出Wox - 重啟Wox - 設置 - + + + 命令 + 描述 + + 關閉電腦 + 註銷 + 鎖定這臺電腦 + 退出Wox + 重啟Wox + 設置 + + 系統命令 + 系統系統相關的命令。例如,關機,鎖定,設置等 + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Sys/Sys.cs b/Plugins/Wox.Plugin.Sys/Sys.cs index 80132b29ed..1617772b09 100644 --- a/Plugins/Wox.Plugin.Sys/Sys.cs +++ b/Plugins/Wox.Plugin.Sys/Sys.cs @@ -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 results = new List(); 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"); + } + } } diff --git a/Plugins/Wox.Plugin.Url/Images/url.png b/Plugins/Wox.Plugin.Url/Images/url.png index 3b86b637dac8432809fd41b685c56685294ec6b1..90634f7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1zl~ zno2p+$XP*IRebvCrgLUF7GJwon_5&hEX*IvDP zH6=JW*p5xhoXyGv$1-Srx~mR={A0imBMy)%lC3%Q+Wz3dgZ?2(s zaN$BNhHE*J*Pc9ivQExZr%u)JyN+n5@i{`ljMiWe_l2syK}vqe@`md>HPmH_1hR3Y!4 z;V8d|s6Robk;v8uSzO2m2Le*Tn&F>+{;Bh?8)Uv7&JCedMFQI6tP?N!P`d#n+LYMX z*ac*F3R!-TD!2^T2Y`Dzqi$R~8W8>5ZJ2BG0J04$)?5^1qp=!|>O z@gObwu$(lfgY<+wAt51~Sd&2T3#gXq$T$|t2azM)$)C2cV{`xheI=~vbKU5@aqvKo ztTnoP`Lc?|cF@$GjP@XcendDD5FzZ8Gl_0KoiT&5s{H-kQX5q0Brv zTKm#QIf=&yLic#GIh1dO$#POPq1>B5R*xo$hmkYBIQN8lS0r_U+2(xgs0h-SMAfG+ zGhH7OlV4`&}dFHR^NU1U32oo z9%dXU(-v}a?FdMFp4lRuH3?@y)TYp`q)d&lWq{^-tZVerG!%;e0;f)L)sWy?_W%F@ M07*qoM6N<$f&fV!4FCWD diff --git a/Plugins/Wox.Plugin.Url/Languages/en.xaml b/Plugins/Wox.Plugin.Url/Languages/en.xaml new file mode 100644 index 0000000000..eec48e692b --- /dev/null +++ b/Plugins/Wox.Plugin.Url/Languages/en.xaml @@ -0,0 +1,11 @@ + + + Open url:{0} + Can't open url:{0} + + URL + Open the typed URL from Wox + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Url/Languages/zh-cn.xaml b/Plugins/Wox.Plugin.Url/Languages/zh-cn.xaml new file mode 100644 index 0000000000..4cab4182cd --- /dev/null +++ b/Plugins/Wox.Plugin.Url/Languages/zh-cn.xaml @@ -0,0 +1,11 @@ + + + 打开链接:{0} + 无法打开链接:{0} + + URL + 从Wox打开链接 + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Url/Languages/zh-tw.xaml b/Plugins/Wox.Plugin.Url/Languages/zh-tw.xaml new file mode 100644 index 0000000000..e4d45de1da --- /dev/null +++ b/Plugins/Wox.Plugin.Url/Languages/zh-tw.xaml @@ -0,0 +1,11 @@ + + + 打開鏈接:{0} + 無法打開鏈接:{0} + + URL + 從Wox打開鏈接 + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Url/UrlPlugin.cs b/Plugins/Wox.Plugin.Url/UrlPlugin.cs index b769a720bb..ae871d2b23 100644 --- a/Plugins/Wox.Plugin.Url/UrlPlugin.cs +++ b/Plugins/Wox.Plugin.Url/UrlPlugin.cs @@ -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 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"); } } } \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj b/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj index a35d32f5e1..aabcb45255 100644 --- a/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj +++ b/Plugins/Wox.Plugin.Url/Wox.Plugin.Url.csproj @@ -64,6 +64,27 @@ PreserveNewest + + + MSBuild:Compile + Designer + PreserveNewest + + + + + MSBuild:Compile + Designer + PreserveNewest + + + + + MSBuild:Compile + Designer + PreserveNewest + + - 标题 - 启用 - 图标 - 选择图标 - 取消 - 非法的网页搜索 - 请输入标题 - 请输入触发关键字 - 请输入URL - 触发关键字已经存在,请选择一个新的关键字 - 操作成功 - + + + 删除 + 编辑 + 添加 + 触发关键字 + URL + 启用搜索建议 + 请选择一项 + 你确定要删除 {0} 吗? + + + + 标题 + 启用 + 图标 + 选择图标 + 取消 + 非法的网页搜索 + 请输入标题 + 请输入触发关键字 + 请输入URL + 触发关键字已经存在,请选择一个新的关键字 + 操作成功 + + 网页搜索 + 提供网页搜索能力 + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.WebSearch/Languages/zh-tw.xaml b/Plugins/Wox.Plugin.WebSearch/Languages/zh-tw.xaml index def9146a81..ec1f620ab1 100644 --- a/Plugins/Wox.Plugin.WebSearch/Languages/zh-tw.xaml +++ b/Plugins/Wox.Plugin.WebSearch/Languages/zh-tw.xaml @@ -1,28 +1,31 @@ - - - 刪除 - 編輯 - 添加 - 觸發關鍵字 - URL - 啟用搜索建議 - 請選擇一項 - 你確定要刪除 {0} 嗎? - - - - 標題 - 啟用 - 圖標 - 選擇圖標 - 取消 - 非法的網頁搜索 - 請輸入標題 - 請輸入觸發關鍵字 - 請輸入URL - 觸發關鍵字已經存在,請選擇一個新的關鍵字 - 操作成功 - + + + 刪除 + 編輯 + 添加 + 觸發關鍵字 + URL + 啟用搜索建議 + 請選擇一項 + 你確定要刪除 {0} 嗎? + + + + 標題 + 啟用 + 圖標 + 選擇圖標 + 取消 + 非法的網頁搜索 + 請輸入標題 + 請輸入觸發關鍵字 + 請輸入URL + 觸發關鍵字已經存在,請選擇一個新的關鍵字 + 操作成功 + + 網頁搜索 + 提供網頁搜索能力 + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.WebSearch/WebQueryPlugin.cs b/Plugins/Wox.Plugin.WebSearch/WebQueryPlugin.cs index 10632094af..6399a08f19 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebQueryPlugin.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebQueryPlugin.cs @@ -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(' '); diff --git a/Plugins/Wox.Plugin.WebSearch/plugin.json b/Plugins/Wox.Plugin.WebSearch/plugin.json index e1bb0fb631..5132ec9e49 100644 --- a/Plugins/Wox.Plugin.WebSearch/plugin.json +++ b/Plugins/Wox.Plugin.WebSearch/plugin.json @@ -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", diff --git a/Wox.Core/AssemblyHelper.cs b/Wox.Core/AssemblyHelper.cs new file mode 100644 index 0000000000..f9c428178b --- /dev/null +++ b/Wox.Core/AssemblyHelper.cs @@ -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> LoadPluginInterfaces() where T : class + { + List CSharpPluginMetadatas = PluginManager.AllPlugins.Select(o => o.Metadata).Where(o => o.Language.ToUpper() == AllowedLanguage.CSharp.ToUpper()).ToList(); + List> plugins = new List>(); + foreach (PluginMetadata metadata in CSharpPluginMetadatas) + { + try + { + Assembly asm = Assembly.Load(AssemblyName.GetAssemblyName(metadata.ExecuteFilePath)); + List 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(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 LoadInterfacesFromAppDomain() 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(); + } + } +} diff --git a/Wox.Core/Plugin/PluginManager.cs b/Wox.Core/Plugin/PluginManager.cs index 5e93bb0101..ff473061c8 100644 --- a/Wox.Core/Plugin/PluginManager.cs +++ b/Wox.Core/Plugin/PluginManager.cs @@ -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 pluginMetadatas; - private static List> instantSearches; + private static List> instantSearches; private static List> 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> LoadInstantSearches() + private static List> LoadInstantSearches() { if (instantSearches != null) return instantSearches; - instantSearches = new List>(); - List 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 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(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(); return instantSearches; } @@ -261,38 +235,7 @@ namespace Wox.Core.Plugin internal static List> LoadExclusiveSearchPlugins() { if (exclusiveSearchPlugins != null) return exclusiveSearchPlugins; - - exclusiveSearchPlugins = new List>(); - List 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 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(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(); return exclusiveSearchPlugins; } diff --git a/Wox.Core/UI/ResourceMerger.cs b/Wox.Core/UI/ResourceMerger.cs index 6d7a892982..542200ede2 100644 --- a/Wox.Core/UI/ResourceMerger.cs +++ b/Wox.Core/UI/ResourceMerger.cs @@ -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(); 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(); 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 } } } + + } } \ No newline at end of file diff --git a/Wox.Core/Wox.Core.csproj b/Wox.Core/Wox.Core.csproj index 9fc73a2c9a..fa06e3840f 100644 --- a/Wox.Core/Wox.Core.csproj +++ b/Wox.Core/Wox.Core.csproj @@ -69,6 +69,7 @@ + diff --git a/Wox.Core/i18n/Internationalization.cs b/Wox.Core/i18n/Internationalization.cs index d77232091b..25981e89ca 100644 --- a/Wox.Core/i18n/Internationalization.cs +++ b/Wox.Core/i18n/Internationalization.cs @@ -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> plugins = AssemblyHelper.LoadPluginInterfaces(); + 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"); diff --git a/Wox.Plugin/IPluginI18n.cs b/Wox.Plugin/IPluginI18n.cs index cb13dd02bb..c1068ccab8 100644 --- a/Wox.Plugin/IPluginI18n.cs +++ b/Wox.Plugin/IPluginI18n.cs @@ -12,5 +12,9 @@ namespace Wox.Plugin public interface IPluginI18n { string GetLanguagesFolder(); + + string GetTranslatedPluginTitle(); + + string GetTranslatedPluginDescription(); } -} +} \ No newline at end of file diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 482604f4a2..d55e678a3f 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -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; } diff --git a/Wox/Storage/TopMostRecordStorage.cs b/Wox/Storage/TopMostRecordStorage.cs index 87e8feb86b..dc56ed550c 100644 --- a/Wox/Storage/TopMostRecordStorage.cs +++ b/Wox/Storage/TopMostRecordStorage.cs @@ -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)) {