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

@ -2,6 +2,22 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib"> 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> </ResourceDictionary>

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

View File

@ -3,14 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 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" xmlns:program="clr-namespace:Wox.Plugin.Program"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="600"> d:DesignHeight="300" d:DesignWidth="600">
<UserControl.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVis" />
</UserControl.Resources>
<Grid Margin="10"> <Grid Margin="10">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="50"/> <RowDefinition Height="50"/>
@ -18,13 +13,13 @@
<RowDefinition Height="50"/> <RowDefinition Height="50"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right"> <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" 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">Re-Index</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> </StackPanel>
<ListView x:Name="programSourceView" Grid.Row="1"> <ListView x:Name="programSourceView" Grid.Row="1">
<ListView.View> <ListView.View>
<GridView> <GridView>
<GridViewColumn Header="Location" Width="400"> <GridViewColumn Header="{DynamicResource wox_plugin_program_location}" Width="400">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding Location, ConverterParameter=(null), Converter={program:StringEmptyConverter}}"/> <TextBlock Text="{Binding Location, ConverterParameter=(null), Converter={program:StringEmptyConverter}}"/>
@ -37,12 +32,12 @@
<DockPanel Grid.Row="2"> <DockPanel Grid.Row="2">
<StackPanel x:Name="indexingPanel" Visibility="Hidden" HorizontalAlignment="Left" Orientation="Horizontal"> <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> <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>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> <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="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="Edit"/> <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="Add"/> <Button x:Name="btnAddProgramSource" Click="btnAddProgramSource_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_program_add}"/>
</StackPanel> </StackPanel>
</DockPanel> </DockPanel>
</Grid> </Grid>

View File

