mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
PluginSystem: fix plugin translations not properly reloading
This commit is contained in:
@@ -104,17 +104,20 @@ Singleton {
|
||||
|
||||
// Reload translations for all loaded plugins
|
||||
for (var pluginId in root.loadedPlugins) {
|
||||
var plugin = root.loadedPlugins[pluginId];
|
||||
if (plugin && plugin.api && plugin.manifest) {
|
||||
// Update current language
|
||||
plugin.api.currentLanguage = I18n.langCode;
|
||||
// Use IIFE to capture current loop values (avoid closure bug)
|
||||
(function (id, plugin) {
|
||||
if (plugin && plugin.api && plugin.manifest) {
|
||||
// Update current language
|
||||
plugin.api.currentLanguage = I18n.langCode;
|
||||
|
||||
// Reload translations
|
||||
loadPluginTranslationsAsync(pluginId, plugin.manifest, I18n.langCode, function (translations) {
|
||||
plugin.api.pluginTranslations = translations;
|
||||
Logger.d("PluginService", "Reloaded translations for plugin:", pluginId);
|
||||
});
|
||||
}
|
||||
// Reload translations
|
||||
loadPluginTranslationsAsync(id, plugin.manifest, I18n.langCode, function (translations) {
|
||||
plugin.api.pluginTranslations = translations;
|
||||
plugin.api.translationVersion++;
|
||||
Logger.d("PluginService", "Reloaded translations for plugin:", id);
|
||||
});
|
||||
}
|
||||
})(pluginId, root.loadedPlugins[pluginId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -872,6 +875,7 @@ Singleton {
|
||||
// Translation storage
|
||||
property var pluginTranslations: ({})
|
||||
property string currentLanguage: ""
|
||||
property int translationVersion: 0 // Increments when translations change - plugins should depend on this
|
||||
|
||||
// Functions will be bound below
|
||||
property var saveSettings: null
|
||||
|
||||
@@ -102,6 +102,8 @@ Popup {
|
||||
}
|
||||
|
||||
onClosed: {
|
||||
// Clear both source and sourceComponent to ensure full cleanup
|
||||
settingsLoader.sourceComponent = null;
|
||||
settingsLoader.source = "";
|
||||
currentPlugin = null;
|
||||
currentPluginApi = null;
|
||||
@@ -125,10 +127,8 @@ Popup {
|
||||
// Get plugin directory
|
||||
var pluginDir = PluginRegistry.getPluginDir(pluginId);
|
||||
var settingsPath = pluginDir + "/" + pluginManifest.entryPoints.settings;
|
||||
var loadVersion = PluginRegistry.pluginLoadVersions[pluginId] || 0;
|
||||
|
||||
// Load settings component (use version counter to avoid caching)
|
||||
settingsLoader.setSource("file://" + settingsPath + "?v=" + loadVersion, {
|
||||
settingsLoader.setSource("file://" + settingsPath, {
|
||||
"pluginApi": currentPluginApi
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user