diff --git a/Plugins/Wox.Plugin.Program/Languages/en.xaml b/Plugins/Wox.Plugin.Program/Languages/en.xaml index d117108558..3e9a4f1b62 100644 --- a/Plugins/Wox.Plugin.Program/Languages/en.xaml +++ b/Plugins/Wox.Plugin.Program/Languages/en.xaml @@ -2,6 +2,22 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib"> - Delete + + Delete + Edit + Add + Location + Index file suffixes + Reindex + Indexing + + Please select a program source + Are your sure to delete {0}? + + Update + Wox will only index files that end with following suffixes: + (Each suffix should split by ;) + Sucessfully update file suffixes + File suffixes can't be empty \ 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 new file mode 100644 index 0000000000..3887344677 --- /dev/null +++ b/Plugins/Wox.Plugin.Program/Languages/zh-cn.xaml @@ -0,0 +1,24 @@ + + + + 删除 + 编辑 + 增加 + 位置 + 索引文件后缀 + 重新索引 + 索引中 + + + 请先选择一项 + 你确定要删除{0}吗? + + 更新 + Wox仅索引下列后缀的文件: + (每个后缀以英文状态下的分号分隔) + 成功更新索引文件后缀 + 文件后缀不能为空 + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml index d5036e915e..3b268f5755 100644 --- a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml +++ b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml @@ -3,14 +3,9 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:infrastructure="clr-namespace:Wox.Infrastructure;assembly=Wox.Infrastructure" xmlns:program="clr-namespace:Wox.Plugin.Program" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="600"> - - - - @@ -18,13 +13,13 @@ - - + + - + @@ -37,12 +32,12 @@ - Indexing + - + diff --git a/Plugins/Wox.Plugin.Program/ProgramSuffixes.xaml.cs b/Plugins/Wox.Plugin.Program/ProgramSuffixes.xaml.cs index 2d2c6d572b..735c28bed5 100644 --- a/Plugins/Wox.Plugin.Program/ProgramSuffixes.xaml.cs +++ b/Plugins/Wox.Plugin.Program/ProgramSuffixes.xaml.cs @@ -7,8 +7,11 @@ namespace Wox.Plugin.Program /// public partial class ProgramSuffixes { - public ProgramSuffixes() + private PluginInitContext context; + + public ProgramSuffixes(PluginInitContext context) { + this.context = context; InitializeComponent(); tbSuffixes.Text = ProgramStorage.Instance.ProgramSuffixes; @@ -18,12 +21,14 @@ namespace Wox.Plugin.Program { if (string.IsNullOrEmpty(tbSuffixes.Text)) { - MessageBox.Show("File suffixes can't be empty"); + string warning = context.API.GetTranslation("wox_plugin_program_suffixes_cannot_empty"); + MessageBox.Show(warning); return; } ProgramStorage.Instance.ProgramSuffixes = tbSuffixes.Text; - MessageBox.Show("Sucessfully update file suffixes"); + string msg = context.API.GetTranslation("wox_plugin_program_update_file_suffixes"); + MessageBox.Show(msg); } } } diff --git a/Plugins/Wox.Plugin.Program/Programs.cs b/Plugins/Wox.Plugin.Program/Programs.cs index ea525140f1..afcd078a13 100644 --- a/Plugins/Wox.Plugin.Program/Programs.cs +++ b/Plugins/Wox.Plugin.Program/Programs.cs @@ -178,7 +178,7 @@ namespace Wox.Plugin.Program public System.Windows.Controls.Control CreateSettingPanel() { - return new ProgramSetting(); + return new ProgramSetting(context); } #endregion diff --git a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj index c72b51267d..371c98697e 100644 --- a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj +++ b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj @@ -1,126 +1,131 @@ - - - - - Debug - AnyCPU - {FDB3555B-58EF-4AE6-B5F1-904719637AB4} - Library - Properties - Wox.Plugin.Program - Wox.Plugin.Program - v3.5 - 512 - ..\..\ - true - - - true - full - false - ..\..\Output\Debug\Plugins\Wox.Plugin.Program\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\..\packages\log4net.2.0.3\lib\net35-full\log4net.dll - - - False - ..\..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll - - - - - - - - - - - - - - - - - - - - ProgramSetting.xaml - - - - - - - - - ProgramSuffixes.xaml - - - - - - - - PreserveNewest - - - - - PreserveNewest - - - MSBuild:Compile - Designer - PreserveNewest - - - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - - - {4fd29318-a8ab-4d8f-aa47-60bc241b8da3} - Wox.Infrastructure - - - {8451ecdd-2ea4-4966-bb0a-7bbc40138e80} - Wox.Plugin - - - - - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - - + + + + + Debug + AnyCPU + {FDB3555B-58EF-4AE6-B5F1-904719637AB4} + Library + Properties + Wox.Plugin.Program + Wox.Plugin.Program + v3.5 + 512 + ..\..\ + true + + + true + full + false + ..\..\Output\Debug\Plugins\Wox.Plugin.Program\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\packages\log4net.2.0.3\lib\net35-full\log4net.dll + + + False + ..\..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + ProgramSetting.xaml + + + + + + + + + ProgramSuffixes.xaml + + + + + + + + PreserveNewest + + + + + PreserveNewest + + + MSBuild:Compile + Designer + PreserveNewest + + + + + MSBuild:Compile + Designer + PreserveNewest + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + {4fd29318-a8ab-4d8f-aa47-60bc241b8da3} + Wox.Infrastructure + + + {8451ecdd-2ea4-4966-bb0a-7bbc40138e80} + Wox.Plugin + + + + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + \ No newline at end of file diff --git a/Wox.Core/UI/ResourceMerger.cs b/Wox.Core/UI/ResourceMerger.cs index 60e34fdeb6..c261576e6a 100644 --- a/Wox.Core/UI/ResourceMerger.cs +++ b/Wox.Core/UI/ResourceMerger.cs @@ -12,8 +12,8 @@ namespace Wox.Core.UI public static void ApplyResources() { Application.Current.Resources.MergedDictionaries.Clear(); - ApplyUIResources(); ApplyPluginLanguages(); + ApplyUIResources(); } private static void ApplyUIResources() @@ -37,13 +37,17 @@ namespace Wox.Core.UI .SelectMany(s => s.GetTypes()) .Where(p => p.IsClass && !p.IsAbstract && pluginI18nType.IsAssignableFrom(p)); - foreach (IPluginI18n pluginI18n in pluginI18ns) + foreach (var pluginI18n in pluginI18ns) { - string languageFile = InternationalizationManager.Internationalization.GetLanguageFile(pluginI18n.GetLanguagesFolder()); - Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary + string languageFile = InternationalizationManager.Internationalization.GetLanguageFile( + ((IPluginI18n)Activator.CreateInstance(pluginI18n)).GetLanguagesFolder()); + if (!string.IsNullOrEmpty(languageFile)) { - Source = new Uri(languageFile, UriKind.Absolute) - }); + Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary + { + Source = new Uri(languageFile, UriKind.Absolute) + }); + } } } } diff --git a/Wox.Core/i18n/IInternationalization.cs b/Wox.Core/i18n/IInternationalization.cs index b74af99be1..23335d7e97 100644 --- a/Wox.Core/i18n/IInternationalization.cs +++ b/Wox.Core/i18n/IInternationalization.cs @@ -14,7 +14,7 @@ namespace Wox.Core.i18n /// /// Get language file for current user selected language /// if couldn't find the current selected language file, it will first try to load en.xaml - /// if en.xaml couldn't find, it will pick up first *.xaml file + /// if en.xaml couldn't find, return empty string /// /// /// diff --git a/Wox.Core/i18n/Internationalization.cs b/Wox.Core/i18n/Internationalization.cs index fdb51e1c35..d77232091b 100644 --- a/Wox.Core/i18n/Internationalization.cs +++ b/Wox.Core/i18n/Internationalization.cs @@ -137,16 +137,8 @@ namespace Wox.Core.i18n { return english; } - else - { - string file = Directory.GetFiles(folder).FirstOrDefault(o => o.EndsWith("xaml")); - if (string.IsNullOrEmpty(file)) - { - throw new WoxI18nException(string.Format("Couldn't find language file from:{0}, current selected language:{1}")); - } - return Path.Combine(folder, file); - } + return string.Empty; } } diff --git a/Wox.Plugin/IPublicAPI.cs b/Wox.Plugin/IPublicAPI.cs index 5ae94e0a40..49279d7900 100644 --- a/Wox.Plugin/IPublicAPI.cs +++ b/Wox.Plugin/IPublicAPI.cs @@ -36,6 +36,8 @@ namespace Wox.Plugin void ReloadPlugins(); + string GetTranslation(string key); + List GetAllPlugins(); event WoxKeyDownEventHandler BackKeyDownEvent; diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 8cb1eb757e..ed76bf6351 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -132,6 +132,11 @@ namespace Wox Dispatcher.Invoke(new Action(() => PluginManager.Init(this))); } + public string GetTranslation(string key) + { + return InternationalizationManager.Internationalization.GetTranslation(key); + } + public List GetAllPlugins() { return PluginManager.AllPlugins; diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs index 706acb470a..56f5f3435c 100644 --- a/Wox/SettingWindow.xaml.cs +++ b/Wox/SettingWindow.xaml.cs @@ -482,7 +482,7 @@ namespace Wox pluginTitle.Text = pair.Metadata.Name; pluginTitle.Cursor = Cursors.Hand; pluginActionKeyword.Text = pair.Metadata.ActionKeyword; - pluginAuthor.Text = "By: " + pair.Metadata.Author; + pluginAuthor.Text = InternationalizationManager.Internationalization.GetTranslation("author") + ": " + pair.Metadata.Author; pluginSubTitle.Text = pair.Metadata.Description; pluginId = pair.Metadata.ID; pluginIcon.Source = ImageLoader.ImageLoader.Load(pair.Metadata.FullIcoPath); @@ -509,8 +509,6 @@ namespace Wox control.Width = Double.NaN; control.Height = Double.NaN; } - // featureControls - // throw new NotImplementedException(); } private void CbDisablePlugin_OnClick(object sender, RoutedEventArgs e)