diff --git a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua index 431a65ef..74c3080a 100644 --- a/app/MindWork AI Studio/Assistants/I18N/allTexts.lua +++ b/app/MindWork AI Studio/Assistants/I18N/allTexts.lua @@ -1714,6 +1714,24 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENT::T3825586228"] = "Please p -- Show web content options UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENT::T4249712357"] = "Show web content options" +-- Loading +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENTSTEPSEXTENSIONS::T1404011351"] = "Loading" + +-- Start +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENTSTEPSEXTENSIONS::T182978943"] = "Start" + +-- Done +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENTSTEPSEXTENSIONS::T2379421585"] = "Done" + +-- Parsing +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENTSTEPSEXTENSIONS::T3151033983"] = "Parsing" + +-- Cleaning +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENTSTEPSEXTENSIONS::T3420573362"] = "Cleaning" + +-- n/a +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENTSTEPSEXTENSIONS::T907272257"] = "n/a" + -- Hide content UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::SECRETINPUTFIELD::T1273315904"] = "Hide content" diff --git a/app/MindWork AI Studio/Components/ReadWebContentStepsExtensions.cs b/app/MindWork AI Studio/Components/ReadWebContentStepsExtensions.cs new file mode 100644 index 00000000..d7c01c51 --- /dev/null +++ b/app/MindWork AI Studio/Components/ReadWebContentStepsExtensions.cs @@ -0,0 +1,24 @@ +using AIStudio.Tools.PluginSystem; + +namespace AIStudio.Components; + +public static class ReadWebContentStepsExtensions +{ + private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(ReadWebContentStepsExtensions).Namespace, nameof(ReadWebContentStepsExtensions)); + + /// + /// Gets the text representation of a given ReadWebContentSteps enum value. + /// + /// The ReadWebContentSteps enum value. + /// >The text representation of the process step. + public static string GetText(this ReadWebContentSteps step) => step switch + { + ReadWebContentSteps.START => TB("Start"), + ReadWebContentSteps.LOADING => TB("Loading"), + ReadWebContentSteps.PARSING => TB("Parsing"), + ReadWebContentSteps.CLEANING => TB("Cleaning"), + ReadWebContentSteps.DONE => TB("Done"), + + _ => TB("n/a") + }; +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua b/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua index b4a643ee..6cda3de2 100644 --- a/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua +++ b/app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua @@ -1716,6 +1716,24 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENT::T3825586228"] = "Bitte ge -- Show web content options UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENT::T4249712357"] = "Optionen für Webinhalte anzeigen" +-- Loading +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENTSTEPSEXTENSIONS::T1404011351"] = "Laden" + +-- Start +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENTSTEPSEXTENSIONS::T182978943"] = "Start" + +-- Done +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENTSTEPSEXTENSIONS::T2379421585"] = "Fertig" + +-- Parsing +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENTSTEPSEXTENSIONS::T3151033983"] = "Zerlegen" + +-- Cleaning +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENTSTEPSEXTENSIONS::T3420573362"] = "Bereinigen" + +-- n/a +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENTSTEPSEXTENSIONS::T907272257"] = "n/a" + -- Hide content UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::SECRETINPUTFIELD::T1273315904"] = "Inhalt ausblenden" diff --git a/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua b/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua index a5087d4d..cc561314 100644 --- a/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua +++ b/app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua @@ -1716,6 +1716,24 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENT::T3825586228"] = "Please p -- Show web content options UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENT::T4249712357"] = "Show web content options" +-- Loading +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENTSTEPSEXTENSIONS::T1404011351"] = "Loading" + +-- Start +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENTSTEPSEXTENSIONS::T182978943"] = "Start" + +-- Done +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENTSTEPSEXTENSIONS::T2379421585"] = "Done" + +-- Parsing +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENTSTEPSEXTENSIONS::T3151033983"] = "Parsing" + +-- Cleaning +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENTSTEPSEXTENSIONS::T3420573362"] = "Cleaning" + +-- n/a +UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::READWEBCONTENTSTEPSEXTENSIONS::T907272257"] = "n/a" + -- Hide content UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::SECRETINPUTFIELD::T1273315904"] = "Hide content" diff --git a/app/MindWork AI Studio/Tools/Process.cs b/app/MindWork AI Studio/Tools/Process.cs index 53488915..eac7f799 100644 --- a/app/MindWork AI Studio/Tools/Process.cs +++ b/app/MindWork AI Studio/Tools/Process.cs @@ -1,5 +1,3 @@ -using System.Text; - namespace AIStudio.Tools; public sealed class Process where T : struct, Enum @@ -20,7 +18,7 @@ public sealed class Process where T : struct, Enum { var value = values[i]; var stepValue = Convert.ToInt32(value); - var stepName = DeriveName(value); + var stepName = ProcessStepTextRouter.GetText(value); this.labels[i] = stepName; this.stepsData[value] = new ProcessStepValue(stepValue, stepName); @@ -33,30 +31,6 @@ public sealed class Process where T : struct, Enum } } - private static string DeriveName(T value) - { - var text = value.ToString(); - if (!text.Contains('_')) - { - text = text.ToLowerInvariant(); - text = char.ToUpperInvariant(text[0]) + text[1..]; - } - else - { - var parts = text.Split('_'); - var sb = new StringBuilder(); - foreach (var part in parts) - { - sb.Append(char.ToUpperInvariant(part[0])); - sb.Append(part[1..].ToLowerInvariant()); - } - - text = sb.ToString(); - } - - return text; - } - public string[] Labels => this.labels; public int Min => this.min; diff --git a/app/MindWork AI Studio/Tools/ProcessStepTextRouter.cs b/app/MindWork AI Studio/Tools/ProcessStepTextRouter.cs new file mode 100644 index 00000000..eebaff48 --- /dev/null +++ b/app/MindWork AI Studio/Tools/ProcessStepTextRouter.cs @@ -0,0 +1,59 @@ +using System.Text; + +using AIStudio.Components; + +namespace AIStudio.Tools; + +/// +/// Routes process step enums to their corresponding text representations, when possible. +/// +public static class ProcessStepTextRouter +{ + /// + /// Gets the text representation of a given process step enum. + /// + /// + /// Gets the text representation of a given process step enum. + /// When the enum type has a specific extension method for text retrieval, it uses that; + /// otherwise, it derives a name based on the enum value. + /// + /// The process step enum value. + /// The enum type representing the process steps. + /// The text representation of the process step. + public static string GetText(T step) where T : struct, Enum => step switch + { + ReadWebContentSteps x => x.GetText(), + _ => DeriveName(step) + }; + + /// + /// Derives a name from the enum value by converting it to a more human-readable format. + /// It handles both single-word and multi-word enum values (separated by underscores). + /// + /// The enum value to derive the name from. + /// The enum type. + /// A human-readable name derived from the enum value. + private static string DeriveName(T value) where T : struct, Enum + { + var text = value.ToString(); + if (!text.Contains('_')) + { + text = text.ToLowerInvariant(); + text = char.ToUpperInvariant(text[0]) + text[1..]; + } + else + { + var parts = text.Split('_'); + var sb = new StringBuilder(); + foreach (var part in parts) + { + sb.Append(char.ToUpperInvariant(part[0])); + sb.Append(part[1..].ToLowerInvariant()); + } + + text = sb.ToString(); + } + + return text; + } +} \ No newline at end of file