From 898c8854aa33e2a67902e66736a89752b3274cd2 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Wed, 7 Jan 2015 18:45:55 +0800 Subject: [PATCH] Add translation for web search plugin --- Deploy/Installer/Installer.iss | 4 +- .../Wox.Plugin.WebSearch/Languages/en.xaml | 28 ++ .../Wox.Plugin.WebSearch/Languages/zh-cn.xaml | 28 ++ .../Wox.Plugin.WebSearch/WebSearchPlugin.cs | 11 +- .../WebSearchSetting.xaml | 17 +- .../WebSearchSetting.xaml.cs | 29 +- .../WebSearchesSetting.xaml | 14 +- .../WebSearchesSetting.xaml.cs | 21 +- .../Wox.Plugin.WebSearch.csproj | 266 +++++++++--------- 9 files changed, 256 insertions(+), 162 deletions(-) create mode 100644 Plugins/Wox.Plugin.WebSearch/Languages/en.xaml create mode 100644 Plugins/Wox.Plugin.WebSearch/Languages/zh-cn.xaml diff --git a/Deploy/Installer/Installer.iss b/Deploy/Installer/Installer.iss index 253572eef3..3a30f94d86 100644 --- a/Deploy/Installer/Installer.iss +++ b/Deploy/Installer/Installer.iss @@ -7,7 +7,7 @@ #define MyAppVer = GetFileVersion(MyAppPath + "\Wox.exe") [Setup] -AppId={{A5AF4C34-70A7-4D3B-BA18-E49C0AEEA5E6} +AppId=05700E94-3DAD-4827-8AAA-9908178DE132-Wox AppMutex=DBDE24E4-91F6-11DF-B495-C536DFD72085-Wox AppName={#MyAppName} AppVerName={#MyAppName} v{#MyAppVer} @@ -21,6 +21,8 @@ OutputBaseFilename=Wox-setup OutputDir={#OutputPath} Compression=lzma SolidCompression=yes +DisableDirPage=auto +DisableProgramGroupPage=auto [Languages] Name: english; MessagesFile: compiler:Default.isl diff --git a/Plugins/Wox.Plugin.WebSearch/Languages/en.xaml b/Plugins/Wox.Plugin.WebSearch/Languages/en.xaml new file mode 100644 index 0000000000..e0a143f53c --- /dev/null +++ b/Plugins/Wox.Plugin.WebSearch/Languages/en.xaml @@ -0,0 +1,28 @@ + + + Delete + Edit + Add + Action Keyword + URL + Enable search suggestions + Please select a web search + Are your sure to delete {0}? + + + + Title + Enable + Select Icon + Icon + Cancel + Invalid web search + Please input title + Please input action keyword + Please input URL + ActionWord has existed, please input a new one + Succeed + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.WebSearch/Languages/zh-cn.xaml b/Plugins/Wox.Plugin.WebSearch/Languages/zh-cn.xaml new file mode 100644 index 0000000000..6e13e40ceb --- /dev/null +++ b/Plugins/Wox.Plugin.WebSearch/Languages/zh-cn.xaml @@ -0,0 +1,28 @@ + + + 删除 + 编辑 + 添加 + 触发关键字 + URL + 启用搜索建议 + 请选择一项 + 你确定要删除 {0} 吗? + + + + 标题 + 启用 + 图标 + 选择图标 + 取消 + 非法的网页搜索 + 请输入标题 + 请输入触发关键字 + 请输入URL + 触发关键字已经存在,请选择一个新的关键字 + 操作成功 + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs index 6b24eead6d..f7bd002aa5 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs @@ -1,13 +1,15 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; +using System.Reflection; using Wox.Core.UserSettings; using Wox.Plugin.WebSearch.SuggestionSources; namespace Wox.Plugin.WebSearch { - public class WebSearchPlugin : IPlugin, ISettingProvider + public class WebSearchPlugin : IPlugin, ISettingProvider,IPluginI18n { private PluginInitContext context; @@ -86,9 +88,14 @@ namespace Wox.Plugin.WebSearch public System.Windows.Controls.Control CreateSettingPanel() { - return new WebSearchesSetting(); + return new WebSearchesSetting(context); } #endregion + + public string GetLanguagesFolder() + { + return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages"); + } } } diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml b/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml index 2ffc409d66..86beaf2917 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml @@ -17,27 +17,28 @@ - Title: + - URL: + - ActionWord: + - Enable: + - Icon: + - + - - + + diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs index c237a5f5bf..c7e5138d06 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchSetting.xaml.cs @@ -15,9 +15,11 @@ namespace Wox.Plugin.WebSearch private WebSearchesSetting settingWindow; private bool update; private Core.UserSettings.WebSearch updateWebSearch; + private PluginInitContext context; - public WebSearchSetting(WebSearchesSetting settingWidow) + public WebSearchSetting(WebSearchesSetting settingWidow,PluginInitContext context) { + this.context = context; this.settingWindow = settingWidow; InitializeComponent(); } @@ -27,7 +29,9 @@ namespace Wox.Plugin.WebSearch updateWebSearch = UserSettingStorage.Instance.WebSearches.FirstOrDefault(o => o == webSearch); if (updateWebSearch == null || string.IsNullOrEmpty(updateWebSearch.Url)) { - MessageBox.Show("Invalid web search"); + + string warning = context.API.GetTranslation("wox_plugin_websearch_invalid_web_search"); + MessageBox.Show(warning); Close(); return; } @@ -63,21 +67,24 @@ namespace Wox.Plugin.WebSearch string title = tbTitle.Text; if (string.IsNullOrEmpty(title)) { - MessageBox.Show("Please input Title field"); + string warning = context.API.GetTranslation("wox_plugin_websearch_input_title"); + MessageBox.Show(warning); return; } string url = tbUrl.Text; if (string.IsNullOrEmpty(url)) { - MessageBox.Show("Please input URL field"); + string warning = context.API.GetTranslation("wox_plugin_websearch_input_url"); + MessageBox.Show(warning); return; } string action = tbActionword.Text; if (string.IsNullOrEmpty(action)) { - MessageBox.Show("Please input ActionWord field"); + string warning = context.API.GetTranslation("wox_plugin_websearch_input_action_keyword"); + MessageBox.Show(warning); return; } @@ -86,7 +93,8 @@ namespace Wox.Plugin.WebSearch { if (UserSettingStorage.Instance.WebSearches.Exists(o => o.ActionWord == action)) { - MessageBox.Show("ActionWord has existed, please input a new one."); + string warning = context.API.GetTranslation("wox_plugin_websearch_action_keyword_exist"); + MessageBox.Show(warning); return; } UserSettingStorage.Instance.WebSearches.Add(new Core.UserSettings.WebSearch() @@ -97,13 +105,15 @@ namespace Wox.Plugin.WebSearch Url = url, Title = title }); - MessageBox.Show(string.Format("Add {0} web search successfully!", title)); + string msg = context.API.GetTranslation("wox_plugin_websearch_succeed"); + MessageBox.Show(msg); } else { if (UserSettingStorage.Instance.WebSearches.Exists(o => o.ActionWord == action && o != updateWebSearch)) { - MessageBox.Show("ActionWord has existed, please input a new one."); + string warning = context.API.GetTranslation("wox_plugin_websearch_action_keyword_exist"); + MessageBox.Show(warning); return; } updateWebSearch.ActionWord = action; @@ -111,7 +121,8 @@ namespace Wox.Plugin.WebSearch updateWebSearch.Enabled = cbEnable.IsChecked ?? false; updateWebSearch.Url = url; updateWebSearch.Title= title; - MessageBox.Show(string.Format("Update {0} web search successfully!", title)); + string msg = context.API.GetTranslation("wox_plugin_websearch_succeed"); + MessageBox.Show(msg); } UserSettingStorage.Instance.Save(); settingWindow.ReloadWebSearchView(); diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchesSetting.xaml b/Plugins/Wox.Plugin.WebSearch/WebSearchesSetting.xaml index be59621a3d..0a823dc7cd 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchesSetting.xaml +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchesSetting.xaml @@ -4,7 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" - d:DesignHeight="300" d:DesignWidth="300"> + d:DesignHeight="300" d:DesignWidth="500"> @@ -12,21 +12,21 @@ - Enable search suggestions + - + - + @@ -37,9 +37,9 @@ -