Resolved warnings

This commit is contained in:
Thorsten Sommer 2025-04-25 17:55:18 +02:00
parent 3528535b3f
commit bb7eead608
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
9 changed files with 9 additions and 137 deletions

View File

@ -161,133 +161,6 @@ public sealed partial class CollectI18NKeysCommand
return sb.ToString();
}
private string ExportToLuaTable(Dictionary<string, string> keyValuePairs)
{
// Collect all nodes:
var root = new Dictionary<string, object>();
//
// 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<string, object> childDict)
{
childDict = new Dictionary<string, object>();
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<string, object> innerDict, int indent = 0)
{
sb.AppendLine("{");
var prefix = new string(' ', indent * 4);
foreach (var kvp in innerDict)
{
if (kvp.Value is Dictionary<string, object> 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<string, object> dict)
ToLuaTable(sbLua, dict);
return sbLua.ToString();
}
private List<string> FindAllTextTags(ReadOnlySpan<char> fileContent)
{
const string START_TAG = """

View File

@ -13,6 +13,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RID/@EntryIndexedValue">RID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=UI/@EntryIndexedValue">UI</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=URL/@EntryIndexedValue">URL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=I18N/@EntryIndexedValue">I18N</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=agentic/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=groq/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=gwdg/@EntryIndexedValue">True</s:Boolean>

View File

@ -66,7 +66,6 @@ public partial class AssistantI18N : AssistantBaseCore<SettingsDialogI18N>
private string searchString = string.Empty;
private Guid selectedLanguagePluginId;
private ILanguagePlugin? selectedLanguagePlugin;
private bool isTranslationNeeded;
private Dictionary<string, string> addedKeys = [];
private Dictionary<string, string> removedKeys = [];
@ -160,7 +159,6 @@ public partial class AssistantI18N : AssistantBaseCore<SettingsDialogI18N>
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;
}

View File

@ -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<MSGComponentBase> Logger { get; init; } = null!;
private ILanguagePlugin Lang { get; set; } = PluginFactory.BaseLanguage;

View File

@ -68,11 +68,12 @@
<MudSelectItem Value="@inferenceProvider">
@inferenceProvider.ToName()
</MudSelectItem>
}
}
</MudSelect>
@* ReSharper disable Asp.Entity *@
<MudJustifiedText Class="mb-3"> Please double-check if your model name matches the curl specifications provided by the inference provider. If it doesn't, you might get a <b>Not Found</b> error when trying to use the model. Here's a <MudLink Href="https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct?inference_api=true&inference_provider=novita&language=sh" Target="_blank">curl example</MudLink>.</MudJustifiedText>
}
@* ReSharper restore Asp.Entity *@
}
<MudField FullWidth="true" Label="Model selection" Variant="Variant.Outlined" Class="mb-3">
<MudStack Row="@true" AlignItems="AlignItems.Center" StretchItems="StretchItems.End">

View File

@ -1,5 +1,4 @@
@using AIStudio.Settings
@using AIStudio.Settings.DataModel
@inherits SettingsDialogBase
<MudDialog>
<TitleContent>

View File

@ -1,5 +1,3 @@
using Microsoft.AspNetCore.Components;
namespace AIStudio.Dialogs.Settings;
public partial class SettingsDialogI18N : SettingsDialogBase

View File

@ -1,7 +1,5 @@
using AIStudio.Components;
using Microsoft.AspNetCore.Components;
namespace AIStudio.Pages;
public partial class Supporters : MSGComponentBase;

View File

@ -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,