@ -10,8 +10,11 @@ namespace Wox.Plugin.Program
/// </summary> /// </summary>
public partial class ProgramSetting : UserControl public partial class ProgramSetting : UserControl
{ {
public ProgramSetting() private PluginInitContext context;
public ProgramSetting(PluginInitContext context)
{ {
this.context = context;
InitializeComponent(); InitializeComponent();
Loaded += Setting_Loaded; Loaded += Setting_Loaded;
} }
@ -55,8 +58,9 @@ namespace Wox.Plugin.Program
ProgramSource selectedProgramSource = programSourceView.SelectedItem as ProgramSource; ProgramSource selectedProgramSource = programSourceView.SelectedItem as ProgramSource;
if (selectedProgramSource != null) if (selectedProgramSource != null)
{ {
if (MessageBox.Show("Are your sure to delete " + selectedProgramSource.Location, "Delete ProgramSource", string msg = string.Format(context.API.GetTranslation("wox_plugin_program_delete_program_source"), selectedProgramSource.Location);
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
if (MessageBox.Show(msg, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{ {
ProgramStorage.Instance.ProgramSources.Remove(selectedProgramSource); ProgramStorage.Instance.ProgramSources.Remove(selectedProgramSource);
ProgramStorage.Instance.Save(); ProgramStorage.Instance.Save();
@ -65,7 +69,8 @@ namespace Wox.Plugin.Program
} }
else 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 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) private void BtnProgramSuffixes_OnClick(object sender, RoutedEventArgs e)
{ {
ProgramSuffixes p = new ProgramSuffixes(context);
ProgramSuffixes p = new ProgramSuffixes();
p.ShowDialog(); p.ShowDialog();
} }
} }

View File

@ -5,13 +5,13 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" mc:Ignorable="d"
Width="400" Width="400"
Height="170" Height="180"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
d:DesignHeight="400" d:DesignWidth="300"> d:DesignHeight="400" d:DesignWidth="300">
<StackPanel> <StackPanel>
<TextBlock Margin="10 10 0 0" Foreground="Gray">Wox will only index files that end with following suffixes.</TextBlock> <TextBlock Margin="10 10 0 0" Foreground="Gray" Text="{DynamicResource wox_plugin_program_only_index_tip}"></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_split_by_tip}"></TextBlock>
<TextBox x:Name="tbSuffixes" Margin="10"/> <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> </StackPanel>
</Window> </Window>

View File

@ -7,8 +7,11 @@ namespace Wox.Plugin.Program
/// </summary> /// </summary>
public partial class ProgramSuffixes public partial class ProgramSuffixes
{ {
public ProgramSuffixes() private PluginInitContext context;
public ProgramSuffixes(PluginInitContext context)
{ {
this.context = context;
InitializeComponent(); InitializeComponent();
tbSuffixes.Text = ProgramStorage.Instance.ProgramSuffixes; tbSuffixes.Text = ProgramStorage.Instance.ProgramSuffixes;
@ -18,12 +21,14 @@ namespace Wox.Plugin.Program
{ {
if (string.IsNullOrEmpty(tbSuffixes.Text)) 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; return;
} }
ProgramStorage.Instance.ProgramSuffixes = tbSuffixes.Text; 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);
} }
} }
} }

View File

@ -178,7 +178,7 @@ namespace Wox.Plugin.Program
public System.Windows.Controls.Control CreateSettingPanel() public System.Windows.Controls.Control CreateSettingPanel()
{ {
return new ProgramSetting(); return new ProgramSetting(context);
} }
#endregion #endregion

View File

@ -1,126 +1,131 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FDB3555B-58EF-4AE6-B5F1-904719637AB4}</ProjectGuid> <ProjectGuid>{FDB3555B-58EF-4AE6-B5F1-904719637AB4}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Wox.Plugin.Program</RootNamespace> <RootNamespace>Wox.Plugin.Program</RootNamespace>
<AssemblyName>Wox.Plugin.Program</AssemblyName> <AssemblyName>Wox.Plugin.Program</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages> <RestorePackages>true</RestorePackages>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>..\..\Output\Debug\Plugins\Wox.Plugin.Program\</OutputPath> <OutputPath>..\..\Output\Debug\Plugins\Wox.Plugin.Program\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net"> <Reference Include="log4net">
<HintPath>..\..\packages\log4net.2.0.3\lib\net35-full\log4net.dll</HintPath> <HintPath>..\..\packages\log4net.2.0.3\lib\net35-full\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll</HintPath> <HintPath>..\..\packages\Newtonsoft.Json.6.0.7\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="FileChangeWatcher.cs" /> <Compile Include="FileChangeWatcher.cs" />
<Compile Include="IProgramSource.cs" /> <Compile Include="IProgramSource.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="ProgramCacheStorage.cs" /> <Compile Include="ProgramCacheStorage.cs" />
<Compile Include="Programs.cs" /> <Compile Include="Programs.cs" />
<Compile Include="ProgramSetting.xaml.cs"> <Compile Include="ProgramSetting.xaml.cs">
<DependentUpon>ProgramSetting.xaml</DependentUpon> <DependentUpon>ProgramSetting.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="ProgramSource.cs" /> <Compile Include="ProgramSource.cs" />
<Compile Include="ProgramSources\AppPathsProgramSource.cs" /> <Compile Include="ProgramSources\AppPathsProgramSource.cs" />
<Compile Include="ProgramSources\CommonStartMenuProgramSource.cs" /> <Compile Include="ProgramSources\CommonStartMenuProgramSource.cs" />
<Compile Include="ProgramSources\FileSystemProgramSource.cs" /> <Compile Include="ProgramSources\FileSystemProgramSource.cs" />
<Compile Include="ProgramSources\UserStartMenuProgramSource.cs" /> <Compile Include="ProgramSources\UserStartMenuProgramSource.cs" />
<Compile Include="ProgramStorage.cs" /> <Compile Include="ProgramStorage.cs" />
<Compile Include="ProgramSuffixes.xaml.cs"> <Compile Include="ProgramSuffixes.xaml.cs">
<DependentUpon>ProgramSuffixes.xaml</DependentUpon> <DependentUpon>ProgramSuffixes.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="StringEmptyConverter.cs" /> <Compile Include="StringEmptyConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="plugin.json"> <None Include="plugin.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Images\program.png"> <None Include="Images\program.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<Content Include="Languages\en.xaml"> <Content Include="Languages\en.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Page Include="ProgramSetting.xaml"> <None Include="Languages\zh-cn.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Page Include="ProgramSuffixes.xaml"> </None>
<Generator>MSBuild:Compile</Generator> <Page Include="ProgramSetting.xaml">
<SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator>
</Page> <SubType>Designer</SubType>
</ItemGroup> </Page>
<ItemGroup> <Page Include="ProgramSuffixes.xaml">
<ProjectReference Include="..\..\Wox.Infrastructure\Wox.Infrastructure.csproj"> <Generator>MSBuild:Compile</Generator>
<Project>{4fd29318-a8ab-4d8f-aa47-60bc241b8da3}</Project> <SubType>Designer</SubType>
<Name>Wox.Infrastructure</Name> </Page>
</ProjectReference> </ItemGroup>
<ProjectReference Include="..\..\Wox.Plugin\Wox.Plugin.csproj"> <ItemGroup>
<Project>{8451ecdd-2ea4-4966-bb0a-7bbc40138e80}</Project> <ProjectReference Include="..\..\Wox.Infrastructure\Wox.Infrastructure.csproj">
<Name>Wox.Plugin</Name> <Project>{4fd29318-a8ab-4d8f-aa47-60bc241b8da3}</Project>
</ProjectReference> <Name>Wox.Infrastructure</Name>
</ItemGroup> </ProjectReference>
<ItemGroup /> <ProjectReference Include="..\..\Wox.Plugin\Wox.Plugin.csproj">
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Project>{8451ecdd-2ea4-4966-bb0a-7bbc40138e80}</Project>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> <Name>Wox.Plugin</Name>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> </ProjectReference>
<PropertyGroup> </ItemGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText> <ItemGroup />
</PropertyGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" /> <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
</Target> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <PropertyGroup>
Other similar extension points exist, see Microsoft.Common.targets. <ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
<Target Name="BeforeBuild"> </PropertyGroup>
</Target> <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
<Target Name="AfterBuild"> </Target>
</Target> <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
--> Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project> </Project>

View File

@ -12,8 +12,8 @@ namespace Wox.Core.UI
public static void ApplyResources() public static void ApplyResources()
{ {
Application.Current.Resources.MergedDictionaries.Clear(); Application.Current.Resources.MergedDictionaries.Clear();
ApplyUIResources();
ApplyPluginLanguages(); ApplyPluginLanguages();
ApplyUIResources();
} }
private static void ApplyUIResources() private static void ApplyUIResources()
@ -37,13 +37,17 @@ namespace Wox.Core.UI
.SelectMany(s => s.GetTypes()) .SelectMany(s => s.GetTypes())
.Where(p => p.IsClass && !p.IsAbstract && pluginI18nType.IsAssignableFrom(p)); .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()); string languageFile = InternationalizationManager.Internationalization.GetLanguageFile(
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary ((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> /// <summary>
/// Get language file for current user selected language /// 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 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> /// </summary>
/// <param name="folder"></param> /// <param name="folder"></param>
/// <returns></returns> /// <returns></returns>

View File

@ -137,16 +137,8 @@ namespace Wox.Core.i18n
{ {
return english; 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;
}
} }
} }

View File

@ -36,6 +36,8 @@ namespace Wox.Plugin
void ReloadPlugins(); void ReloadPlugins();
string GetTranslation(string key);
List<PluginPair> GetAllPlugins(); List<PluginPair> GetAllPlugins();
event WoxKeyDownEventHandler BackKeyDownEvent; event WoxKeyDownEventHandler BackKeyDownEvent;

View File

@ -132,6 +132,11 @@ namespace Wox
Dispatcher.Invoke(new Action(() => PluginManager.Init(this))); Dispatcher.Invoke(new Action(() => PluginManager.Init(this)));
} }
public string GetTranslation(string key)
{
return InternationalizationManager.Internationalization.GetTranslation(key);
}
public List<PluginPair> GetAllPlugins() public List<PluginPair> GetAllPlugins()
{ {
return PluginManager.AllPlugins; return PluginManager.AllPlugins;

View File

@ -482,7 +482,7 @@ namespace Wox
pluginTitle.Text = pair.Metadata.Name; pluginTitle.Text = pair.Metadata.Name;
pluginTitle.Cursor = Cursors.Hand; pluginTitle.Cursor = Cursors.Hand;
pluginActionKeyword.Text = pair.Metadata.ActionKeyword; 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; pluginSubTitle.Text = pair.Metadata.Description;
pluginId = pair.Metadata.ID; pluginId = pair.Metadata.ID;
pluginIcon.Source = ImageLoader.ImageLoader.Load(pair.Metadata.FullIcoPath); pluginIcon.Source = ImageLoader.ImageLoader.Load(pair.Metadata.FullIcoPath);
@ -509,8 +509,6 @@ namespace Wox
control.Width = Double.NaN; control.Width = Double.NaN;
control.Height = Double.NaN; control.Height = Double.NaN;
} }
// featureControls
// throw new NotImplementedException();
} }
private void CbDisablePlugin_OnClick(object sender, RoutedEventArgs e) private void CbDisablePlugin_OnClick(object sender, RoutedEventArgs e)