mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-04 18:29:40 +00:00
Improved the I18N & the German translation (#552)
Build and Release / Read metadata (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Build and Release / Read metadata (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
This commit is contained in:
1 parent
6a37ce6d25
commit
d966929dca
7 files changed
+154
-42
No files matched your search
@@ -0,0 +1,59 @@
|
||||
using System.Text;
|
||||
|
||||
using AIStudio.Components;
|
||||
|
||||
namespace AIStudio.Tools;
|
||||
|
||||
/// <summary>
|
||||
/// Routes process step enums to their corresponding text representations, when possible.
|
||||
/// </summary>
|
||||
public static class ProcessStepTextRouter
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the text representation of a given process step enum.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 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.
|
||||
/// </remarks>
|
||||
/// <param name="step">The process step enum value.</param>
|
||||
/// <typeparam name="T">The enum type representing the process steps.</typeparam>
|
||||
/// <returns>The text representation of the process step.</returns>
|
||||
public static string GetText<T>(T step) where T : struct, Enum => step switch
|
||||
{
|
||||
ReadWebContentSteps x => x.GetText(),
|
||||
_ => DeriveName(step)
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 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).
|
||||
/// </summary>
|
||||
/// <param name="value">The enum value to derive the name from.</param>
|
||||
/// <typeparam name="T">The enum type.</typeparam>
|
||||
/// <returns>A human-readable name derived from the enum value.</returns>
|
||||
private static string DeriveName<T>(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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user