Added the choice between formal and informal address to the whole app (#1200)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-13 10:16:56 +01:00
1 parent 382db4b8d0
commit c9a376f742
342 files changed
+14378 -1893

No files matched your search

@@ -17,6 +17,8 @@ public sealed class DataSourceValidation
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(DataSourceValidation).Namespace, nameof(DataSourceValidation));
private static string TA(string fallbackEN) => I18N.I.TA(fallbackEN, typeof(DataSourceValidation).Namespace, nameof(DataSourceValidation));
public static bool IsNameValid(string name) => !string.IsNullOrWhiteSpace(name) && name.Length <= MAX_NAME_LENGTH && !name.Any(char.IsControl);
public Func<string> GetSecretStorageIssue { get; init; } = () => string.Empty;
@@ -48,7 +50,7 @@ public sealed class DataSourceValidation
public string? ValidatingHostname(string hostname)
{
if(string.IsNullOrWhiteSpace(hostname))
return TB("Please enter a hostname, e.g., http://localhost");
return TA("Please enter a hostname, e.g., http://localhost");
if(!hostname.StartsWith("http://", StringComparison.InvariantCultureIgnoreCase) && !hostname.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase))
return TB("The hostname must start with either http:// or https://");
@@ -70,14 +72,14 @@ public sealed class DataSourceValidation
public string? ValidateSecurityPolicy(DataSourceSecurity securityPolicy)
{
if(securityPolicy is DataSourceSecurity.NOT_SPECIFIED)
return TB("Please select your security policy.");
return TA("Please select your security policy.");
var dataSourceSecurity = this.GetSecurityRequirements();
if (dataSourceSecurity is null)
return null;
if(dataSourceSecurity.Value.AllowedProviderType is ProviderType.SELF_HOSTED && securityPolicy is not DataSourceSecurity.SELF_HOSTED)
return TB("This data source can only be used with a self-hosted LLM provider. Please change the security policy.");
return TA("This data source can only be used with a self-hosted LLM provider. Please change the security policy.");
return null;
}
@@ -106,10 +108,10 @@ public sealed class DataSourceValidation
if (string.IsNullOrWhiteSpace(secret))
return authMethod switch
{
AuthMethod.TOKEN => TB("Please enter your secure access token."),
AuthMethod.USERNAME_PASSWORD => TB("Please enter your password."),
AuthMethod.TOKEN => TA("Please enter your secure access token."),
AuthMethod.USERNAME_PASSWORD => TA("Please enter your password."),
_ => TB("Please enter the secret necessary for authentication.")
_ => TA("Please enter the secret necessary for authentication.")
};
return null;
@@ -118,7 +120,7 @@ public sealed class DataSourceValidation
public string? ValidateRetrievalProcess(RetrievalInfo retrievalInfo)
{
if(retrievalInfo == default)
return TB("Please select one retrieval process.");
return TA("Please select one retrieval process.");
return null;
}
@@ -136,7 +138,7 @@ public sealed class DataSourceValidation
var lowerName = dataSourceName.ToLowerInvariant();
if(lowerName != this.GetPreviousDataSourceName() && this.GetUsedDataSourceNames().Contains(lowerName))
return TB("The name is already used by another data source. Please choose a different name.");
return TA("The name is already used by another data source. Please choose a different name.");
return null;
}
@@ -144,10 +146,10 @@ public sealed class DataSourceValidation
public string? ValidatePath(string path)
{
if(string.IsNullOrWhiteSpace(path))
return TB("The path must not be empty. Please select a directory.");
return TA("The path must not be empty. Please select a directory.");
if(!Directory.Exists(path))
return TB("The path does not exist. Please select a valid directory.");
return TA("The path does not exist. Please select a valid directory.");
return null;
}
@@ -155,10 +157,10 @@ public sealed class DataSourceValidation
public string? ValidateFilePath(string filePath)
{
if(string.IsNullOrWhiteSpace(filePath))
return TB("The file path must not be empty. Please select a file.");
return TA("The file path must not be empty. Please select a file.");
if(!File.Exists(filePath))
return TB("The file does not exist. Please select a valid file.");
return TA("The file does not exist. Please select a valid file.");
if(!FileTypes.IsAllowedPath(filePath, FileTypes.DOCUMENT, FileTypes.AUDIO, FileTypes.VIDEO))
return TB("The selected file is not a supported document, readable text file, audio file, or video file.");
@@ -171,7 +173,7 @@ public sealed class DataSourceValidation
public string? ValidateEmbeddingId(string embeddingId)
{
if(string.IsNullOrWhiteSpace(embeddingId))
return TB("Please select an embedding provider.");
return TA("Please select an embedding provider.");
return null;
}
@@ -187,11 +189,11 @@ public sealed class DataSourceValidation
// data source keeps pointing at a provider nobody can reach, and nothing of it is embedded:
//
if(this.GetSelectedEmbeddingProvider() is not { } selectedEmbedding)
return TB("The embedding provider of this data source no longer exists. Please select another one.");
return TA("The embedding provider of this data source no longer exists. Please select another one.");
// Saved like this, nothing of the data source would ever be embedded:
if(this.GetSettingsManager() is { } settingsManager && settingsManager.IsProviderProhibited(selectedEmbedding.UsedLLMProvider))
return TB("The use of this embedding provider has been prohibited by your organization. Please select a different embedding provider.");
return TA("The use of this embedding provider has been prohibited by your organization. Please select a different embedding provider.");
return this.ValidateSelectedEmbeddingProviderAccess();
}
@@ -199,7 +201,7 @@ public sealed class DataSourceValidation
public string? ValidateDataSourceConfidenceLevel(ConfidenceLevel confidenceLevel)
{
if(confidenceLevel is ConfidenceLevel.NONE)
return TB("Please select a required provider confidence level.");
return TA("Please select a required provider confidence level.");
return this.ValidateSelectedEmbeddingProviderAccess();
}
@@ -207,7 +209,7 @@ public sealed class DataSourceValidation
public string? ValidateMailboxConfidenceLevel(ConfidenceLevel confidenceLevel)
{
if(confidenceLevel is ConfidenceLevel.NONE)
return TB("Please select a required provider confidence level.");
return TA("Please select a required provider confidence level.");
if(!confidenceLevel.IsAllowedMailboxConfidence)
return string.Format(TB("A mailbox requires a provider confidence level from '{0}' to '{1}'."), ConfidenceLevel.VERY_LOW.Name, ConfidenceLevel.HIGH.Name);
@@ -218,10 +220,10 @@ public sealed class DataSourceValidation
public static string? ValidateMailboxHost(string host)
{
if(string.IsNullOrWhiteSpace(host))
return TB("Please enter the host of the IMAP server, e.g., imap.example.org.");
return TA("Please enter the host of the IMAP server, e.g., imap.example.org.");
if(Uri.CheckHostName(host.Trim()) is not (UriHostNameType.Dns or UriHostNameType.IPv4 or UriHostNameType.IPv6))
return TB("Please enter the host alone, without a protocol, a port, or a path, e.g., imap.example.org.");
return TA("Please enter the host alone, without a protocol, a port, or a path, e.g., imap.example.org.");
return null;
}
@@ -229,7 +231,7 @@ public sealed class DataSourceValidation
public static string? ValidateMailboxTransportSecurity(MailboxTransportSecurity transportSecurity)
{
if(transportSecurity is MailboxTransportSecurity.UNKNOWN)
return TB("Please select how the connection to the server is encrypted.");
return TA("Please select how the connection to the server is encrypted.");
return null;
}
@@ -249,7 +251,7 @@ public sealed class DataSourceValidation
return secretStorageIssue;
if(string.IsNullOrEmpty(password))
return TB("Please enter your password.");
return TA("Please enter your password.");
return null;
}
@@ -265,10 +267,10 @@ public sealed class DataSourceValidation
public string? ValidateUserAcknowledgedCloudEmbedding(bool value)
{
if(this.GetSelectedCloudTranscription() && !value)
return TB("Please acknowledge that you are aware of the cloud transcription implications.");
return TA("Please acknowledge that you are aware of the cloud transcription implications.");
if(this.GetSelectedCloudEmbedding() && !value)
return TB("Please acknowledge that you are aware of the cloud embedding implications.");
return TA("Please acknowledge that you are aware of the cloud embedding implications.");
return null;
}
@@ -276,10 +278,10 @@ public sealed class DataSourceValidation
public string? ValidateTestedConnection()
{
if(!this.GetTestedConnection())
return TB("Please test the connection before saving.");
return TA("Please test the connection before saving.");
if(!this.GetTestedConnectionResult())
return TB("The connection test failed. Please check the connection settings.");
return TA("The connection test failed. Please check the connection settings.");
return null;
}
@@ -287,7 +289,7 @@ public sealed class DataSourceValidation
public string? ValidateAuthMethod(AuthMethod authMethod)
{
if(!this.GetAvailableAuthMethods().Contains(authMethod))
return TB("Please select one valid authentication method.");
return TA("Please select one valid authentication method.");
return null;
}
@@ -304,7 +306,7 @@ public sealed class DataSourceValidation
return null;
return string.Format(
TB("The selected embedding provider has confidence '{0}', but this data source requires provider confidence '{1}'. Select an embedding provider with equal or higher confidence or lower the required confidence level."),
TA("The selected embedding provider has confidence '{0}', but this data source requires provider confidence '{1}'. Select an embedding provider with equal or higher confidence or lower the required confidence level."),
selectedEmbedding.GetConfidenceLevel(settingsManager).Name,
confidenceLevel.Name);
}
@@ -11,6 +11,8 @@ public static class FileExtensionValidation
{
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(FileExtensionValidation).Namespace, nameof(FileExtensionValidation));
private static string TA(string fallbackEN) => I18N.I.TA(fallbackEN, typeof(FileExtensionValidation).Namespace, nameof(FileExtensionValidation));
/// <summary>
/// Defines the use cases for file extension validation.
/// </summary>
@@ -46,7 +48,7 @@ public static class FileExtensionValidation
{
await MessageBus.INSTANCE.SendWarning(new(
AppIcons.DOCUMENT,
TB("This file format is not supported. Please convert the .doc file to .docx (e.g. with Microsoft Word).")));
TA("This file format is not supported. Please convert the .doc file to .docx (e.g. with Microsoft Word).")));
return false;
}
@@ -77,7 +79,7 @@ public static class FileExtensionValidation
case UseCase.ATTACHING_CONTENT when !FileTypes.IsAllowedPath(filePath, FileTypes.MODEL_IMAGE):
await MessageBus.INSTANCE.SendWarning(new(
AppIcons.IMAGE_NOT_SUPPORTED,
string.Format(TB("AI Studio cannot give {0} images to an AI model. Please convert the image to JPG or PNG."), Path.GetExtension(filePath).TrimStart('.').ToUpperInvariant())));
string.Format(TA("AI Studio cannot give {0} images to an AI model. Please convert the image to JPG or PNG."), Path.GetExtension(filePath).TrimStart('.').ToUpperInvariant())));
return false;
// In this use case, we don't validate the provider capabilities:
@@ -9,6 +9,8 @@ namespace AIStudio.Tools.Validation;
public sealed class ProviderValidation
{
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(ProviderValidation).Namespace, nameof(ProviderValidation));
private static string TA(string fallbackEN) => I18N.I.TA(fallbackEN, typeof(ProviderValidation).Namespace, nameof(ProviderValidation));
public Func<LLMProviders> GetProvider { get; init; } = () => LLMProviders.NONE;
@@ -36,7 +38,7 @@ public sealed class ProviderValidation
return null;
if(string.IsNullOrWhiteSpace(hostname))
return TB("Please enter a hostname, e.g., http://localhost:1234");
return TA("Please enter a hostname, e.g., http://localhost:1234");
if(!hostname.StartsWith("http://", StringComparison.InvariantCultureIgnoreCase) && !hostname.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase))
return TB("The hostname must start with either http:// or https://");
@@ -61,7 +63,7 @@ public sealed class ProviderValidation
return null;
if(string.IsNullOrWhiteSpace(apiKey))
return TB("Please enter an API key.");
return TA("Please enter an API key.");
return null;
}
@@ -69,7 +71,7 @@ public sealed class ProviderValidation
public string? ValidatingInstanceName(string instanceName)
{
if (string.IsNullOrWhiteSpace(instanceName))
return TB("Please enter an instance name.");
return TA("Please enter an instance name.");
if (instanceName.Length > 40)
return TB("The instance name must not exceed 40 characters.");
@@ -102,7 +104,7 @@ public sealed class ProviderValidation
return null;
if (model == default)
return TB("Please select a model.");
return TA("Please select a model.");
return null;
}
@@ -110,7 +112,7 @@ public sealed class ProviderValidation
public string? ValidatingProvider(LLMProviders llmProvider)
{
if (llmProvider == LLMProviders.NONE)
return TB("Please select a provider.");
return TA("Please select a provider.");
return null;
}
@@ -121,7 +123,7 @@ public sealed class ProviderValidation
return null;
if (host == Host.NONE)
return TB("Please select a host.");
return TA("Please select a host.");
return null;
}
@@ -132,7 +134,7 @@ public sealed class ProviderValidation
return null;
if (!inferenceProvider.SupportsChat)
return TB("Please select an Hugging Face inference provider.");
return TA("Please select an Hugging Face inference provider.");
return null;
}
@@ -163,10 +165,10 @@ public sealed class ProviderValidation
return null;
if (inferenceProvider is HFInferenceProvider.NONE)
return TB("Please select an Hugging Face inference provider.");
return TA("Please select an Hugging Face inference provider.");
if (!inferenceProvider.SupportsEmbeddings)
return TB("This Hugging Face inference provider does not create embeddings. Please select another one.");
return TA("This Hugging Face inference provider does not create embeddings. Please select another one.");
return null;
}
@@ -186,10 +188,10 @@ public sealed class ProviderValidation
return null;
if (inferenceProvider is HFInferenceProvider.NONE)
return TB("Please select an Hugging Face inference provider.");
return TA("Please select an Hugging Face inference provider.");
if (!inferenceProvider.SupportsTranscription)
return TB("This Hugging Face inference provider does not transcribe audio. Please select another one.");
return TA("This Hugging Face inference provider does not transcribe audio. Please select another one.");
return null;
}