add international language support

This commit is contained in:
Jeremy Wu 2020-06-08 20:31:48 +10:00
parent 82cfddbdb3
commit d23fe3943a
12 changed files with 189 additions and 28 deletions

View file

@ -38,7 +38,7 @@ namespace Flow.Launcher.Plugin.Explorer
contextMenus.Add(CreateOpenContainingFolderResult(record));
contextMenus.Add(CreateOpenWindowsIndexingOptions(record));
contextMenus.Add(CreateOpenWindowsIndexingOptions());
if (record.ShowIndexState)
contextMenus.Add(new Result {Title = "From index search: " + (record.WindowsIndexed ? "Yes" : "No"),
@ -49,7 +49,7 @@ namespace Flow.Launcher.Plugin.Explorer
var fileOrFolder = (record.Type == ResultType.File) ? "file" : "folder";
contextMenus.Add(new Result
{
Title = "Copy path",
Title = Context.API.GetTranslation("plugin_explorer_copypath"),
SubTitle = $"Copy the current {fileOrFolder} path to clipboard",
Action = (context) =>
{
@ -71,7 +71,7 @@ namespace Flow.Launcher.Plugin.Explorer
contextMenus.Add(new Result
{
Title = $"Copy {fileOrFolder}",
Title = Context.API.GetTranslation("plugin_explorer_copyfilefolder") + $" {fileOrFolder}",
SubTitle = $"Copy the {fileOrFolder} to clipboard",
Action = (context) =>
{
@ -95,8 +95,8 @@ namespace Flow.Launcher.Plugin.Explorer
if (record.Type == ResultType.File || record.Type == ResultType.Folder)
contextMenus.Add(new Result
{
Title = $"Delete {fileOrFolder}",
SubTitle = $"Delete the selected {fileOrFolder}",
Title = Context.API.GetTranslation("plugin_explorer_deletefilefolder") + $" {fileOrFolder}",
SubTitle = Context.API.GetTranslation("plugin_explorer_deletefilefolder_subtitle") + $" {fileOrFolder}",
Action = (context) =>
{
try
@ -122,7 +122,8 @@ namespace Flow.Launcher.Plugin.Explorer
if (record.Type == ResultType.File && CanRunAsDifferentUser(record.FullPath))
contextMenus.Add(new Result
{
Title = "Run as different user",
Title = Context.API.GetTranslation("plugin_explorer_runasdifferentuser"),
SubTitle = Context.API.GetTranslation("plugin_explorer_runasdifferentuser_subtitle"),
Action = (context) =>
{
try
@ -149,8 +150,8 @@ namespace Flow.Launcher.Plugin.Explorer
{
return new Result
{
Title = "Open containing folder",
SubTitle = "Opens the location that contains the file or folder",
Title = Context.API.GetTranslation("plugin_explorer_opencontainingfolder"),
SubTitle = Context.API.GetTranslation("plugin_explorer_opencontainingfolder_subtitle"),
Action = _ =>
{
try
@ -173,9 +174,11 @@ namespace Flow.Launcher.Plugin.Explorer
private Result CreateOpenWithEditorResult(SearchResult record)
{
string editorPath = "notepad.exe"; // TODO add the ability to create a custom editor
string editorPath = "Notepad.exe"; // TODO add the ability to create a custom editor
var name = Context.API.GetTranslation("plugin_explorer_openwitheditor")
+ " " + Path.GetFileNameWithoutExtension(editorPath);
var name = "Open With Editor: " + Path.GetFileNameWithoutExtension(editorPath);
return new Result
{
Title = name,
@ -202,8 +205,8 @@ namespace Flow.Launcher.Plugin.Explorer
{
return new Result
{
Title = "Exclude current and sub-directories from index search",
SubTitle = "Path: " + record.FullPath,
Title = Context.API.GetTranslation("plugin_explorer_excludefromindexsearch"),
SubTitle = Context.API.GetTranslation("plugin_explorer_path") + " " + record.FullPath,
Action = _ =>
{
if(!Settings.IndexSearchExcludedSubdirectoryPaths.Any(x => x.Path == record.FullPath))
@ -215,7 +218,9 @@ namespace Flow.Launcher.Plugin.Explorer
Task.Run(() =>
{
Context.API.ShowMsg("Excluded from Index Search", "Path: " + record.FullPath, iconPath);
Context.API.ShowMsg(Context.API.GetTranslation("plugin_explorer_excludedfromindexsearch_msg"),
Context.API.GetTranslation("plugin_explorer_path") +
" " + record.FullPath, iconPath);
// so the new path can be persisted to storage and not wait till next ViewModel save.
Context.API.SaveAppAllSettings();
@ -227,12 +232,12 @@ namespace Flow.Launcher.Plugin.Explorer
};
}
private Result CreateOpenWindowsIndexingOptions(SearchResult record)
private Result CreateOpenWindowsIndexingOptions()
{
return new Result
{
Title = "Open Windows Indexing Options",
SubTitle = "Manage indexed files and folders",
Title = Context.API.GetTranslation("plugin_explorer_openindexingoptions"),
SubTitle = Context.API.GetTranslation("plugin_explorer_openindexingoptions_subtitle"),
Action = _ =>
{
try
@ -249,7 +254,7 @@ namespace Flow.Launcher.Plugin.Explorer
}
catch (Exception e)
{
var message = $"Failed to open Windows Indexing Options";
var message = Context.API.GetTranslation("plugin_explorer_openindexingoptions_errormsg");
LogException(message, e);
Context.API.ShowMsg(message);
return false;

View file

@ -60,6 +60,42 @@
<None Include="Images\windowsindexingoptions.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="Languages\en.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Languages\zh-cn.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Languages\zh-tw.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Languages\de.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Languages\pl.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Languages\tr.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>

View file

@ -0,0 +1,14 @@
<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">
<!--Controls-->
<system:String x:Key="plugin_explorer_delete">Löschen</system:String>
<system:String x:Key="plugin_explorer_edit">Bearbeiten</system:String>
<system:String x:Key="plugin_explorer_add">Hinzufügen</system:String>
<!--Dialogues-->
<system:String x:Key="plugin_explorer_select_folder_link_warning">Bitte wähle eine Ordnerverknüpfung</system:String>
<system:String x:Key="plugin_explorer_delete_folder_link">Bist du sicher {0} zu löschen?</system:String>
</ResourceDictionary>

View file

@ -0,0 +1,39 @@
<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">
<!--Dialogues-->
<system:String x:Key="plugin_explorer_select_folder_link_warning">Please select a folder link</system:String>
<system:String x:Key="plugin_explorer_delete_folder_link">Are you sure you want to delete {0}?</system:String>
<!--Controls-->
<system:String x:Key="plugin_explorer_delete">Delete</system:String>
<system:String x:Key="plugin_explorer_edit">Edit</system:String>
<system:String x:Key="plugin_explorer_add">Add</system:String>
<system:String x:Key="plugin_explorer_quickfolderaccess_header">Quick Folder Access Paths</system:String>
<system:String x:Key="plugin_explorer_indexsearchexcludedpaths_header">Index Search Excluded Paths</system:String>
<system:String x:Key="plugin_explorer_manageindexoptions">Indexing Options</system:String>
<!--Plugin Infos-->
<system:String x:Key="plugin_explorer_plugin_name">Explorer</system:String>
<system:String x:Key="plugin_explorer_plugin_description">Search and manage files and folders. Explorer utilises Windows Index Search</system:String>
<!--Context menu items-->
<system:String x:Key="plugin_explorer_copypath">Copy path</system:String>
<system:String x:Key="plugin_explorer_copyfilefolder">Copy</system:String>
<system:String x:Key="plugin_explorer_deletefilefolder">Delete</system:String>
<system:String x:Key="plugin_explorer_path">Path:</system:String>
<system:String x:Key="plugin_explorer_deletefilefolder_subtitle">Delete the selected</system:String>
<system:String x:Key="plugin_explorer_runasdifferentuser">Run as different user</system:String>
<system:String x:Key="plugin_explorer_runasdifferentuser_subtitle">Run the selected using a different user account</system:String>
<system:String x:Key="plugin_explorer_opencontainingfolder">Open containing folder</system:String>
<system:String x:Key="plugin_explorer_opencontainingfolder_subtitle">Opens the location that contains the file or folder</system:String>
<system:String x:Key="plugin_explorer_openwitheditor">Open With Editor:</system:String>
<system:String x:Key="plugin_explorer_excludefromindexsearch">Exclude current and sub-directories from index search</system:String>
<system:String x:Key="plugin_explorer_excludedfromindexsearch_msg">Excluded from Index Search</system:String>
<system:String x:Key="plugin_explorer_openindexingoptions">Open Windows Indexing Options</system:String>
<system:String x:Key="plugin_explorer_openindexingoptions_subtitle">Manage indexed files and folders</system:String>
<system:String x:Key="plugin_explorer_openindexingoptions_errormsg">Failed to open Windows Indexing Options</system:String>
</ResourceDictionary>

View file

@ -0,0 +1,14 @@
<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">
<!--Controls-->
<system:String x:Key="plugin_explorer_delete">Usuń</system:String>
<system:String x:Key="plugin_explorer_edit">Edytuj</system:String>
<system:String x:Key="plugin_explorer_add">Dodaj</system:String>
<!--Dialogues-->
<system:String x:Key="plugin_explorer_select_folder_link_warning">Musisz wybrać któryś folder z listy</system:String>
<system:String x:Key="plugin_explorer_delete_folder_link">Czy jesteś pewien że chcesz usunąć {0}?</system:String>
</ResourceDictionary>

View file

@ -0,0 +1,14 @@
<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">
<!--Controls-->
<system:String x:Key="plugin_explorer_delete">Sil</system:String>
<system:String x:Key="plugin_explorer_edit">Düzenle</system:String>
<system:String x:Key="plugin_explorer_add">Ekle</system:String>
<!--Dialogues-->
<system:String x:Key="plugin_explorer_select_folder_link_warning">Lütfen bir klasör bağlantısı seçin</system:String>
<system:String x:Key="plugin_explorer_delete_folder_link">{0} bağlantısını silmek istediğinize emin misiniz?</system:String>
</ResourceDictionary>

View file

@ -0,0 +1,14 @@
<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">
<!--Controls-->
<system:String x:Key="plugin_explorer_delete">删除</system:String>
<system:String x:Key="plugin_explorer_edit">编辑</system:String>
<system:String x:Key="plugin_explorer_add">添加</system:String>
<!--Dialogues-->
<system:String x:Key="plugin_explorer_select_folder_link_warning">请选择一个文件夹</system:String>
<system:String x:Key="plugin_explorer_delete_folder_link">你确定要删除{0}吗?</system:String>
</ResourceDictionary>

View file

@ -0,0 +1,14 @@
<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">
<!--Controls-->
<system:String x:Key="plugin_explorer_delete">刪除</system:String>
<system:String x:Key="plugin_explorer_edit">編輯</system:String>
<system:String x:Key="plugin_explorer_add">新增</system:String>
<!--Dialogues-->
<system:String x:Key="plugin_explorer_select_folder_link_warning">請選擇一個資料夾</system:String>
<system:String x:Key="plugin_explorer_delete_folder_link">你確認要刪除{0}嗎?</system:String>
</ResourceDictionary>

View file

@ -7,7 +7,7 @@ using System.Windows.Controls;
namespace Flow.Launcher.Plugin.Explorer
{
public class Main : ISettingProvider, IPlugin, ISavable, IContextMenu //, IPluginI18n <=== do later
public class Main : ISettingProvider, IPlugin, ISavable, IContextMenu, IPluginI18n
{
internal PluginInitContext Context { get; set; }
@ -49,5 +49,15 @@ namespace Flow.Launcher.Plugin.Explorer
{
viewModel.Save();
}
public string GetTranslatedPluginTitle()
{
return Context.API.GetTranslation("plugin_explorer_plugin_name");
}
public string GetTranslatedPluginDescription()
{
return Context.API.GetTranslation("plugin_explorer_plugin_description");
}
}
}

View file

@ -25,7 +25,7 @@
</Grid.RowDefinitions>
<ScrollViewer Margin="20 35 0 0" HorizontalScrollBarVisibility="Hidden" Grid.Row="0" VerticalScrollBarVisibility="Auto">
<StackPanel>
<Expander Name="expFolderLinks" Header="Quick Folder Access Paths"
<Expander Name="expFolderLinks" Header="{DynamicResource plugin_explorer_quickfolderaccess_header}"
Expanded="expFolderLinks_Click" Collapsed="expFolderLinks_Click">
<ListView
x:Name="lbxFolderLinks" AllowDrop="True"
@ -33,7 +33,7 @@
DragEnter="lbxFolders_DragEnter"
ItemTemplate="{StaticResource ListViewTemplateFolderLinks}"/>
</Expander>
<Expander x:Name="expExcludedPaths" Header="Index Search Excluded Paths"
<Expander x:Name="expExcludedPaths" Header="{DynamicResource plugin_explorer_indexsearchexcludedpaths_header}"
Expanded="expExcludedPaths_Click" Collapsed="expExcludedPaths_Click"
Margin="0 10 0 0">
<ListView
@ -50,12 +50,13 @@
<ColumnDefinition Width="350"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left" Orientation="Horizontal">
<Button x:Name="btnIndexingOptions" Click="btnOpenIndexingOptions_Click" Width="130" Margin="10" Content="Indexing Options"/>
<Button x:Name="btnIndexingOptions" Click="btnOpenIndexingOptions_Click" Width="130" Margin="10"
Content="{DynamicResource plugin_explorer_manageindexoptions}"/>
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal">
<Button x:Name="btnDelete" Click="btnDelete_Click" Width="100" Margin="10" Content="{DynamicResource flowlauncher_plugin_folder_delete}"/>
<Button x:Name="btnEdit" Click="btnEdit_Click" Width="100" Margin="10" Content="{DynamicResource flowlauncher_plugin_folder_edit}"/>
<Button x:Name="btnAdd" Click="btnAdd_Click" Width="100" Margin="10" Content="{DynamicResource flowlauncher_plugin_folder_add}"/>
<Button x:Name="btnDelete" Click="btnDelete_Click" Width="100" Margin="10" Content="{DynamicResource plugin_explorer_delete}"/>
<Button x:Name="btnEdit" Click="btnEdit_Click" Width="100" Margin="10" Content="{DynamicResource plugin_explorer_edit}"/>
<Button x:Name="btnAdd" Click="btnAdd_Click" Width="100" Margin="10" Content="{DynamicResource plugin_explorer_add}"/>
</StackPanel>
</Grid>
</Grid>

View file

@ -110,7 +110,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
if (selectedRow != null)
{
string msg = string.Format(viewModel.Context.API.GetTranslation("flowlauncher_plugin_folder_delete_folder_link"), selectedRow.Path);
string msg = string.Format(viewModel.Context.API.GetTranslation("plugin_explorer_delete_folder_link"), selectedRow.Path);
if (MessageBox.Show(msg, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
@ -125,7 +125,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
}
else
{
string warning = viewModel.Context.API.GetTranslation("flowlauncher_plugin_folder_select_folder_link_warning");
string warning = viewModel.Context.API.GetTranslation("plugin_explorer_select_folder_link_warning");
MessageBox.Show(warning);
}
}
@ -157,7 +157,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
}
else
{
string warning = viewModel.Context.API.GetTranslation("flowlauncher_plugin_folder_select_folder_link_warning");
string warning = viewModel.Context.API.GetTranslation("plugin_explorer_select_folder_link_warning");
MessageBox.Show(warning);
}
}

View file

@ -2,7 +2,7 @@
"ID": "572be03c74c642baae319fc283e561a8",
"ActionKeyword": "*",
"Name": "Explorer",
"Description": "Search for and manage files and folders. Explorer utilises Windows Index Search",
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
"Author": "Jeremy Wu",
"Version": "1.0.0",
"Language": "csharp",