From bb7eead608e551ab80b253b007589934429bcb64 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Fri, 25 Apr 2025 17:55:18 +0200 Subject: [PATCH] Resolved warnings --- app/Build/Commands/CollectI18NKeysCommand.cs | 127 ------------------ app/MindWork AI Studio.sln.DotSettings | 1 + .../Assistants/I18N/AssistantI18N.razor.cs | 2 - .../Components/MSGComponentBase.cs | 1 + .../Dialogs/ProviderDialog.razor | 7 +- .../SettingsDialogAssistantBias.razor | 1 - .../Settings/SettingsDialogI18N.razor.cs | 2 - .../Pages/Supporters.razor.cs | 2 - app/MindWork AI Studio/Tools/Components.cs | 3 + 9 files changed, 9 insertions(+), 137 deletions(-) diff --git a/app/Build/Commands/CollectI18NKeysCommand.cs b/app/Build/Commands/CollectI18NKeysCommand.cs index 0270333b..405a93b7 100644 --- a/app/Build/Commands/CollectI18NKeysCommand.cs +++ b/app/Build/Commands/CollectI18NKeysCommand.cs @@ -161,133 +161,6 @@ public sealed partial class CollectI18NKeysCommand return sb.ToString(); } - private string ExportToLuaTable(Dictionary keyValuePairs) - { - // Collect all nodes: - var root = new Dictionary(); - - // - // Split all collected keys into nodes: - // - foreach (var key in keyValuePairs.Keys.Order()) - { - var path = key.Split('.'); - var current = root; - for (var i = 0; i < path.Length - 1; i++) - { - // We ignore the AISTUDIO segment of the path: - if(path[i] == "AISTUDIO") - continue; - - if (!current.TryGetValue(path[i], out var child) || child is not Dictionary childDict) - { - childDict = new Dictionary(); - current[path[i]] = childDict; - } - - current = childDict; - } - - current[path.Last()] = keyValuePairs[key]; - } - - // - // Inner method to build Lua code from the collected nodes: - // - void ToLuaTable(StringBuilder sb, Dictionary innerDict, int indent = 0) - { - sb.AppendLine("{"); - var prefix = new string(' ', indent * 4); - foreach (var kvp in innerDict) - { - if (kvp.Value is Dictionary childDict) - { - sb.Append($"{prefix} {kvp.Key}"); - sb.Append(" = "); - - ToLuaTable(sb, childDict, indent + 1); - } - else if (kvp.Value is string s) - { - sb.AppendLine($"{prefix} -- {s.Trim().Replace("\n", " ")}"); - sb.Append($"{prefix} {kvp.Key}"); - sb.Append(" = "); - sb.Append($""" - "{s}" - """); - sb.AppendLine(","); - sb.AppendLine(); - } - } - - sb.AppendLine(prefix + "},"); - sb.AppendLine(); - } - - // - // Write the Lua code: - // - var sbLua = new StringBuilder(); - - // To make the later parsing easier, we add the mandatory plugin - // metadata: - sbLua.AppendLine( - """ - -- The ID for this plugin: - ID = "77c2688a-a68f-45cc-820e-fa8f3038a146" - - -- The icon for the plugin: - ICON_SVG = "" - - -- The name of the plugin: - NAME = "Collected I18N keys" - - -- The description of the plugin: - DESCRIPTION = "This plugin is not meant to be used directly. Its a collection of all I18N keys found in the project." - - -- The version of the plugin: - VERSION = "1.0.0" - - -- The type of the plugin: - TYPE = "LANGUAGE" - - -- The authors of the plugin: - AUTHORS = {"MindWork AI Community"} - - -- The support contact for the plugin: - SUPPORT_CONTACT = "MindWork AI Community" - - -- The source URL for the plugin: - SOURCE_URL = "https://github.com/MindWorkAI/AI-Studio" - - -- The categories for the plugin: - CATEGORIES = { "CORE" } - - -- The target groups for the plugin: - TARGET_GROUPS = { "EVERYONE" } - - -- The flag for whether the plugin is maintained: - IS_MAINTAINED = true - - -- When the plugin is deprecated, this message will be shown to users: - DEPRECATION_MESSAGE = "" - - -- The IETF BCP 47 tag for the language. It's the ISO 639 language - -- code followed by the ISO 3166-1 country code: - IETF_TAG = "en-US" - - -- The language name in the user's language: - LANG_NAME = "English (United States)" - - """); - - sbLua.Append("UI_TEXT_CONTENT = "); - if(root["UI_TEXT_CONTENT"] is Dictionary dict) - ToLuaTable(sbLua, dict); - - return sbLua.ToString(); - } - private List FindAllTextTags(ReadOnlySpan fileContent) { const string START_TAG = """ diff --git a/app/MindWork AI Studio.sln.DotSettings b/app/MindWork AI Studio.sln.DotSettings index a626186b..f8edfd31 100644 --- a/app/MindWork AI Studio.sln.DotSettings +++ b/app/MindWork AI Studio.sln.DotSettings @@ -13,6 +13,7 @@ RID UI URL + I18N True True True diff --git a/app/MindWork AI Studio/Assistants/I18N/AssistantI18N.razor.cs b/app/MindWork AI Studio/Assistants/I18N/AssistantI18N.razor.cs index 62fe512d..5ee4ee9a 100644 --- a/app/MindWork AI Studio/Assistants/I18N/AssistantI18N.razor.cs +++ b/app/MindWork AI Studio/Assistants/I18N/AssistantI18N.razor.cs @@ -66,7 +66,6 @@ public partial class AssistantI18N : AssistantBaseCore private string searchString = string.Empty; private Guid selectedLanguagePluginId; private ILanguagePlugin? selectedLanguagePlugin; - private bool isTranslationNeeded; private Dictionary addedKeys = []; private Dictionary removedKeys = []; @@ -160,7 +159,6 @@ public partial class AssistantI18N : AssistantBaseCore this.addedKeys = newI18NContent.ExceptBy(currentI18NContent.Keys, n => n.Key).ToDictionary(); this.removedKeys = currentI18NContent.ExceptBy(newI18NContent.Keys, n => n.Key).ToDictionary(); this.localizationPossible = true; - this.isTranslationNeeded = this.selectedTargetLanguage is not CommonLanguages.EN_US; break; } diff --git a/app/MindWork AI Studio/Components/MSGComponentBase.cs b/app/MindWork AI Studio/Components/MSGComponentBase.cs index 2ad3b96e..65d770c1 100644 --- a/app/MindWork AI Studio/Components/MSGComponentBase.cs +++ b/app/MindWork AI Studio/Components/MSGComponentBase.cs @@ -14,6 +14,7 @@ public abstract class MSGComponentBase : ComponentBase, IDisposable, IMessageBus protected MessageBus MessageBus { get; init; } = null!; [Inject] + // ReSharper disable once UnusedAutoPropertyAccessor.Local private ILogger Logger { get; init; } = null!; private ILanguagePlugin Lang { get; set; } = PluginFactory.BaseLanguage; diff --git a/app/MindWork AI Studio/Dialogs/ProviderDialog.razor b/app/MindWork AI Studio/Dialogs/ProviderDialog.razor index 439a2dea..6e28d6fe 100644 --- a/app/MindWork AI Studio/Dialogs/ProviderDialog.razor +++ b/app/MindWork AI Studio/Dialogs/ProviderDialog.razor @@ -68,11 +68,12 @@ @inferenceProvider.ToName() - } + } - + @* ReSharper disable Asp.Entity *@ Please double-check if your model name matches the curl specifications provided by the inference provider. If it doesn't, you might get a Not Found error when trying to use the model. Here's a curl example. - } + @* ReSharper restore Asp.Entity *@ + } diff --git a/app/MindWork AI Studio/Dialogs/Settings/SettingsDialogAssistantBias.razor b/app/MindWork AI Studio/Dialogs/Settings/SettingsDialogAssistantBias.razor index 389a6719..ec6776f0 100644 --- a/app/MindWork AI Studio/Dialogs/Settings/SettingsDialogAssistantBias.razor +++ b/app/MindWork AI Studio/Dialogs/Settings/SettingsDialogAssistantBias.razor @@ -1,5 +1,4 @@ @using AIStudio.Settings -@using AIStudio.Settings.DataModel @inherits SettingsDialogBase diff --git a/app/MindWork AI Studio/Dialogs/Settings/SettingsDialogI18N.razor.cs b/app/MindWork AI Studio/Dialogs/Settings/SettingsDialogI18N.razor.cs index afa917d8..22cbbfb9 100644 --- a/app/MindWork AI Studio/Dialogs/Settings/SettingsDialogI18N.razor.cs +++ b/app/MindWork AI Studio/Dialogs/Settings/SettingsDialogI18N.razor.cs @@ -1,5 +1,3 @@ -using Microsoft.AspNetCore.Components; - namespace AIStudio.Dialogs.Settings; public partial class SettingsDialogI18N : SettingsDialogBase diff --git a/app/MindWork AI Studio/Pages/Supporters.razor.cs b/app/MindWork AI Studio/Pages/Supporters.razor.cs index dcd937c9..bb82da0b 100644 --- a/app/MindWork AI Studio/Pages/Supporters.razor.cs +++ b/app/MindWork AI Studio/Pages/Supporters.razor.cs @@ -1,7 +1,5 @@ using AIStudio.Components; -using Microsoft.AspNetCore.Components; - namespace AIStudio.Pages; public partial class Supporters : MSGComponentBase; \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/Components.cs b/app/MindWork AI Studio/Tools/Components.cs index 62eb2bf9..94148d5e 100644 --- a/app/MindWork AI Studio/Tools/Components.cs +++ b/app/MindWork AI Studio/Tools/Components.cs @@ -18,7 +18,10 @@ public enum Components JOB_POSTING_ASSISTANT, BIAS_DAY_ASSISTANT, ERI_ASSISTANT, + + // ReSharper disable InconsistentNaming I18N_ASSISTANT, + // ReSharper restore InconsistentNaming CHAT, APP_SETTINGS,