mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 19:26:39 +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:
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Plugin;
|
||||
using Wox.Infrastructure.Exception;
|
||||
|
||||
namespace Wox.Core.Resource
|
||||
{
|
||||
@@ -33,14 +35,28 @@ namespace Wox.Core.Resource
|
||||
internal static void UpdatePluginLanguages()
|
||||
{
|
||||
RemoveResource(PluginManager.DirectoryName);
|
||||
foreach (var languageFile in PluginManager.GetPluginsForInterface<IPluginI18n>().
|
||||
Select(plugin => InternationalizationManager.Instance.GetLanguageFile(((IPluginI18n)plugin.Plugin).GetLanguagesFolder())).
|
||||
Where(file => !string.IsNullOrEmpty(file)))
|
||||
foreach (var plugin in PluginManager.GetPluginsForInterface<IPluginI18n>())
|
||||
{
|
||||
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.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user