Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/modules/launcher/PowerLauncher/Plugin/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,10 @@ public static void InitializePlugins(IPublicAPI api)

if (!failedPlugins.IsEmpty)
{
var failed = string.Join(", ", failedPlugins.Select(x => x.Metadata.Name));
string title = Resources.FailedToInitializePluginsTitle.ToString().Replace("{0}", Constant.Version);
var failed = string.Join(", ", failedPlugins.Select(x => $"{x.Metadata.Name} ({x.Metadata.ExecuteFileVersion})"));
var description = $"{string.Format(CultureInfo.CurrentCulture, FailedToInitializePluginsDescription, failed)}\n\n{Resources.FailedToInitializePluginsDescriptionPartTwo}";
Application.Current.Dispatcher.InvokeAsync(() => API.ShowMsg(Resources.FailedToInitializePluginsTitle, description, string.Empty, false));
Application.Current.Dispatcher.InvokeAsync(() => API.ShowMsg(title, description, string.Empty, false));
}
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
<value>Fail to initialize plugins: {0}</value>
</data>
<data name="FailedToInitializePluginsTitle" xml:space="preserve">
<value>PowerToys Run - Plugin Initialization Error</value>
<value>PowerToys Run {0} - Plugin Initialization Error</value>
<comment>Don't translate "PowerToys Run". This is a product name.</comment>
</data>
<data name="ContextMenuItemsAvailable" xml:space="preserve">
Expand Down
3 changes: 1 addition & 2 deletions src/modules/launcher/PowerLauncher/SettingsReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Abstractions;
using System.Linq;
Expand Down Expand Up @@ -252,7 +251,7 @@ private static IEnumerable<PowerLauncherPluginSettings> GetDefaultPluginsSetting
Id = x.Metadata.ID,
Name = x.Plugin == null ? x.Metadata.Name : x.Plugin.Name,
Description = x.Plugin?.Description,
Version = FileVersionInfo.GetVersionInfo(x.Metadata.ExecuteFilePath).FileVersion,
Version = x.Metadata.ExecuteFileVersion,
Author = x.Metadata.Author,
Website = x.Metadata.Website,
Disabled = x.Metadata.Disabled,
Expand Down
20 changes: 20 additions & 0 deletions src/modules/launcher/Wox.Plugin/PluginMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Diagnostics;
using System.IO;
using System.IO.Abstractions;
using System.Text.Json.Serialization;

Expand Down Expand Up @@ -42,6 +44,9 @@ public PluginMetadata()

public string ExecuteFileName { get; set; }

[JsonIgnore]
public string ExecuteFileVersion { get; private set; }

public string PluginDirectory
{
get
Expand All @@ -53,6 +58,7 @@ internal set
{
_pluginDirectory = value;
ExecuteFilePath = Path.Combine(value, ExecuteFileName);
SetExecutableVersion();
}
}

Expand Down Expand Up @@ -84,5 +90,19 @@ public override string ToString()

[JsonIgnore]
public int QueryCount { get; set; }

private void SetExecutableVersion()
{
// Using version from plugin metadata json as fallback
try
{
var v = FileVersionInfo.GetVersionInfo(ExecuteFilePath).FileVersion;
ExecuteFileVersion = (v is null or "0.0.0.0") ? Version : v;
}
catch (FileNotFoundException)
{
ExecuteFileVersion = Version;
}
}
}
}
5 changes: 3 additions & 2 deletions src/modules/launcher/Wox.Plugin/PluginPair.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ public void Update(PowerLauncherPluginSettings setting, IPublicAPI api, Action r

if (!IsPluginInitialized)
{
string description = $"{Resources.FailedToLoadPluginDescription} {Metadata.Name}\n\n{Resources.FailedToLoadPluginDescriptionPartTwo}";
Application.Current.Dispatcher.InvokeAsync(() => api.ShowMsg(Resources.FailedToLoadPluginTitle, description, string.Empty, false));
string title = Resources.FailedToLoadPluginTitle.ToString().Replace("{0}", Constant.Version);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use string.Format?

Copy link
Collaborator Author

@htcfreek htcfreek Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With string format it will require CompositFormat too. And this would make translation complicated and imo no sense if we don't have a constant.

string description = $"{Resources.FailedToLoadPluginDescription} {Metadata.Name} ({Metadata.ExecuteFileVersion})\n\n{Resources.FailedToLoadPluginDescriptionPartTwo}";
Application.Current.Dispatcher.InvokeAsync(() => api.ShowMsg(title, description, string.Empty, false));
}
}
else
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/modules/launcher/Wox.Plugin/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<comment>"https://aka.ms/powerToysReportBug" is a web uri.</comment>
</data>
<data name="FailedToLoadPluginTitle" xml:space="preserve">
<value>PowerToys Run - Plugin Loading Error</value>
<value>PowerToys Run {0} - Plugin Loading Error</value>
<comment>Don't translate "PowerToys Run". This is a product name.</comment>
</data>
<data name="VirtualDesktopHelper_AllDesktops" xml:space="preserve">
Expand Down
Loading