Fixed localization of profiles

This commit is contained in:
Thorsten Sommer 2026-01-08 17:32:12 +01:00
parent c9b257a408
commit 830eb9973c
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 21 additions and 4 deletions

View File

@ -7,7 +7,7 @@
@if (this.CurrentChatTemplate != ChatTemplate.NO_CHAT_TEMPLATE)
{
<MudButton IconSize="Size.Large" StartIcon="@Icons.Material.Filled.RateReview" IconColor="Color.Default">
@this.CurrentChatTemplate.Name
@this.CurrentChatTemplate.GetSafeName()
</MudButton>
}
else

View File

@ -6,7 +6,7 @@
@if (this.CurrentProfile != Profile.NO_PROFILE)
{
<MudButton IconSize="Size.Large" StartIcon="@Icons.Material.Filled.Person4" IconColor="Color.Default">
@this.CurrentProfile.Name
@this.CurrentProfile.GetSafeName()
</MudButton>
}
else
@ -20,7 +20,7 @@
@foreach (var profile in this.SettingsManager.ConfigurationData.Profiles.GetAllProfiles())
{
<MudMenuItem Icon="@this.ProfileIcon(profile)" OnClick="() => this.SelectionChanged(profile)">
@profile.Name
@profile.GetSafeName()
</MudMenuItem>
}
</ChildContent>

View File

@ -22,7 +22,7 @@ public record Profile(
public static readonly Profile NO_PROFILE = new()
{
Name = TB("Use no profile"),
Name = TB("Use no profile"), // Cannot be localized due to being a static readonly field
NeedToKnow = string.Empty,
Actions = string.Empty,
Id = Guid.Empty.ToString(),
@ -39,6 +39,23 @@ public record Profile(
#endregion
/// <summary>
/// Gets the name of this profile. If it is the NO_PROFILE, it returns a localized string.
/// </summary>
/// <remarks>
/// Why not using the Name property directly? Because the Name property of NO_PROFILE cannot be
/// localized because it is a static readonly field. So we need this method to return a localized
/// string instead.
/// </remarks>
/// <returns>The name of this profile.</returns>
public string GetSafeName()
{
if(this == NO_PROFILE)
return TB("Use no profile");
return this.Name;
}
public string ToSystemPrompt()
{
if(this.Num == uint.MaxValue)