diff --git a/src/Infrastructure/BotSharp.Abstraction/Conversations/IIndicationLocalizer.cs b/src/Infrastructure/BotSharp.Abstraction/Conversations/IIndicationLocalizer.cs
new file mode 100644
index 000000000..ae5f0ac11
--- /dev/null
+++ b/src/Infrastructure/BotSharp.Abstraction/Conversations/IIndicationLocalizer.cs
@@ -0,0 +1,14 @@
+namespace BotSharp.Abstraction.Conversations;
+
+///
+/// Puts an indication into the conversation's language before it is pushed. Indications skip
+/// TranslationResponseHook -- they go out ahead of the function, where an LLM translation would
+/// hold up the very line meant to say "working on it" -- so the host supplies fixed wording instead.
+/// Optional: with none registered, indications go out as the function wrote them.
+///
+public interface IIndicationLocalizer
+{
+ /// The conversation's StateConst.LANGUAGE, e.g. LanguageType.CHINESE.
+ /// The wording for , or unchanged when there is none.
+ string Localize(string indication, string language);
+}
diff --git a/src/Infrastructure/BotSharp.Core/MessageHub/ConversationHub.cs b/src/Infrastructure/BotSharp.Core/MessageHub/ConversationHub.cs
index 488a59cfd..dc3af3ecd 100644
--- a/src/Infrastructure/BotSharp.Core/MessageHub/ConversationHub.cs
+++ b/src/Infrastructure/BotSharp.Core/MessageHub/ConversationHub.cs
@@ -8,11 +8,14 @@ namespace BotSharp.Core.MessageHub;
public sealed class ConversationHub
{
private readonly MessageHub> _hub;
+ private readonly Func? _localize;
- internal ConversationHub(MessageHub> hub, string? conversationId)
+ internal ConversationHub(MessageHub> hub, string? conversationId,
+ Func? localize = null)
{
_hub = hub;
ConversationId = conversationId;
+ _localize = localize;
}
/// Where every push goes; null when taken outside a conversation.
@@ -30,7 +33,7 @@ public void PushIndication(RoleDialogModel message, string? indication)
return;
}
- message.Indication = indication;
+ message.Indication = _localize?.Invoke(indication) ?? indication;
_hub.Push(new()
{
diff --git a/src/Infrastructure/BotSharp.Core/MessageHub/MessageHubExtensions.cs b/src/Infrastructure/BotSharp.Core/MessageHub/MessageHubExtensions.cs
index bf07cc3fa..52387eb6c 100644
--- a/src/Infrastructure/BotSharp.Core/MessageHub/MessageHubExtensions.cs
+++ b/src/Infrastructure/BotSharp.Core/MessageHub/MessageHubExtensions.cs
@@ -1,3 +1,5 @@
+using BotSharp.Abstraction.Infrastructures.Enums;
+
namespace BotSharp.Core.MessageHub;
public static class MessageHubExtensions
@@ -9,6 +11,12 @@ public static ConversationHub GetHub(this IServiceProvider services)
{
var conv = services.GetRequiredService();
var hub = services.GetRequiredService>>();
- return new ConversationHub(hub, conv.ConversationId);
+
+ // Resolved now, not at push time: a hub may be kept and pushed from a transport's own thread.
+ var localizer = services.GetService();
+ var language = conv.States.GetState(StateConst.LANGUAGE, LanguageType.ENGLISH);
+ Func? localize = localizer == null ? null : text => localizer.Localize(text, language);
+
+ return new ConversationHub(hub, conv.ConversationId, localize);
}
}