diff --git a/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs b/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs index 877374ad..07938468 100644 --- a/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs +++ b/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs @@ -136,6 +136,8 @@ public abstract partial class AssistantBase : AssistantLowerBase wher #endregion + private string TB(string fallbackEN) => this.T(fallbackEN, typeof(AssistantBase).Namespace, nameof(AssistantBase)); + private string SubmitButtonStyle => this.SettingsManager.ConfigurationData.LLMProviders.ShowProviderConfidence ? this.providerSettings.UsedLLMProvider.GetConfidence(this.SettingsManager).StyleBorder(this.SettingsManager) : string.Empty; protected string? ValidatingProvider(AIStudio.Settings.Provider provider) diff --git a/app/MindWork AI Studio/Components/MSGComponentBase.cs b/app/MindWork AI Studio/Components/MSGComponentBase.cs index ad211203..a8e0fb43 100644 --- a/app/MindWork AI Studio/Components/MSGComponentBase.cs +++ b/app/MindWork AI Studio/Components/MSGComponentBase.cs @@ -35,6 +35,9 @@ public abstract class MSGComponentBase : ComponentBase, IDisposable, IMessageBus /// public string T(string fallbackEN) => this.GetText(this.Lang, fallbackEN); + + /// + public string T(string fallbackEN, string? typeNamespace, string? typeName) => this.GetText(this.Lang, fallbackEN, typeNamespace, typeName); #endregion diff --git a/app/MindWork AI Studio/Layout/MainLayout.razor.cs b/app/MindWork AI Studio/Layout/MainLayout.razor.cs index 4baa48f7..934dc358 100644 --- a/app/MindWork AI Studio/Layout/MainLayout.razor.cs +++ b/app/MindWork AI Studio/Layout/MainLayout.razor.cs @@ -123,8 +123,12 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan #region Implementation of ILang + /// public string T(string fallbackEN) => this.GetText(this.Lang, fallbackEN); + /// + public string T(string fallbackEN, string? typeNamespace, string? typeName) => this.GetText(this.Lang, fallbackEN, typeNamespace, typeName); + #endregion #region Implementation of IMessageBusReceiver diff --git a/app/MindWork AI Studio/Tools/PluginSystem/ILang.cs b/app/MindWork AI Studio/Tools/PluginSystem/ILang.cs index 6c5277ea..ee6ca554 100644 --- a/app/MindWork AI Studio/Tools/PluginSystem/ILang.cs +++ b/app/MindWork AI Studio/Tools/PluginSystem/ILang.cs @@ -18,4 +18,24 @@ public interface ILang /// The fallback text in English (US). /// The text from the language plugin or the fallback text. public string T(string fallbackEN); + + /// + /// Tries to get a text from the language plugin. + /// + /// + /// The given fallback text is used to determine the key for + /// the language plugin. Base for the key is the namespace of + /// the using component and the fallback text in English (US). + /// The given text is hashed. When the key does not exist, + /// the fallback text will be returned.
+ ///
+ /// You might predefine the namespace and type. This is needed + /// when your abstract base class component wants to localize + /// text as well. + ///
+ /// The fallback text in English (US). + /// The namespace of the type requesting the text, used as part of the key. + /// The name of the type requesting the text, used as part of the key. + /// The text from the language plugin or the fallback text. + public string T(string fallbackEN, string? typeNamespace, string? typeName); } \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/PluginSystem/ILangExtensions.cs b/app/MindWork AI Studio/Tools/PluginSystem/ILangExtensions.cs index d1c26856..6dd5e462 100644 --- a/app/MindWork AI Studio/Tools/PluginSystem/ILangExtensions.cs +++ b/app/MindWork AI Studio/Tools/PluginSystem/ILangExtensions.cs @@ -6,10 +6,13 @@ public static class ILangExtensions { private static readonly ILogger LOGGER = Program.LOGGER_FACTORY.CreateLogger(); - public static string GetText(this ILang lang, ILanguagePlugin plugin, string fallbackEN) + public static string GetText(this ILang lang, ILanguagePlugin plugin, string fallbackEN, string? typeNamespace = null, string? typeName = null) { var type = lang.GetType(); - var ns = $"{type.Namespace!}::{type.Name}".ToUpperInvariant().Replace(".", "::"); + typeName ??= type.Name; + typeNamespace ??= type.Namespace!; + + var ns = $"{typeNamespace}::{typeName}".ToUpperInvariant().Replace(".", "::"); var key = $"root::{ns}::T{fallbackEN.ToFNV32()}"; if(plugin is NoPluginLanguage)