mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-05 08:29:40 +00:00
Added more text content to the I18N system (#446)
This commit is contained in:
1 parent
cfc2103b43
commit
7a08baf99b
43 files changed
+3356
-354
No files matched your search
@@ -1,10 +1,13 @@
|
||||
using AIStudio.Settings.DataModel;
|
||||
using AIStudio.Tools.ERIClient.DataModel;
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
|
||||
namespace AIStudio.Tools.Validation;
|
||||
|
||||
public sealed class DataSourceValidation
|
||||
{
|
||||
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(DataSourceValidation).Namespace, nameof(DataSourceValidation));
|
||||
|
||||
public Func<string> GetSecretStorageIssue { get; init; } = () => string.Empty;
|
||||
|
||||
public Func<string> GetPreviousDataSourceName { get; init; } = () => string.Empty;
|
||||
@@ -26,13 +29,13 @@ public sealed class DataSourceValidation
|
||||
public string? ValidatingHostname(string hostname)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(hostname))
|
||||
return "Please enter a hostname, e.g., http://localhost";
|
||||
return TB("Please enter a hostname, e.g., http://localhost");
|
||||
|
||||
if(!hostname.StartsWith("http://", StringComparison.InvariantCultureIgnoreCase) && !hostname.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase))
|
||||
return "The hostname must start with either http:// or https://";
|
||||
return TB("The hostname must start with either http:// or https://");
|
||||
|
||||
if(!Uri.TryCreate(hostname, UriKind.Absolute, out _))
|
||||
return "The hostname is not a valid HTTP(S) URL.";
|
||||
return TB("The hostname is not a valid HTTP(S) URL.");
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -40,7 +43,7 @@ public sealed class DataSourceValidation
|
||||
public string? ValidatePort(int port)
|
||||
{
|
||||
if(port is < 1 or > 65535)
|
||||
return "The port must be between 1 and 65535.";
|
||||
return TB("The port must be between 1 and 65535.");
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -48,14 +51,14 @@ public sealed class DataSourceValidation
|
||||
public string? ValidateSecurityPolicy(DataSourceSecurity securityPolicy)
|
||||
{
|
||||
if(securityPolicy is DataSourceSecurity.NOT_SPECIFIED)
|
||||
return "Please select your security policy.";
|
||||
return TB("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 "This data source can only be used with a self-hosted LLM provider. Please change the security policy.";
|
||||
return TB("This data source can only be used with a self-hosted LLM provider. Please change the security policy.");
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -66,7 +69,7 @@ public sealed class DataSourceValidation
|
||||
return null;
|
||||
|
||||
if(string.IsNullOrWhiteSpace(username))
|
||||
return "The username must not be empty.";
|
||||
return TB("The username must not be empty.");
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -84,10 +87,10 @@ public sealed class DataSourceValidation
|
||||
if (string.IsNullOrWhiteSpace(secret))
|
||||
return authMethod switch
|
||||
{
|
||||
AuthMethod.TOKEN => "Please enter your secure access token.",
|
||||
AuthMethod.USERNAME_PASSWORD => "Please enter your password.",
|
||||
AuthMethod.TOKEN => TB("Please enter your secure access token."),
|
||||
AuthMethod.USERNAME_PASSWORD => TB("Please enter your password."),
|
||||
|
||||
_ => "Please enter the secret necessary for authentication."
|
||||
_ => TB("Please enter the secret necessary for authentication.")
|
||||
};
|
||||
|
||||
return null;
|
||||
@@ -96,7 +99,7 @@ public sealed class DataSourceValidation
|
||||
public string? ValidateRetrievalProcess(RetrievalInfo retrievalInfo)
|
||||
{
|
||||
if(retrievalInfo == default)
|
||||
return "Please select one retrieval process.";
|
||||
return TB("Please select one retrieval process.");
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -104,14 +107,14 @@ public sealed class DataSourceValidation
|
||||
public string? ValidatingName(string dataSourceName)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(dataSourceName))
|
||||
return "The name must not be empty.";
|
||||
return TB("The name must not be empty.");
|
||||
|
||||
if (dataSourceName.Length > 40)
|
||||
return "The name must not exceed 40 characters.";
|
||||
return TB("The name must not exceed 40 characters.");
|
||||
|
||||
var lowerName = dataSourceName.ToLowerInvariant();
|
||||
if(lowerName != this.GetPreviousDataSourceName() && this.GetUsedDataSourceNames().Contains(lowerName))
|
||||
return "The name is already used by another data source. Please choose a different name.";
|
||||
return TB("The name is already used by another data source. Please choose a different name.");
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -119,10 +122,10 @@ public sealed class DataSourceValidation
|
||||
public string? ValidatePath(string path)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(path))
|
||||
return "The path must not be empty. Please select a directory.";
|
||||
return TB("The path must not be empty. Please select a directory.");
|
||||
|
||||
if(!Directory.Exists(path))
|
||||
return "The path does not exist. Please select a valid directory.";
|
||||
return TB("The path does not exist. Please select a valid directory.");
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -130,10 +133,10 @@ public sealed class DataSourceValidation
|
||||
public string? ValidateFilePath(string filePath)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(filePath))
|
||||
return "The file path must not be empty. Please select a file.";
|
||||
return TB("The file path must not be empty. Please select a file.");
|
||||
|
||||
if(!File.Exists(filePath))
|
||||
return "The file does not exist. Please select a valid file.";
|
||||
return TB("The file does not exist. Please select a valid file.");
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -141,7 +144,7 @@ public sealed class DataSourceValidation
|
||||
public string? ValidateEmbeddingId(string embeddingId)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(embeddingId))
|
||||
return "Please select an embedding provider.";
|
||||
return TB("Please select an embedding provider.");
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -149,7 +152,7 @@ public sealed class DataSourceValidation
|
||||
public string? ValidateUserAcknowledgedCloudEmbedding(bool value)
|
||||
{
|
||||
if(this.GetSelectedCloudEmbedding() && !value)
|
||||
return "Please acknowledge that you are aware of the cloud embedding implications.";
|
||||
return TB("Please acknowledge that you are aware of the cloud embedding implications.");
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -157,10 +160,10 @@ public sealed class DataSourceValidation
|
||||
public string? ValidateTestedConnection()
|
||||
{
|
||||
if(!this.GetTestedConnection())
|
||||
return "Please test the connection before saving.";
|
||||
return TB("Please test the connection before saving.");
|
||||
|
||||
if(!this.GetTestedConnectionResult())
|
||||
return "The connection test failed. Please check the connection settings.";
|
||||
return TB("The connection test failed. Please check the connection settings.");
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -168,7 +171,7 @@ public sealed class DataSourceValidation
|
||||
public string? ValidateAuthMethod(AuthMethod authMethod)
|
||||
{
|
||||
if(!this.GetAvailableAuthMethods().Contains(authMethod))
|
||||
return "Please select one valid authentication method.";
|
||||
return TB("Please select one valid authentication method.");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user