mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 04:37:30 +02:00
Fix "NoTranslation" bug for plugins
1. fix #475 2. remove GetLanguagesFolder, part of #468 3. bug introduced since 1f939ff3
This commit is contained in:
@@ -6,7 +6,6 @@ using System.Linq;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using WindowsInput;
|
using WindowsInput;
|
||||||
using WindowsInput.Native;
|
using WindowsInput.Native;
|
||||||
using Wox.Infrastructure;
|
|
||||||
using Wox.Infrastructure.Hotkey;
|
using Wox.Infrastructure.Hotkey;
|
||||||
using Wox.Infrastructure.Logger;
|
using Wox.Infrastructure.Logger;
|
||||||
using Control = System.Windows.Controls.Control;
|
using Control = System.Windows.Controls.Control;
|
||||||
@@ -200,11 +199,6 @@ namespace Wox.Plugin.CMD
|
|||||||
return new CMDSetting();
|
return new CMDSetting();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetLanguagesFolder()
|
|
||||||
{
|
|
||||||
return Path.Combine(WoxDirectroy.Executable, "Languages");
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetTranslatedPluginTitle()
|
public string GetTranslatedPluginTitle()
|
||||||
{
|
{
|
||||||
return context.API.GetTranslation("wox_plugin_cmd_plugin_name");
|
return context.API.GetTranslation("wox_plugin_cmd_plugin_name");
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Wox.Infrastructure;
|
|
||||||
using YAMP;
|
using YAMP;
|
||||||
|
|
||||||
namespace Wox.Plugin.Caculator
|
namespace Wox.Plugin.Caculator
|
||||||
@@ -93,12 +91,6 @@ namespace Wox.Plugin.Caculator
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetLanguagesFolder()
|
|
||||||
{
|
|
||||||
return Path.Combine(WoxDirectroy.Executable, "Languages");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetTranslatedPluginTitle()
|
public string GetTranslatedPluginTitle()
|
||||||
{
|
{
|
||||||
return context.API.GetTranslation("wox_plugin_caculator_plugin_name");
|
return context.API.GetTranslation("wox_plugin_caculator_plugin_name");
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using System.Drawing.Imaging;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Wox.Infrastructure;
|
|
||||||
|
|
||||||
namespace Wox.Plugin.Color
|
namespace Wox.Plugin.Color
|
||||||
{
|
{
|
||||||
@@ -109,11 +108,6 @@ namespace Wox.Plugin.Color
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public string GetLanguagesFolder()
|
|
||||||
{
|
|
||||||
return Path.Combine(WoxDirectroy.Executable, "Languages");
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetTranslatedPluginTitle()
|
public string GetTranslatedPluginTitle()
|
||||||
{
|
{
|
||||||
return context.API.GetTranslation("wox_plugin_color_plugin_name");
|
return context.API.GetTranslation("wox_plugin_color_plugin_name");
|
||||||
|
|||||||
@@ -82,11 +82,6 @@ namespace Wox.Plugin.ControlPanel
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetLanguagesFolder()
|
|
||||||
{
|
|
||||||
return Path.Combine(WoxDirectroy.Executable, "Languages");
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetTranslatedPluginTitle()
|
public string GetTranslatedPluginTitle()
|
||||||
{
|
{
|
||||||
return context.API.GetTranslation("wox_plugin_controlpanel_plugin_name");
|
return context.API.GetTranslation("wox_plugin_controlpanel_plugin_name");
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ using System.Linq;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.ServiceProcess;
|
using System.ServiceProcess;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Wox.Infrastructure;
|
|
||||||
using Wox.Plugin.Everything.Everything;
|
using Wox.Plugin.Everything.Everything;
|
||||||
|
|
||||||
namespace Wox.Plugin.Everything
|
namespace Wox.Plugin.Everything
|
||||||
@@ -256,11 +255,6 @@ namespace Wox.Plugin.Everything
|
|||||||
return directory;
|
return directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetLanguagesFolder()
|
|
||||||
{
|
|
||||||
return Path.Combine(WoxDirectroy.Executable, "Languages");
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetTranslatedPluginTitle()
|
public string GetTranslatedPluginTitle()
|
||||||
{
|
{
|
||||||
return _context.API.GetTranslation("wox_plugin_everything_plugin_name");
|
return _context.API.GetTranslation("wox_plugin_everything_plugin_name");
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using Wox.Infrastructure;
|
|
||||||
|
|
||||||
namespace Wox.Plugin.Folder
|
namespace Wox.Plugin.Folder
|
||||||
{
|
{
|
||||||
@@ -244,11 +243,6 @@ namespace Wox.Plugin.Folder
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetLanguagesFolder()
|
|
||||||
{
|
|
||||||
return Path.Combine(WoxDirectroy.Executable, "Languages");
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetTranslatedPluginTitle()
|
public string GetTranslatedPluginTitle()
|
||||||
{
|
{
|
||||||
return context.API.GetTranslation("wox_plugin_folder_plugin_name");
|
return context.API.GetTranslation("wox_plugin_folder_plugin_name");
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Wox.Core.Plugin;
|
using Wox.Core.Plugin;
|
||||||
using Wox.Core.UserSettings;
|
using Wox.Core.UserSettings;
|
||||||
using Wox.Infrastructure;
|
|
||||||
|
|
||||||
namespace Wox.Plugin.PluginIndicator
|
namespace Wox.Plugin.PluginIndicator
|
||||||
{
|
{
|
||||||
@@ -39,11 +37,6 @@ namespace Wox.Plugin.PluginIndicator
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetLanguagesFolder()
|
|
||||||
{
|
|
||||||
return Path.Combine(WoxDirectroy.Executable, "Languages");
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetTranslatedPluginTitle()
|
public string GetTranslatedPluginTitle()
|
||||||
{
|
{
|
||||||
return context.API.GetTranslation("wox_plugin_pluginindicator_plugin_name");
|
return context.API.GetTranslation("wox_plugin_pluginindicator_plugin_name");
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using System.Text;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Wox.Infrastructure;
|
|
||||||
|
|
||||||
namespace Wox.Plugin.PluginManagement
|
namespace Wox.Plugin.PluginManagement
|
||||||
{
|
{
|
||||||
@@ -242,11 +241,6 @@ namespace Wox.Plugin.PluginManagement
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetLanguagesFolder()
|
|
||||||
{
|
|
||||||
return Path.Combine(WoxDirectroy.Executable, "Languages");
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetTranslatedPluginTitle()
|
public string GetTranslatedPluginTitle()
|
||||||
{
|
{
|
||||||
return context.API.GetTranslation("wox_plugin_plugin_management_plugin_name");
|
return context.API.GetTranslation("wox_plugin_plugin_management_plugin_name");
|
||||||
|
|||||||
@@ -175,10 +175,6 @@ namespace Wox.Plugin.Program
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public string GetLanguagesFolder()
|
|
||||||
{
|
|
||||||
return Path.Combine(WoxDirectroy.Executable, "Languages");
|
|
||||||
}
|
|
||||||
public string GetTranslatedPluginTitle()
|
public string GetTranslatedPluginTitle()
|
||||||
{
|
{
|
||||||
return context.API.GetTranslation("wox_plugin_program_plugin_name");
|
return context.API.GetTranslation("wox_plugin_program_plugin_name");
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
@@ -190,11 +189,6 @@ namespace Wox.Plugin.Sys
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetLanguagesFolder()
|
|
||||||
{
|
|
||||||
return Path.Combine(WoxDirectroy.Executable, "Languages");
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetTranslatedPluginTitle()
|
public string GetTranslatedPluginTitle()
|
||||||
{
|
{
|
||||||
return context.API.GetTranslation("wox_plugin_sys_plugin_name");
|
return context.API.GetTranslation("wox_plugin_sys_plugin_name");
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Wox.Infrastructure;
|
|
||||||
|
|
||||||
namespace Wox.Plugin.Url
|
namespace Wox.Plugin.Url
|
||||||
{
|
{
|
||||||
@@ -103,11 +101,6 @@ namespace Wox.Plugin.Url
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetLanguagesFolder()
|
|
||||||
{
|
|
||||||
return Path.Combine(WoxDirectroy.Executable, "Languages");
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetTranslatedPluginTitle()
|
public string GetTranslatedPluginTitle()
|
||||||
{
|
{
|
||||||
return context.API.GetTranslation("wox_plugin_url_plugin_name");
|
return context.API.GetTranslation("wox_plugin_url_plugin_name");
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using Wox.Infrastructure;
|
|
||||||
using Wox.Plugin.WebSearch.Annotations;
|
using Wox.Plugin.WebSearch.Annotations;
|
||||||
using Wox.Plugin.WebSearch.SuggestionSources;
|
using Wox.Plugin.WebSearch.SuggestionSources;
|
||||||
|
|
||||||
@@ -90,11 +88,6 @@ namespace Wox.Plugin.WebSearch
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public string GetLanguagesFolder()
|
|
||||||
{
|
|
||||||
return Path.Combine(WoxDirectroy.Executable, "Languages");
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetTranslatedPluginTitle()
|
public string GetTranslatedPluginTitle()
|
||||||
{
|
{
|
||||||
return Context.API.GetTranslation("wox_plugin_websearch_plugin_name");
|
return Context.API.GetTranslation("wox_plugin_websearch_plugin_name");
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ namespace Wox.Core.Resource
|
|||||||
public Internationalization()
|
public Internationalization()
|
||||||
{
|
{
|
||||||
DirectoryName = "Languages";
|
DirectoryName = "Languages";
|
||||||
MakesureThemeDirectoriesExist();
|
MakesureDirectoriesExist();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MakesureThemeDirectoriesExist()
|
private void MakesureDirectoriesExist()
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(DirectoryPath))
|
if (!Directory.Exists(DirectoryPath))
|
||||||
{
|
{
|
||||||
@@ -73,10 +73,11 @@ namespace Wox.Core.Resource
|
|||||||
|
|
||||||
public override ResourceDictionary GetResourceDictionary()
|
public override ResourceDictionary GetResourceDictionary()
|
||||||
{
|
{
|
||||||
return new ResourceDictionary
|
var dictionary = new ResourceDictionary
|
||||||
{
|
{
|
||||||
Source = new Uri(GetLanguageFile(DirectoryPath), UriKind.Absolute)
|
Source = new Uri(GetLanguageFile(DirectoryPath), UriKind.Absolute)
|
||||||
};
|
};
|
||||||
|
return dictionary;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Language> LoadAvailableLanguages()
|
public List<Language> LoadAvailableLanguages()
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Wox.Core.Plugin;
|
using Wox.Core.Plugin;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
|
using Wox.Infrastructure.Exception;
|
||||||
|
|
||||||
namespace Wox.Core.Resource
|
namespace Wox.Core.Resource
|
||||||
{
|
{
|
||||||
@@ -33,14 +35,28 @@ namespace Wox.Core.Resource
|
|||||||
internal static void UpdatePluginLanguages()
|
internal static void UpdatePluginLanguages()
|
||||||
{
|
{
|
||||||
RemoveResource(PluginManager.DirectoryName);
|
RemoveResource(PluginManager.DirectoryName);
|
||||||
foreach (var languageFile in PluginManager.GetPluginsForInterface<IPluginI18n>().
|
foreach (var plugin in PluginManager.GetPluginsForInterface<IPluginI18n>())
|
||||||
Select(plugin => InternationalizationManager.Instance.GetLanguageFile(((IPluginI18n)plugin.Plugin).GetLanguagesFolder())).
|
|
||||||
Where(file => !string.IsNullOrEmpty(file)))
|
|
||||||
{
|
{
|
||||||
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary
|
var location = Assembly.GetAssembly(plugin.Plugin.GetType()).Location;
|
||||||
|
var directoryName = Path.GetDirectoryName(location);
|
||||||
|
if (directoryName != null)
|
||||||
{
|
{
|
||||||
Source = new Uri(languageFile, UriKind.Absolute)
|
var internationalization = InternationalizationManager.Instance;
|
||||||
});
|
var folder = Path.Combine(directoryName, internationalization.DirectoryName);
|
||||||
|
var file = internationalization.GetLanguageFile(folder);
|
||||||
|
if (!string.IsNullOrEmpty(file))
|
||||||
|
{
|
||||||
|
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary
|
||||||
|
{
|
||||||
|
Source = new Uri(file, UriKind.Absolute)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new WoxPluginException(plugin.Metadata.Name, "Can't find plugin location.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,5 +14,9 @@
|
|||||||
{
|
{
|
||||||
PluginName = pluginName;
|
PluginName = pluginName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WoxPluginException(string msg) : base(msg)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ namespace Wox.Plugin
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IPluginI18n : IFeatures
|
public interface IPluginI18n : IFeatures
|
||||||
{
|
{
|
||||||
string GetLanguagesFolder();
|
|
||||||
|
|
||||||
string GetTranslatedPluginTitle();
|
string GetTranslatedPluginTitle();
|
||||||
|
|
||||||
string GetTranslatedPluginDescription();
|
string GetTranslatedPluginDescription();
|
||||||
|
|||||||
Reference in New Issue
Block a user