mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
Add translations for Program plugin.
This commit is contained in:
@@ -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)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Wox.Core.i18n
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
/// <param name="folder"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user