mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 11:39:16 +08:00
Add translations for Program plugin.
This commit is contained in:
parent
ce9c832e00
commit
492e33aeda
@ -2,6 +2,22 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:String x:Key="wox_plugin_porgram_delete">Delete</system:String>
|
||||
<!--Program setting-->
|
||||
<system:String x:Key="wox_plugin_program_delete">Delete</system:String>
|
||||
<system:String x:Key="wox_plugin_program_edit">Edit</system:String>
|
||||
<system:String x:Key="wox_plugin_program_add">Add</system:String>
|
||||
<system:String x:Key="wox_plugin_program_location">Location</system:String>
|
||||
<system:String x:Key="wox_plugin_program_suffixes">Index file suffixes</system:String>
|
||||
<system:String x:Key="wox_plugin_program_reindex">Reindex</system:String>
|
||||
<system:String x:Key="wox_plugin_program_indexing">Indexing</system:String>
|
||||
|
||||
<system:String x:Key="wox_plugin_program_pls_select_program_source">Please select a program source</system:String>
|
||||
<system:String x:Key="wox_plugin_program_delete_program_source">Are your sure to delete {0}?</system:String>
|
||||
|
||||
<system:String x:Key="wox_plugin_program_update">Update</system:String>
|
||||
<system:String x:Key="wox_plugin_program_only_index_tip">Wox will only index files that end with following suffixes:</system:String>
|
||||
<system:String x:Key="wox_plugin_program_split_by_tip">(Each suffix should split by ;)</system:String>
|
||||
<system:String x:Key="wox_plugin_program_update_file_suffixes">Sucessfully update file suffixes</system:String>
|
||||
<system:String x:Key="wox_plugin_program_suffixes_cannot_empty">File suffixes can't be empty</system:String>
|
||||
|
||||
</ResourceDictionary>
|
24
Plugins/Wox.Plugin.Program/Languages/zh-cn.xaml
Normal file
24
Plugins/Wox.Plugin.Program/Languages/zh-cn.xaml
Normal file
@ -0,0 +1,24 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<!--Program setting-->
|
||||
<system:String x:Key="wox_plugin_program_delete">删除</system:String>
|
||||
<system:String x:Key="wox_plugin_program_edit">编辑</system:String>
|
||||
<system:String x:Key="wox_plugin_program_add">增加</system:String>
|
||||
<system:String x:Key="wox_plugin_program_location">位置</system:String>
|
||||
<system:String x:Key="wox_plugin_program_suffixes">索引文件后缀</system:String>
|
||||
<system:String x:Key="wox_plugin_program_reindex">重新索引</system:String>
|
||||
<system:String x:Key="wox_plugin_program_indexing">索引中</system:String>
|
||||
|
||||
|
||||
<system:String x:Key="wox_plugin_program_pls_select_program_source">请先选择一项</system:String>
|
||||
<system:String x:Key="wox_plugin_program_delete_program_source">你确定要删除{0}吗?</system:String>
|
||||
|
||||
<system:String x:Key="wox_plugin_program_update">更新</system:String>
|
||||
<system:String x:Key="wox_plugin_program_only_index_tip">Wox仅索引下列后缀的文件:</system:String>
|
||||
<system:String x:Key="wox_plugin_program_split_by_tip">(每个后缀以英文状态下的分号分隔)</system:String>
|
||||
<system:String x:Key="wox_plugin_program_update_file_suffixes">成功更新索引文件后缀</system:String>
|
||||
<system:String x:Key="wox_plugin_program_suffixes_cannot_empty">文件后缀不能为空</system:String>
|
||||
|
||||
</ResourceDictionary>
|
@ -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">
|
||||
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVis" />
|
||||
</UserControl.Resources>
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"/>
|
||||
@ -18,13 +13,13 @@
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Height="30" HorizontalAlignment="Right" x:Name="btnProgramSuffixes" Width="130" Click="BtnProgramSuffixes_OnClick">Index file suffixes</Button>
|
||||
<Button Height="30" HorizontalAlignment="Right" Margin="10 0 0 0" x:Name="btnReindex" Width="100" Click="btnReindex_Click">Re-Index</Button>
|
||||
<Button Height="30" HorizontalAlignment="Right" x:Name="btnProgramSuffixes" Width="130" Click="BtnProgramSuffixes_OnClick" Content="{DynamicResource wox_plugin_program_suffixes}"></Button>
|
||||
<Button Height="30" HorizontalAlignment="Right" Margin="10 0 0 0" x:Name="btnReindex" Width="100" Click="btnReindex_Click" Content="{DynamicResource wox_plugin_program_reindex}"></Button>
|
||||
</StackPanel>
|
||||
<ListView x:Name="programSourceView" Grid.Row="1">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Header="Location" Width="400">
|
||||
<GridViewColumn Header="{DynamicResource wox_plugin_program_location}" Width="400">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Location, ConverterParameter=(null), Converter={program:StringEmptyConverter}}"/>
|
||||
@ -37,12 +32,12 @@
|
||||
<DockPanel Grid.Row="2">
|
||||
<StackPanel x:Name="indexingPanel" Visibility="Hidden" HorizontalAlignment="Left" Orientation="Horizontal">
|
||||
<ProgressBar x:Name="progressBarIndexing" Height="20" Width="80" Minimum="0" Maximum="100" IsIndeterminate="True"></ProgressBar>
|
||||
<TextBlock Margin="10 0 0 0" Height="20" HorizontalAlignment="Center">Indexing</TextBlock>
|
||||
<TextBlock Margin="10 0 0 0" Height="20" HorizontalAlignment="Center" Text="{DynamicResource wox_plugin_program_indexing}"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<Button x:Name="btnDeleteProgramSource" Click="btnDeleteProgramSource_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_porgram_delete}"/>
|
||||
<Button x:Name="btnEditProgramSource" Click="btnEditProgramSource_OnClick" Width="100" Margin="10" Content="Edit"/>
|
||||
<Button x:Name="btnAddProgramSource" Click="btnAddProgramSource_OnClick" Width="100" Margin="10" Content="Add"/>
|
||||
<Button x:Name="btnDeleteProgramSource" Click="btnDeleteProgramSource_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_program_delete}"/>
|
||||
<Button x:Name="btnEditProgramSource" Click="btnEditProgramSource_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_program_edit}"/>
|
||||
<Button x:Name="btnAddProgramSource" Click="btnAddProgramSource_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_program_add}"/>
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
|
@ -10,8 +10,11 @@ namespace Wox.Plugin.Program
|
||||
/// </summary>
|
||||
public partial class ProgramSetting : UserControl
|
||||
{
|
||||
public ProgramSetting()
|
||||
private PluginInitContext context;
|
||||
|
||||
public ProgramSetting(PluginInitContext context)
|
||||
{
|
||||
this.context = context;
|
||||
InitializeComponent();
|
||||
Loaded += Setting_Loaded;
|
||||
}
|
||||
@ -55,8 +58,9 @@ namespace Wox.Plugin.Program
|
||||
ProgramSource selectedProgramSource = programSourceView.SelectedItem as ProgramSource;
|
||||
if (selectedProgramSource != null)
|
||||
{
|
||||
if (MessageBox.Show("Are your sure to delete " + selectedProgramSource.Location, "Delete ProgramSource",
|
||||
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
string msg = string.Format(context.API.GetTranslation("wox_plugin_program_delete_program_source"), selectedProgramSource.Location);
|
||||
|
||||
if (MessageBox.Show(msg, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||
{
|
||||
ProgramStorage.Instance.ProgramSources.Remove(selectedProgramSource);
|
||||
ProgramStorage.Instance.Save();
|
||||
@ -65,7 +69,8 @@ namespace Wox.Plugin.Program
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Please select a program source");
|
||||
string msg = context.API.GetTranslation("wox_plugin_program_pls_select_program_source");
|
||||
MessageBox.Show(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +91,8 @@ namespace Wox.Plugin.Program
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Please select a program source");
|
||||
string msg = context.API.GetTranslation("wox_plugin_program_pls_select_program_source");
|
||||
MessageBox.Show(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,8 +103,7 @@ namespace Wox.Plugin.Program
|
||||
|
||||
private void BtnProgramSuffixes_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
ProgramSuffixes p = new ProgramSuffixes();
|
||||
ProgramSuffixes p = new ProgramSuffixes(context);
|
||||
p.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
@ -5,13 +5,13 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
Width="400"
|
||||
Height="170"
|
||||
Height="180"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
d:DesignHeight="400" d:DesignWidth="300">
|
||||
<StackPanel>
|
||||
<TextBlock Margin="10 10 0 0" Foreground="Gray">Wox will only index files that end with following suffixes.</TextBlock>
|
||||
<TextBlock Margin="10 0 0 0" Foreground="Gray">Each suffix should split by ;</TextBlock>
|
||||
<TextBlock Margin="10 10 0 0" Foreground="Gray" Text="{DynamicResource wox_plugin_program_only_index_tip}"></TextBlock>
|
||||
<TextBlock Margin="10 10 0 0" Foreground="Gray" Text="{DynamicResource wox_plugin_program_split_by_tip}"></TextBlock>
|
||||
<TextBox x:Name="tbSuffixes" Margin="10"/>
|
||||
<Button HorizontalAlignment="Right" Height="30" Width="80" Click="ButtonBase_OnClick" Margin="10">Update</Button>
|
||||
<Button HorizontalAlignment="Right" Height="30" Width="80" Click="ButtonBase_OnClick" Margin="10" Content="{DynamicResource wox_plugin_program_update}"></Button>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
|
@ -7,8 +7,11 @@ namespace Wox.Plugin.Program
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ namespace Wox.Plugin.Program
|
||||
|
||||
public System.Windows.Controls.Control CreateSettingPanel()
|
||||
{
|
||||
return new ProgramSetting();
|
||||
return new ProgramSetting(context);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -88,6 +88,11 @@
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Languages\zh-cn.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Page Include="ProgramSetting.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
@ -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,9 +37,12 @@ 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(
|
||||
((IPluginI18n)Activator.CreateInstance(pluginI18n)).GetLanguagesFolder());
|
||||
if (!string.IsNullOrEmpty(languageFile))
|
||||
{
|
||||
string languageFile = InternationalizationManager.Internationalization.GetLanguageFile(pluginI18n.GetLanguagesFolder());
|
||||
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary
|
||||
{
|
||||
Source = new Uri(languageFile, UriKind.Absolute)
|
||||
@ -48,3 +51,4 @@ namespace Wox.Core.UI
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,6 +36,8 @@ namespace Wox.Plugin
|
||||
|
||||
void ReloadPlugins();
|
||||
|
||||
string GetTranslation(string key);
|
||||
|
||||
List<PluginPair> GetAllPlugins();
|
||||
|
||||
event WoxKeyDownEventHandler BackKeyDownEvent;
|
||||
|
@ -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<PluginPair> GetAllPlugins()
|
||||
{
|
||||
return PluginManager.AllPlugins;
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user