diff --git a/app/MindWork AI Studio/Tools/PluginSystem/ILanguagePlugin.cs b/app/MindWork AI Studio/Tools/PluginSystem/ILanguagePlugin.cs index 8766a2e7..36b61985 100644 --- a/app/MindWork AI Studio/Tools/PluginSystem/ILanguagePlugin.cs +++ b/app/MindWork AI Studio/Tools/PluginSystem/ILanguagePlugin.cs @@ -16,8 +16,9 @@ public interface ILanguagePlugin /// /// The key to use to get the text. /// The desired text. + /// When true, a warning will be logged if the key does not exist. /// True if the key exists, false otherwise. - public bool TryGetText(string key, out string value); + public bool TryGetText(string key, out string value, bool logWarning = false); /// /// Gets the text from the language plugin. diff --git a/app/MindWork AI Studio/Tools/PluginSystem/NoPluginLanguage.cs b/app/MindWork AI Studio/Tools/PluginSystem/NoPluginLanguage.cs index 67fd644a..7a0ddd9e 100644 --- a/app/MindWork AI Studio/Tools/PluginSystem/NoPluginLanguage.cs +++ b/app/MindWork AI Studio/Tools/PluginSystem/NoPluginLanguage.cs @@ -12,7 +12,7 @@ public sealed class NoPluginLanguage : PluginBase, ILanguagePlugin #region Implementation of ILanguagePlugin - public bool TryGetText(string key, out string value) + public bool TryGetText(string key, out string value, bool logWarning = false) { value = string.Empty; return true; diff --git a/app/MindWork AI Studio/Tools/PluginSystem/PluginLanguage.cs b/app/MindWork AI Studio/Tools/PluginSystem/PluginLanguage.cs index 95f6c1ba..0b726ad0 100644 --- a/app/MindWork AI Studio/Tools/PluginSystem/PluginLanguage.cs +++ b/app/MindWork AI Studio/Tools/PluginSystem/PluginLanguage.cs @@ -4,6 +4,8 @@ namespace AIStudio.Tools.PluginSystem; public sealed class PluginLanguage : PluginBase, ILanguagePlugin { + private static readonly ILogger LOGGER = Program.LOGGER_FACTORY.CreateLogger(); + private readonly Dictionary content = []; private readonly List otherLanguagePlugins = []; private readonly string langCultureTag; @@ -132,8 +134,9 @@ public sealed class PluginLanguage : PluginBase, ILanguagePlugin /// /// The key to use to get the text. /// The desired text. + /// When true, a warning will be logged if the key does not exist. /// True if the key exists, false otherwise. - public bool TryGetText(string key, out string value) + public bool TryGetText(string key, out string value, bool logWarning = false) { // First, we check if the key is part of the main language pack: if (this.content.TryGetValue(key, out value!)) @@ -150,6 +153,9 @@ public sealed class PluginLanguage : PluginBase, ILanguagePlugin if(this.baseLanguage is not null && this.baseLanguage.TryGetText(key, out value)) return true; + if(logWarning) + LOGGER.LogWarning($"Missing translation key '{key}'."); + value = string.Empty; return false; }