diff --git a/Flow.Launcher.Avalonia/App.axaml.cs b/Flow.Launcher.Avalonia/App.axaml.cs index 14919a92c..4afb52982 100644 --- a/Flow.Launcher.Avalonia/App.axaml.cs +++ b/Flow.Launcher.Avalonia/App.axaml.cs @@ -36,6 +36,10 @@ public partial class App : Application ConfigureDI(); AvaloniaXamlLoader.Load(this); + + // Inject translations into Application.Resources for DynamicResource bindings in plugins + var i18n = Ioc.Default.GetRequiredService(); + i18n.InjectIntoApplicationResources(); } public override void OnFrameworkInitializationCompleted() diff --git a/Flow.Launcher.Avalonia/Resource/Internationalization.cs b/Flow.Launcher.Avalonia/Resource/Internationalization.cs index 0705eca14..c783714f7 100644 --- a/Flow.Launcher.Avalonia/Resource/Internationalization.cs +++ b/Flow.Launcher.Avalonia/Resource/Internationalization.cs @@ -201,6 +201,37 @@ public class Internationalization Log.Debug(ClassName, $"Parsed {count} strings from {filePath}"); } + /// + /// Inject all translations into Avalonia's Application.Resources so {DynamicResource} works. + /// This enables plugin settings to use {DynamicResource key} for localization. + /// Must be called after Application is initialized. + /// + public void InjectIntoApplicationResources() + { + try + { + var app = Application.Current; + if (app == null) + { + Log.Warn(ClassName, "Cannot inject resources: Application.Current is null"); + return; + } + + var count = 0; + foreach (var kvp in _translations) + { + app.Resources[kvp.Key] = kvp.Value; + count++; + } + + Log.Info(ClassName, $"Injected {count} translations into Application.Resources"); + } + catch (Exception e) + { + Log.Exception(ClassName, "Failed to inject translations into Application.Resources", e); + } + } + /// /// Get a translated string by key. /// @@ -208,12 +239,10 @@ public class Internationalization { if (_translations.TryGetValue(key, out var translation)) { - Log.Debug(ClassName, $"Translation found for '{key}': '{translation}'"); return translation; } Log.Warn(ClassName, $"Translation not found for key: {key}"); - Log.Debug(ClassName, $"Available keys (first 20): {string.Join(", ", _translations.Keys.Take(20))}"); return $"[{key}]"; } @@ -260,6 +289,10 @@ public class Internationalization } ChangeCultureInfo(languageCode); + + // Re-inject into Application.Resources for DynamicResource bindings + InjectIntoApplicationResources(); + Log.Info(ClassName, $"Language changed to: {languageCode}"); } } diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj index 8249b354a..03ff64eb6 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj @@ -1,4 +1,4 @@ - + Library @@ -108,6 +108,19 @@ + + + + + + ..\..\Output\$(Configuration)\Avalonia\Plugins\$(AssemblyName)\ + + + + + + + diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs index 07ce510fb..2545dabbc 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -10,6 +10,7 @@ using Flow.Launcher.Plugin.BrowserBookmark.Commands; using Flow.Launcher.Plugin.BrowserBookmark.Models; using Flow.Launcher.Plugin.BrowserBookmark.Views; using Flow.Launcher.Plugin.SharedCommands; +using AvaloniaControl = Avalonia.Controls.Control; namespace Flow.Launcher.Plugin.BrowserBookmark; @@ -225,6 +226,11 @@ public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContex return new SettingsControl(_settings); } + public AvaloniaControl CreateSettingPanelAvalonia() + { + return new Views.Avalonia.SettingsControl(_settings); + } + public List LoadContextMenus(Result selectedResult) { return new List() diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/Avalonia/CustomBrowserSettingWindow.axaml b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/Avalonia/CustomBrowserSettingWindow.axaml new file mode 100644 index 000000000..8015eb927 --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/Avalonia/CustomBrowserSettingWindow.axaml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + +