diff --git a/app/Build/Commands/CollectI18NKeysCommand.cs b/app/Build/Commands/CollectI18NKeysCommand.cs index 3108a488..1a09d77a 100644 --- a/app/Build/Commands/CollectI18NKeysCommand.cs +++ b/app/Build/Commands/CollectI18NKeysCommand.cs @@ -10,6 +10,29 @@ namespace Build.Commands; public sealed partial class CollectI18NKeysCommand { + private const string START_TAG1 = """ + T(" + """; + + private const string START_TAG2 = """ + TB(" + """; + + private const string START_TAG3 = """ + T(@" + """; + + private const string END_TAG = """ + ") + """; + + private static readonly (string Tag, int Length)[] START_TAGS = + [ + (START_TAG1, START_TAG1.Length), + (START_TAG2, START_TAG2.Length), + (START_TAG3, START_TAG3.Length) + ]; + [Command("collect-i18n", Description = "Collect I18N keys")] public async Task CollectI18NKeys() { @@ -133,36 +156,22 @@ public sealed partial class CollectI18NKeysCommand private List FindAllTextTags(ReadOnlySpan fileContent) { - const string START_TAG1 = """ - T(" - """; - - const string START_TAG2 = """ - TB(" - """; - - const string END_TAG = """ - ") - """; - (int Index, int Len) FindNextStart(ReadOnlySpan content) { - var startIdx1 = content.IndexOf(START_TAG1); - var startIdx2 = content.IndexOf(START_TAG2); - - if (startIdx1 == -1 && startIdx2 == -1) - return (-1, 0); - - if (startIdx1 == -1) - return (startIdx2, START_TAG2.Length); - - if (startIdx2 == -1) - return (startIdx1, START_TAG1.Length); - - if (startIdx1 < startIdx2) - return (startIdx1, START_TAG1.Length); - - return (startIdx2, START_TAG2.Length); + var bestIndex = -1; + var bestLength = 0; + + foreach (var (tag, length) in START_TAGS) + { + var index = content.IndexOf(tag); + if (index != -1 && (bestIndex == -1 || index < bestIndex)) + { + bestIndex = index; + bestLength = length; + } + } + + return (bestIndex, bestLength); } var matches = new List(); diff --git a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua index eefd323f..3971eaf1 100644 --- a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua +++ b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua @@ -445,6 +445,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::CHATCOMPONENT::T636393754"] = "Move the c -- Show your workspaces UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::CHATCOMPONENT::T733672375"] = "Show your workspaces" +-- Start new chat in workspace "{0}" +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::CHATCOMPONENT::T896906391"] = "Start new chat in workspace \"{0}\"" + -- Region UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::CONFIDENCEINFO::T1227782301"] = "Region" diff --git a/app/MindWork AI Studio/Components/ChatComponent.razor.cs b/app/MindWork AI Studio/Components/ChatComponent.razor.cs index 522a2739..fff2a9f5 100644 --- a/app/MindWork AI Studio/Components/ChatComponent.razor.cs +++ b/app/MindWork AI Studio/Components/ChatComponent.razor.cs @@ -270,7 +270,9 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable private bool CanThreadBeSaved => this.ChatThread is not null && this.ChatThread.Blocks.Count > 0; - private string TooltipAddChatToWorkspace => string.Format(T(@"Start new chat in workspace ""{0}"""), this.currentWorkspaceName); + private string TooltipAddChatToWorkspace => string.Format(T(""" + Start new chat in workspace "{0}" + """), this.currentWorkspaceName); private string UserInputStyle => this.SettingsManager.ConfigurationData.LLMProviders.ShowProviderConfidence ? this.Provider.UsedLLMProvider.GetConfidence(this.SettingsManager).SetColorStyle(this.SettingsManager) : string.Empty;