diff --git a/app/MindWork AI Studio/Tools/PluginSystem/PluginBase.cs b/app/MindWork AI Studio/Tools/PluginSystem/PluginBase.cs
index 378cf7f3..4f719d18 100644
--- a/app/MindWork AI Studio/Tools/PluginSystem/PluginBase.cs
+++ b/app/MindWork AI Studio/Tools/PluginSystem/PluginBase.cs
@@ -468,6 +468,54 @@ public abstract class PluginBase
message = string.Empty;
return true;
}
+
+ ///
+ /// Tries to initialize the UI text content of the plugin.
+ ///
+ /// The error message, when the UI text content could not be read.
+ /// The read UI text content.
+ /// True, when the UI text content could be read successfully.
+ protected bool TryInitUITextContent(out string message, out Dictionary pluginContent)
+ {
+ if (!this.state.Environment["UI_TEXT_CONTENT"].TryRead(out var textTable))
+ {
+ message = "The UI_TEXT_CONTENT table does not exist or is not a valid table.";
+ pluginContent = [];
+ return false;
+ }
+
+ this.ReadTextTable("root", textTable, out pluginContent);
+
+ message = string.Empty;
+ return true;
+ }
+
+ ///
+ /// Reads a flat or hierarchical text table.
+ ///
+ /// The parent key(s).
+ /// The table to read.
+ /// The read table content.
+ protected void ReadTextTable(string parent, LuaTable table, out Dictionary tableContent)
+ {
+ tableContent = [];
+ var lastKey = LuaValue.Nil;
+ while (table.TryGetNext(lastKey, out var pair))
+ {
+ var keyText = pair.Key.ToString();
+ if (pair.Value.TryRead(out var value))
+ tableContent[$"{parent}::{keyText}"] = value;
+
+ else if (pair.Value.TryRead(out var t))
+ {
+ this.ReadTextTable($"{parent}::{keyText}", t, out var subContent);
+ foreach (var (k, v) in subContent)
+ tableContent[k] = v;
+ }
+
+ lastKey = pair.Key;
+ }
+ }
#endregion
}
\ No newline at end of file