From 9d4506f0a57fdb51e66ca42195ab65140a205662 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sun, 18 May 2025 14:46:11 +0200 Subject: [PATCH] Migrated more text data to I18N --- .../Dialogs/DataSourceERI-V1InfoDialog.razor | 50 ++++++++------- .../DataSourceERI-V1InfoDialog.razor.cs | 17 ++--- .../Dialogs/DataSourceERI_V1Dialog.razor | 32 +++++----- .../Dialogs/DataSourceERI_V1Dialog.razor.cs | 22 +++---- .../DataSourceLocalDirectoryDialog.razor | 42 +++++++------ .../DataSourceLocalDirectoryDialog.razor.cs | 6 +- .../DataSourceLocalDirectoryInfoDialog.razor | 30 ++++----- ...ataSourceLocalDirectoryInfoDialog.razor.cs | 6 +- .../Dialogs/DataSourceLocalFileDialog.razor | 42 +++++++------ .../DataSourceLocalFileDialog.razor.cs | 6 +- .../DataSourceLocalFileInfoDialog.razor | 24 +++---- .../DataSourceLocalFileInfoDialog.razor.cs | 6 +- .../Dialogs/EmbeddingMethodDialog.razor | 34 +++++----- .../Dialogs/EmbeddingMethodDialog.razor.cs | 20 +++--- .../Dialogs/RetrievalProcessDialog.razor | 62 +++++++++---------- .../Dialogs/RetrievalProcessDialog.razor.cs | 37 +++++------ 16 files changed, 220 insertions(+), 216 deletions(-) diff --git a/app/MindWork AI Studio/Dialogs/DataSourceERI-V1InfoDialog.razor b/app/MindWork AI Studio/Dialogs/DataSourceERI-V1InfoDialog.razor index dd6d2773..e51e3e19 100644 --- a/app/MindWork AI Studio/Dialogs/DataSourceERI-V1InfoDialog.razor +++ b/app/MindWork AI Studio/Dialogs/DataSourceERI-V1InfoDialog.razor @@ -1,6 +1,6 @@ @using AIStudio.Settings.DataModel @using AIStudio.Tools.ERIClient.DataModel - +@inherits MSGComponentBase @@ -8,59 +8,57 @@ Common data source information - - - + + + @if (!this.IsConnectionEncrypted()) { - Please note: the connection to the ERI v1 server is not encrypted. This means that all - data sent to the server is transmitted in plain text. Please ask the ERI server administrator - to enable encryption. + @T("Please note: the connection to the ERI v1 server is not encrypted. This means that all data sent to the server is transmitted in plain text. Please ask the ERI server administrator to enable encryption.") } @if (this.DataSource.AuthMethod is AuthMethod.USERNAME_PASSWORD) { - + } - - - + + + - Retrieval information + @T("Retrieval information") @if (!this.retrievalInfoformation.Any()) { - The data source does not provide any retrieval information. + @T("The data source does not provide any retrieval information.") } else { - - + + @if (!string.IsNullOrWhiteSpace(this.selectedRetrievalInfo.Link)) { - Open web link, show more information + @T("Open web link, show more information") } - Embeddings + @T("Embeddings") @* ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract *@ @if (this.selectedRetrievalInfo.Embeddings is null || !this.selectedRetrievalInfo.Embeddings.Any()) { - The data source does not provide any embedding information. + @T("The data source does not provide any embedding information.") } else @@ -70,14 +68,14 @@ { var embedding = this.selectedRetrievalInfo.Embeddings[embeddingIndex]; - - - + + + @if (!string.IsNullOrWhiteSpace(embedding.Link)) { - Open web link, show more information + @T("Open web link, show more information") } @@ -95,7 +93,11 @@ { } - Reload - Close + + @T("Reload") + + + @T("Close") + \ No newline at end of file diff --git a/app/MindWork AI Studio/Dialogs/DataSourceERI-V1InfoDialog.razor.cs b/app/MindWork AI Studio/Dialogs/DataSourceERI-V1InfoDialog.razor.cs index 2594ee58..38ed220a 100644 --- a/app/MindWork AI Studio/Dialogs/DataSourceERI-V1InfoDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/DataSourceERI-V1InfoDialog.razor.cs @@ -3,6 +3,7 @@ using System.Text; using AIStudio.Assistants.ERI; +using AIStudio.Components; using AIStudio.Settings.DataModel; using AIStudio.Tools.ERIClient; using AIStudio.Tools.ERIClient.DataModel; @@ -14,7 +15,7 @@ using RetrievalInfo = AIStudio.Tools.ERIClient.DataModel.RetrievalInfo; namespace AIStudio.Dialogs; -public partial class DataSourceERI_V1InfoDialog : ComponentBase, IAsyncDisposable, ISecretId +public partial class DataSourceERI_V1InfoDialog : MSGComponentBase, IAsyncDisposable, ISecretId { [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!; @@ -29,8 +30,8 @@ public partial class DataSourceERI_V1InfoDialog : ComponentBase, IAsyncDisposabl protected override async Task OnInitializedAsync() { - this.eriServerTasks.Add(this.GetERIMetadata()); await base.OnInitializedAsync(); + this.eriServerTasks.Add(this.GetERIMetadata()); } #endregion @@ -59,21 +60,21 @@ public partial class DataSourceERI_V1InfoDialog : ComponentBase, IAsyncDisposabl return $"[{retrievalInfo.Id}] {retrievalInfo.Name}"; if (hasId) - return $"[{retrievalInfo.Id}] Unnamed retrieval process"; + return string.Format(T("[{0}] Unnamed retrieval process"), retrievalInfo.Id); - return hasName ? retrievalInfo.Name : "Unnamed retrieval process"; + return hasName ? retrievalInfo.Name : T("Unnamed retrieval process"); } private string RetrievalParameters(RetrievalInfo retrievalInfo) { var parameters = retrievalInfo.ParametersDescription; if (parameters is null || parameters.Count == 0) - return "This retrieval process has no parameters."; + return T("This retrieval process has no parameters."); var sb = new StringBuilder(); foreach (var (paramName, description) in parameters) { - sb.Append("Parameter: "); + sb.Append(T("Parameter: ")); sb.AppendLine(paramName); sb.AppendLine(description); sb.AppendLine(); @@ -94,7 +95,7 @@ public partial class DataSourceERI_V1InfoDialog : ComponentBase, IAsyncDisposabl using var client = ERIClientFactory.Get(ERIVersion.V1, this.DataSource); if(client is null) { - this.dataIssues.Add("Failed to connect to the ERI v1 server. The server is not supported."); + this.dataIssues.Add(T("Failed to connect to the ERI v1 server. The server is not supported.")); return; } @@ -136,7 +137,7 @@ public partial class DataSourceERI_V1InfoDialog : ComponentBase, IAsyncDisposabl } catch (Exception e) { - this.dataIssues.Add($"Failed to connect to the ERI v1 server. The message was: {e.Message}"); + this.dataIssues.Add(string.Format(T("Failed to connect to the ERI v1 server. The message was: {0}"), e.Message)); } finally { diff --git a/app/MindWork AI Studio/Dialogs/DataSourceERI_V1Dialog.razor b/app/MindWork AI Studio/Dialogs/DataSourceERI_V1Dialog.razor index a37a2d4d..3f7d208b 100644 --- a/app/MindWork AI Studio/Dialogs/DataSourceERI_V1Dialog.razor +++ b/app/MindWork AI Studio/Dialogs/DataSourceERI_V1Dialog.razor @@ -1,5 +1,7 @@ @using AIStudio.Settings.DataModel @using AIStudio.Tools.ERIClient.DataModel +@inherits MSGComponentBase + @@ -7,7 +9,7 @@ - Please note: the connection to the ERI v1 server is not encrypted. This means that all - data sent to the server is transmitted in plain text. Please ask the ERI server administrator - to enable encryption. + @T("Please note: the connection to the ERI v1 server is not encrypted. This means that all data sent to the server is transmitted in plain text. Please ask the ERI server administrator to enable encryption.") } @@ -57,7 +57,7 @@ { - Test connection & read available metadata + @T("Test connection & read available metadata") @this.GetTestResultText() @@ -70,7 +70,9 @@ @foreach (var authMethod in this.availableAuthMethods) { - @authMethod.DisplayName() + + @authMethod.DisplayName() + } } @@ -83,7 +85,7 @@ 0) { - + @foreach (var retrievalProcess in this.availableRetrievalProcesses) { @@ -122,7 +124,7 @@ } - + @foreach (var policy in Enum.GetValues()) { @@ -135,15 +137,17 @@ - Cancel + + @T("Cancel") + @if(this.IsEditing) { - @:Update + @T("Update") } else { - @:Add + @T("Add") } diff --git a/app/MindWork AI Studio/Dialogs/DataSourceERI_V1Dialog.razor.cs b/app/MindWork AI Studio/Dialogs/DataSourceERI_V1Dialog.razor.cs index e3547d9d..dd703c7c 100644 --- a/app/MindWork AI Studio/Dialogs/DataSourceERI_V1Dialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/DataSourceERI_V1Dialog.razor.cs @@ -1,4 +1,5 @@ using AIStudio.Assistants.ERI; +using AIStudio.Components; using AIStudio.Settings; using AIStudio.Settings.DataModel; using AIStudio.Tools.ERIClient; @@ -13,7 +14,7 @@ using RetrievalInfo = AIStudio.Tools.ERIClient.DataModel.RetrievalInfo; // ReSharper disable InconsistentNaming namespace AIStudio.Dialogs; -public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId +public partial class DataSourceERI_V1Dialog : MSGComponentBase, ISecretId { [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!; @@ -24,9 +25,6 @@ public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId [Parameter] public DataSourceERI_V1 DataSource { get; set; } - [Inject] - private SettingsManager SettingsManager { get; init; } = null!; - [Inject] private ILogger Logger { get; init; } = null!; @@ -195,7 +193,7 @@ public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId await this.form.Validate(); Array.Resize(ref this.dataIssues, this.dataIssues.Length + 1); - this.dataIssues[^1] = "Failed to connect to the ERI v1 server. The server is not supported."; + this.dataIssues[^1] = T("Failed to connect to the ERI v1 server. The server is not supported."); return; } @@ -254,7 +252,7 @@ public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId await this.form.Validate(); Array.Resize(ref this.dataIssues, this.dataIssues.Length + 1); - this.dataIssues[^1] = $"Failed to connect to the ERI v1 server. The message was: {e.Message}"; + this.dataIssues[^1] = string.Format(T("Failed to connect to the ERI v1 server. The message was: {0}"), e.Message); this.Logger.LogError($"Failed to connect to the ERI v1 server. Message: {e.Message}"); this.connectionTested = true; @@ -265,9 +263,9 @@ public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId private string GetTestResultText() { if(!this.connectionTested) - return "Not tested yet."; + return T("Not tested yet."); - return this.connectionSuccessfulTested ? "Connection successful." : "Connection failed."; + return this.connectionSuccessfulTested ? T("Connection successful.") : T("Connection failed."); } private Color GetTestResultColor() @@ -290,9 +288,9 @@ public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId private string GetSecretLabel() => this.dataAuthMethod switch { - AuthMethod.TOKEN => "Access Token", - AuthMethod.USERNAME_PASSWORD => "Password", - _ => "Secret", + AuthMethod.TOKEN => T("Access Token"), + AuthMethod.USERNAME_PASSWORD => T("Password"), + _ => T("Secret"), }; private async Task Store() @@ -320,7 +318,7 @@ public partial class DataSourceERI_V1Dialog : ComponentBase, ISecretId var storeResponse = await this.RustService.SetSecret(this, this.dataSecret); if (!storeResponse.Success) { - this.dataSecretStorageIssue = $"Failed to store the auth. secret in the operating system. The message was: {storeResponse.Issue}. Please try again."; + this.dataSecretStorageIssue = string.Format(T("Failed to store the auth. secret in the operating system. The message was: {0}. Please try again."), storeResponse.Issue); await this.form.Validate(); return; } diff --git a/app/MindWork AI Studio/Dialogs/DataSourceLocalDirectoryDialog.razor b/app/MindWork AI Studio/Dialogs/DataSourceLocalDirectoryDialog.razor index e7863285..8e5cdc4d 100644 --- a/app/MindWork AI Studio/Dialogs/DataSourceLocalDirectoryDialog.razor +++ b/app/MindWork AI Studio/Dialogs/DataSourceLocalDirectoryDialog.razor @@ -1,4 +1,5 @@ @using AIStudio.Settings.DataModel +@inherits MSGComponentBase @@ -7,7 +8,7 @@ - Select a root directory for this data source. All data in this directory and all - its subdirectories will be processed for this data source. + @T("Select a root directory for this data source. All data in this directory and all its subdirectories will be processed for this data source.") - + - In order for the AI to be able to determine the appropriate data at any time, you must - choose an embedding method. + @T("In order for the AI to be able to determine the appropriate data at any time, you must choose an embedding method.") - + @foreach (var embedding in this.AvailableEmbeddings) { - @embedding.Name + + @embedding.Name + } @@ -43,45 +44,46 @@ @if (string.IsNullOrWhiteSpace(this.dataPath)) { - @: Please note: the embedding you selected runs in the cloud. All your data will be sent to the cloud. - @: Please confirm that you have read and understood this. + @T("Please note: the embedding you selected runs in the cloud. All your data will be sent to the cloud. Please confirm that you have read and understood this.") } else { - @: Please note: the embedding you selected runs in the cloud. All your data from the - @: folder '@this.dataPath' and all its subdirectories will be sent to the cloud. Please - @: confirm that you have read and understood this. + @string.Format(T("Please note: the embedding you selected runs in the cloud. All your data from the folder '{0}' and all its subdirectories will be sent to the cloud. Please confirm that you have read and understood this."), this.dataPath) } - + } else { - The embedding you selected runs locally or in your organization. Your data is not sent to the cloud. + @T("The embedding you selected runs locally or in your organization. Your data is not sent to the cloud.") } } - + @foreach (var policy in Enum.GetValues()) { - @policy.ToSelectionText() + + @policy.ToSelectionText() + } - Cancel + + @T("Cancel") + @if(this.IsEditing) { - @:Update + @T("Update") } else { - @:Add + @T("Add") } diff --git a/app/MindWork AI Studio/Dialogs/DataSourceLocalDirectoryDialog.razor.cs b/app/MindWork AI Studio/Dialogs/DataSourceLocalDirectoryDialog.razor.cs index 16c2e677..a1255913 100644 --- a/app/MindWork AI Studio/Dialogs/DataSourceLocalDirectoryDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/DataSourceLocalDirectoryDialog.razor.cs @@ -1,3 +1,4 @@ +using AIStudio.Components; using AIStudio.Settings; using AIStudio.Settings.DataModel; using AIStudio.Tools.Validation; @@ -6,7 +7,7 @@ using Microsoft.AspNetCore.Components; namespace AIStudio.Dialogs; -public partial class DataSourceLocalDirectoryDialog : ComponentBase +public partial class DataSourceLocalDirectoryDialog : MSGComponentBase { [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!; @@ -20,9 +21,6 @@ public partial class DataSourceLocalDirectoryDialog : ComponentBase [Parameter] public IReadOnlyList> AvailableEmbeddings { get; set; } = []; - [Inject] - private SettingsManager SettingsManager { get; init; } = null!; - private static readonly Dictionary SPELLCHECK_ATTRIBUTES = new(); private readonly DataSourceValidation dataSourceValidation; diff --git a/app/MindWork AI Studio/Dialogs/DataSourceLocalDirectoryInfoDialog.razor b/app/MindWork AI Studio/Dialogs/DataSourceLocalDirectoryInfoDialog.razor index a4b647b0..c38ccaea 100644 --- a/app/MindWork AI Studio/Dialogs/DataSourceLocalDirectoryInfoDialog.razor +++ b/app/MindWork AI Studio/Dialogs/DataSourceLocalDirectoryInfoDialog.razor @@ -1,56 +1,58 @@ @using AIStudio.Settings.DataModel +@inherits MSGComponentBase - + - + @if (!this.IsDirectoryAvailable) { - The directory chosen for the data source does not exist anymore. Please edit the data source and correct the path. + @T("The directory chosen for the data source does not exist anymore. Please edit the data source and correct the path.") } else { - The directory chosen for the data source exists. + @T("The directory chosen for the data source exists.") } - + @if (this.IsCloudEmbedding) { - The embedding runs in the cloud. All your data from the folder '@this.DataSource.Path' and all its subdirectories - will be sent to the cloud. + @string.Format(T("The embedding runs in the cloud. All your data from the folder '{0}' and all its subdirectories will be sent to the cloud."), this.DataSource.Path) } else { - The embedding runs locally or in your organization. Your data is not sent to the cloud. + @T("The embedding runs locally or in your organization. Your data is not sent to the cloud.") } - + - - + + @if (this.directorySizeNumFiles > 100) { - For performance reasons, only the first 100 files are shown. The directory contains @this.NumberFilesInDirectory files in total. + @string.Format(T("For performance reasons, only the first 100 files are shown. The directory contains {0} files in total."), this.NumberFilesInDirectory) } - + @if (this.IsOperationInProgress) { } - Close + + @T("Close") + \ No newline at end of file diff --git a/app/MindWork AI Studio/Dialogs/DataSourceLocalDirectoryInfoDialog.razor.cs b/app/MindWork AI Studio/Dialogs/DataSourceLocalDirectoryInfoDialog.razor.cs index af8c0df8..839fd5b8 100644 --- a/app/MindWork AI Studio/Dialogs/DataSourceLocalDirectoryInfoDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/DataSourceLocalDirectoryInfoDialog.razor.cs @@ -1,5 +1,6 @@ using System.Text; +using AIStudio.Components; using AIStudio.Settings; using AIStudio.Settings.DataModel; @@ -9,16 +10,13 @@ using Timer = System.Timers.Timer; namespace AIStudio.Dialogs; -public partial class DataSourceLocalDirectoryInfoDialog : ComponentBase, IAsyncDisposable +public partial class DataSourceLocalDirectoryInfoDialog : MSGComponentBase, IAsyncDisposable { [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!; [Parameter] public DataSourceLocalDirectory DataSource { get; set; } - - [Inject] - private SettingsManager SettingsManager { get; init; } = null!; private readonly Timer refreshTimer = new(TimeSpan.FromSeconds(1.6)) { diff --git a/app/MindWork AI Studio/Dialogs/DataSourceLocalFileDialog.razor b/app/MindWork AI Studio/Dialogs/DataSourceLocalFileDialog.razor index ebd0a5bc..8da1ced4 100644 --- a/app/MindWork AI Studio/Dialogs/DataSourceLocalFileDialog.razor +++ b/app/MindWork AI Studio/Dialogs/DataSourceLocalFileDialog.razor @@ -1,4 +1,6 @@ @using AIStudio.Settings.DataModel +@inherits MSGComponentBase + @@ -6,7 +8,7 @@ - Select a file for this data source. The content of this file will be processed for the data source. + @T("Select a file for this data source. The content of this file will be processed for the data source.") - + - In order for the AI to be able to determine the appropriate data at any time, you must - choose an embedding method. + @T("In order for the AI to be able to determine the appropriate data at any time, you must choose an embedding method.") - + @foreach (var embedding in this.AvailableEmbeddings) { - @embedding.Name + + @embedding.Name + } @@ -41,45 +44,46 @@ @if (string.IsNullOrWhiteSpace(this.dataFilePath)) { - @: Please note: the embedding you selected runs in the cloud. All your data will be sent to the cloud. - @: Please confirm that you have read and understood this. + @T("Please note: the embedding you selected runs in the cloud. All your data will be sent to the cloud. Please confirm that you have read and understood this.") } else { - @: Please note: the embedding you selected runs in the cloud. All your data within the - @: file '@this.dataFilePath' will be sent to the cloud. Please confirm that you have read - @: and understood this. + @string.Format(T("Please note: the embedding you selected runs in the cloud. All your data within the file '{0}' will be sent to the cloud. Please confirm that you have read and understood this."), this.dataFilePath) } - + } else { - The embedding you selected runs locally or in your organization. Your data is not sent to the cloud. + @T("The embedding you selected runs locally or in your organization. Your data is not sent to the cloud.") } } - + @foreach (var policy in Enum.GetValues()) { - @policy.ToSelectionText() + + @policy.ToSelectionText() + } - Cancel + + @T("Cancel") + @if(this.IsEditing) { - @:Update + @T("Update") } else { - @:Add + @T("Add") } diff --git a/app/MindWork AI Studio/Dialogs/DataSourceLocalFileDialog.razor.cs b/app/MindWork AI Studio/Dialogs/DataSourceLocalFileDialog.razor.cs index 902899fe..0ee52f43 100644 --- a/app/MindWork AI Studio/Dialogs/DataSourceLocalFileDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/DataSourceLocalFileDialog.razor.cs @@ -1,3 +1,4 @@ +using AIStudio.Components; using AIStudio.Settings; using AIStudio.Settings.DataModel; using AIStudio.Tools.Validation; @@ -6,7 +7,7 @@ using Microsoft.AspNetCore.Components; namespace AIStudio.Dialogs; -public partial class DataSourceLocalFileDialog : ComponentBase +public partial class DataSourceLocalFileDialog : MSGComponentBase { [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!; @@ -20,9 +21,6 @@ public partial class DataSourceLocalFileDialog : ComponentBase [Parameter] public IReadOnlyList> AvailableEmbeddings { get; set; } = []; - [Inject] - private SettingsManager SettingsManager { get; init; } = null!; - private static readonly Dictionary SPELLCHECK_ATTRIBUTES = new(); private readonly DataSourceValidation dataSourceValidation; diff --git a/app/MindWork AI Studio/Dialogs/DataSourceLocalFileInfoDialog.razor b/app/MindWork AI Studio/Dialogs/DataSourceLocalFileInfoDialog.razor index 0605ff93..1999d27f 100644 --- a/app/MindWork AI Studio/Dialogs/DataSourceLocalFileInfoDialog.razor +++ b/app/MindWork AI Studio/Dialogs/DataSourceLocalFileInfoDialog.razor @@ -1,42 +1,44 @@ @using AIStudio.Settings.DataModel +@inherits MSGComponentBase - + - + @if (!this.IsFileAvailable) { - The file chosen for the data source does not exist anymore. Please edit the data source and choose another file or correct the path. + @T("The file chosen for the data source does not exist anymore. Please edit the data source and choose another file or correct the path.") } else { - The file chosen for the data source exists. + @T("The file chosen for the data source exists.") } - + @if (this.IsCloudEmbedding) { - The embedding runs in the cloud. All your data within the - file '@this.DataSource.FilePath' will be sent to the cloud. + @string.Format(T("The embedding runs in the cloud. All your data within the file '{0}' will be sent to the cloud."), this.DataSource.FilePath) } else { - The embedding runs locally or in your organization. Your data is not sent to the cloud. + @T("The embedding runs locally or in your organization. Your data is not sent to the cloud.") } - - + + - Close + + @T("Close") + \ No newline at end of file diff --git a/app/MindWork AI Studio/Dialogs/DataSourceLocalFileInfoDialog.razor.cs b/app/MindWork AI Studio/Dialogs/DataSourceLocalFileInfoDialog.razor.cs index 7dc204c1..0601c182 100644 --- a/app/MindWork AI Studio/Dialogs/DataSourceLocalFileInfoDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/DataSourceLocalFileInfoDialog.razor.cs @@ -1,3 +1,4 @@ +using AIStudio.Components; using AIStudio.Settings; using AIStudio.Settings.DataModel; @@ -5,16 +6,13 @@ using Microsoft.AspNetCore.Components; namespace AIStudio.Dialogs; -public partial class DataSourceLocalFileInfoDialog : ComponentBase +public partial class DataSourceLocalFileInfoDialog : MSGComponentBase { [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!; [Parameter] public DataSourceLocalFile DataSource { get; set; } - - [Inject] - private SettingsManager SettingsManager { get; init; } = null!; #region Overrides of ComponentBase diff --git a/app/MindWork AI Studio/Dialogs/EmbeddingMethodDialog.razor b/app/MindWork AI Studio/Dialogs/EmbeddingMethodDialog.razor index 5d8da890..44e697cf 100644 --- a/app/MindWork AI Studio/Dialogs/EmbeddingMethodDialog.razor +++ b/app/MindWork AI Studio/Dialogs/EmbeddingMethodDialog.razor @@ -1,3 +1,5 @@ +@inherits MSGComponentBase + @@ -5,8 +7,8 @@ - - + + @* ReSharper disable once CSharpWarnings::CS8974 *@ - Cancel + + @T("Cancel") + @if(this.IsEditing) { - @:Update + @T("Update") } else { - @:Add + @T("Add") } diff --git a/app/MindWork AI Studio/Dialogs/EmbeddingMethodDialog.razor.cs b/app/MindWork AI Studio/Dialogs/EmbeddingMethodDialog.razor.cs index 36ee9417..b7667656 100644 --- a/app/MindWork AI Studio/Dialogs/EmbeddingMethodDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/EmbeddingMethodDialog.razor.cs @@ -1,11 +1,12 @@ using AIStudio.Assistants.ERI; +using AIStudio.Components; using AIStudio.Settings; using Microsoft.AspNetCore.Components; namespace AIStudio.Dialogs; -public partial class EmbeddingMethodDialog : ComponentBase +public partial class EmbeddingMethodDialog : MSGComponentBase { [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!; @@ -52,9 +53,6 @@ public partial class EmbeddingMethodDialog : ComponentBase [Parameter] public bool IsEditing { get; init; } - [Inject] - private SettingsManager SettingsManager { get; init; } = null!; - private static readonly Dictionary SPELLCHECK_ATTRIBUTES = new(); private bool dataIsValid; @@ -90,13 +88,13 @@ public partial class EmbeddingMethodDialog : ComponentBase private string? ValidateName(string name) { if (string.IsNullOrWhiteSpace(name)) - return "The embedding name must not be empty. Please name the embedding."; + return T("The embedding name must not be empty. Please name the embedding."); if (name.Length > 26) - return "The embedding name must not be longer than 26 characters."; + return T("The embedding name must not be longer than 26 characters."); if (this.UsedEmbeddingMethodNames.Contains(name)) - return $"The embedding method name '{name}' is already used. Please choose a unique name."; + return string.Format(T("The embedding method name '{0}' is already used. Please choose a unique name."), name); return null; } @@ -104,10 +102,10 @@ public partial class EmbeddingMethodDialog : ComponentBase private string? ValidateType(string type) { if (string.IsNullOrWhiteSpace(type)) - return "The embedding type must not be empty. Please specify the embedding type."; + return T("The embedding type must not be empty. Please specify the embedding type."); if (type.Length > 56) - return "The embedding type must not be longer than 56 characters."; + return T("The embedding type must not be longer than 56 characters."); return null; } @@ -115,7 +113,7 @@ public partial class EmbeddingMethodDialog : ComponentBase private string? ValidateDescription(string description) { if (string.IsNullOrWhiteSpace(description)) - return "The description must not be empty. Please describe the embedding method."; + return T("The description must not be empty. Please describe the embedding method."); return null; } @@ -123,7 +121,7 @@ public partial class EmbeddingMethodDialog : ComponentBase private string? ValidateUsedWhen(string usedWhen) { if (string.IsNullOrWhiteSpace(usedWhen)) - return "Please describe when the embedding is used. Might be anytime or when certain keywords are present, etc."; + return T("Please describe when the embedding is used. Might be anytime or when certain keywords are present, etc."); return null; } diff --git a/app/MindWork AI Studio/Dialogs/RetrievalProcessDialog.razor b/app/MindWork AI Studio/Dialogs/RetrievalProcessDialog.razor index fb7e3b00..72590f20 100644 --- a/app/MindWork AI Studio/Dialogs/RetrievalProcessDialog.razor +++ b/app/MindWork AI Studio/Dialogs/RetrievalProcessDialog.razor @@ -1,24 +1,25 @@ @using AIStudio.Assistants.ERI @using MudExtensions +@inherits MSGComponentBase + - General Information + @T("General Information") - Please provide some general information about your retrieval process first. This data may be - displayed to the users. + @T("Please provide some general information about your retrieval process first. This data may be displayed to the users.") @* ReSharper disable once CSharpWarnings::CS8974 *@ - Retrieval Process Parameters + @T("Retrieval Process Parameters") - You may want to parameterize your retrieval process. However, this is optional. You can specify any - parameters that can be set by the user or the system during the call. Nevertheless, you should use - sensible default values in your code so that users are not forced to set the parameters manually. + @T("You may want to parameterize your retrieval process. However, this is optional. You can specify any parameters that can be set by the user or the system during the call. Nevertheless, you should use sensible default values in your code so that users are not forced to set the parameters manually.") @@ -87,7 +86,7 @@ } - Add Parameter + @T("Add Parameter") @@ -98,13 +97,13 @@ @if(this.retrievalParameters.Count == 0) { - Add a parameter first, then select it to edit. + @T("Add a parameter first, then select it to edit.") } else { - Select a parameter to show and edit it. + @T("Select a parameter to show and edit it.") } } @@ -114,8 +113,8 @@ - Delete this parameter + @T("Delete this parameter") @@ -155,22 +154,19 @@ - Embeddings + @T("Embeddings") @if(this.AvailableEmbeddings.Count == 0) { - Currently, you have not defined any embedding methods. If your retrieval process does not require embedding, you can ignore this part. - Otherwise, you can define one or more embedding methods in the previous view to assign them to your retrieval process here. + @T("Currently, you have not defined any embedding methods. If your retrieval process does not require embedding, you can ignore this part. Otherwise, you can define one or more embedding methods in the previous view to assign them to your retrieval process here.") } else { - Here you can select which embedding methods are used for this retrieval process. Embeddings are optional; - if your retrieval process works without embedding, you can ignore this part. You can only choose the embedding - methods you have previously defined. + @T("Here you can select which embedding methods are used for this retrieval process. Embeddings are optional; if your retrieval process works without embedding, you can ignore this part. You can only choose the embedding methods you have previously defined.") + HelperText="@T("Optional. Select the embedding methods that are used for this retrieval process.")"> @foreach (var embedding in this.AvailableEmbeddings) { @@ -198,15 +194,17 @@ - Cancel + + @T("Cancel") + @if(this.IsEditing) { - @:Update + @T("Update") } else { - @:Add + @T("Add") } diff --git a/app/MindWork AI Studio/Dialogs/RetrievalProcessDialog.razor.cs b/app/MindWork AI Studio/Dialogs/RetrievalProcessDialog.razor.cs index 99b5d9f8..7aa33760 100644 --- a/app/MindWork AI Studio/Dialogs/RetrievalProcessDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/RetrievalProcessDialog.razor.cs @@ -1,11 +1,11 @@ using AIStudio.Assistants.ERI; -using AIStudio.Settings; +using AIStudio.Components; using Microsoft.AspNetCore.Components; namespace AIStudio.Dialogs; -public partial class RetrievalProcessDialog : ComponentBase +public partial class RetrievalProcessDialog : MSGComponentBase { [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!; @@ -60,9 +60,6 @@ public partial class RetrievalProcessDialog : ComponentBase [Parameter] public bool IsEditing { get; init; } - [Inject] - private SettingsManager SettingsManager { get; init; } = null!; - private static readonly Dictionary SPELLCHECK_ATTRIBUTES = new(); private bool dataIsValid; @@ -80,13 +77,13 @@ public partial class RetrievalProcessDialog : ComponentBase protected override async Task OnInitializedAsync() { + await base.OnInitializedAsync(); + // Configure the spellchecking for the instance name input: this.SettingsManager.InjectSpellchecking(SPELLCHECK_ATTRIBUTES); // Convert the parameters: this.retrievalParameters = this.DataParametersDescription.Select(pair => new RetrievalParameter { Name = pair.Key, Description = pair.Value }).ToList(); - - await base.OnInitializedAsync(); } protected override async Task OnAfterRenderAsync(bool firstRender) @@ -104,13 +101,13 @@ public partial class RetrievalProcessDialog : ComponentBase private string? ValidateName(string name) { if (string.IsNullOrWhiteSpace(name)) - return "The retrieval process name must not be empty. Please name your retrieval process."; + return T("The retrieval process name must not be empty. Please name your retrieval process."); if (name.Length > 26) - return "The retrieval process name must not be longer than 26 characters."; + return T("The retrieval process name must not be longer than 26 characters."); if (this.UsedRetrievalProcessNames.Contains(name)) - return $"The retrieval process name '{name}' must be unique. Please choose a different name."; + return string.Format(T("The retrieval process name '{0}' must be unique. Please choose a different name."), name); return null; } @@ -118,26 +115,26 @@ public partial class RetrievalProcessDialog : ComponentBase private string? ValidateDescription(string description) { if (string.IsNullOrWhiteSpace(description)) - return "The description must not be empty. Please describe the retrieval process."; + return T("The description must not be empty. Please describe the retrieval process."); return null; } private void AddRetrievalProcessParameter() { - this.retrievalParameters.Add(new() { Name = $"New Parameter {this.nextParameterId++}", Description = string.Empty }); + this.retrievalParameters.Add(new() { Name = string.Format(T("New Parameter {0}"), this.nextParameterId++), Description = string.Empty }); } private string? ValidateParameterName(string name) { if (string.IsNullOrWhiteSpace(name)) - return "The parameter name must not be empty. Please name the parameter."; + return T("The parameter name must not be empty. Please name the parameter."); if(name.Length > 26) - return "The parameter name must not be longer than 26 characters."; + return T("The parameter name must not be longer than 26 characters."); if (this.retrievalParameters.Count(parameter => parameter.Name == name) > 1) - return $"The parameter name '{name}' must be unique. Please choose a different name."; + return string.Format(T("The parameter name '{0}' must be unique. Please choose a different name."), name); return null; } @@ -145,7 +142,7 @@ public partial class RetrievalProcessDialog : ComponentBase private string? ValidateParameterDescription(string description) { if (string.IsNullOrWhiteSpace(description)) - return $"The parameter description must not be empty. Please describe the parameter '{this.selectedParameter?.Name}'. What data type is it? What is it used for? What are the possible values?"; + return string.Format(T("The parameter description must not be empty. Please describe the parameter '{0}'. What data type is it? What is it used for? What are the possible values?"), this.selectedParameter?.Name); return null; } @@ -156,7 +153,7 @@ public partial class RetrievalProcessDialog : ComponentBase return nameIssue; if (string.IsNullOrWhiteSpace(parameter.Description)) - return $"The parameter description must not be empty. Please describe the parameter '{parameter.Name}'. What data type is it? What is it used for? What are the possible values?"; + return string.Format(T("The parameter description must not be empty. Please describe the parameter '{0}'. What data type is it? What is it used for? What are the possible values?"), parameter.Name); return null; } @@ -172,12 +169,12 @@ public partial class RetrievalProcessDialog : ComponentBase private string GetMultiSelectionText(List selectedEmbeddings) { if(selectedEmbeddings.Count == 0) - return "No embedding methods selected."; + return T("No embedding methods selected."); if(selectedEmbeddings.Count == 1) - return "You have selected 1 embedding method."; + return T("You have selected 1 embedding method."); - return $"You have selected {selectedEmbeddings.Count} embedding methods."; + return string.Format(T("You have selected {0} embedding methods."), selectedEmbeddings.Count); } private void EmbeddingsChanged(IEnumerable? updatedEmbeddings)