[PT Run] [Program plugin] Add localized name (#19149)

* create common localization class

* add loc name to prog plugin

* fixes

* Tool tip fixes and comments

* cleanup and highlight fix

* change

* Improvements

* Add GetLocalizedPath()

* smal code improvements
This commit is contained in:
Heiko
2022-07-20 16:11:33 +02:00
committed by GitHub
parent 28751d2d36
commit e11bafcc93
3 changed files with 106 additions and 3 deletions

View File

@@ -19,6 +19,7 @@ using Microsoft.Win32;
using Wox.Infrastructure;
using Wox.Infrastructure.FileSystemHelper;
using Wox.Plugin;
using Wox.Plugin.Common;
using Wox.Plugin.Logger;
using DirectoryWrapper = Wox.Infrastructure.FileSystemHelper.DirectoryWrapper;
@@ -46,6 +47,9 @@ namespace Microsoft.Plugin.Program.Programs
public string LnkResolvedExecutableName { get; set; }
// Localized name based on windows display language
public string LocalizedName { get; set; } = string.Empty;
public string ParentDirectory { get; set; }
public string ExecutableName { get; set; }
@@ -97,10 +101,11 @@ namespace Microsoft.Plugin.Program.Programs
private int Score(string query)
{
var nameMatch = StringMatcher.FuzzySearch(query, Name);
var locNameMatch = StringMatcher.FuzzySearch(query, LocalizedName);
var descriptionMatch = StringMatcher.FuzzySearch(query, Description);
var executableNameMatch = StringMatcher.FuzzySearch(query, ExecutableName);
var lnkResolvedExecutableNameMatch = StringMatcher.FuzzySearch(query, LnkResolvedExecutableName);
var score = new[] { nameMatch.Score, descriptionMatch.Score / 2, executableNameMatch.Score, lnkResolvedExecutableNameMatch.Score }.Max();
var score = new[] { nameMatch.Score, locNameMatch.Score, descriptionMatch.Score / 2, executableNameMatch.Score, lnkResolvedExecutableNameMatch.Score }.Max();
return score;
}
@@ -221,7 +226,7 @@ namespace Microsoft.Plugin.Program.Programs
var result = new Result
{
// To set the title for the result to always be the name of the application
Title = Name,
Title = !string.IsNullOrEmpty(LocalizedName) ? LocalizedName : Name,
SubTitle = GetSubtitle(),
IcoPath = IcoPath,
Score = score,
@@ -237,7 +242,7 @@ namespace Microsoft.Plugin.Program.Programs
},
};
result.TitleHighlightData = StringMatcher.FuzzySearch(query, Name).MatchData;
result.TitleHighlightData = StringMatcher.FuzzySearch(query, result.Title).MatchData;
// Using CurrentCulture since this is user facing
var toolTipTitle = string.Format(CultureInfo.CurrentCulture, "{0}: {1}", Properties.Resources.powertoys_run_plugin_program_file_name, result.Title);
@@ -370,6 +375,9 @@ namespace Microsoft.Plugin.Program.Programs
ExecutableName = Path.GetFileName(path),
IcoPath = path,
// Localized name based on windows display language
LocalizedName = ShellLocalization.GetLocalizedName(path),
// Using InvariantCulture since this is user facing
FullPath = path.ToLowerInvariant(),
UniqueIdentifier = path,