Add translations for Program plugin.

This commit is contained in:
qianlifeng
2015-01-06 23:24:11 +08:00
parent ce9c832e00
commit 492e33aeda
14 changed files with 223 additions and 172 deletions

View File

@@ -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)
});
}
}
}
}

View File

@@ -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>

View File

@@ -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;
}
}