Added more text content to the I18N system (#446)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2025-05-04 14:59:30 +02:00
1 parent cfc2103b43
commit 7a08baf99b
43 files changed
+3356 -354

No files matched your search

@@ -1,11 +1,15 @@
using AIStudio.Provider;
using AIStudio.Provider.HuggingFace;
using AIStudio.Tools.PluginSystem;
using Host = AIStudio.Provider.SelfHosted.Host;
namespace AIStudio.Tools.Validation;
public sealed class ProviderValidation
{
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(ProviderValidation).Namespace, nameof(ProviderValidation));
public Func<LLMProviders> GetProvider { get; init; } = () => LLMProviders.NONE;
public Func<string> GetAPIKeyStorageIssue { get; init; } = () => string.Empty;
@@ -22,13 +26,13 @@ public sealed class ProviderValidation
return null;
if(string.IsNullOrWhiteSpace(hostname))
return "Please enter a hostname, e.g., http://localhost:1234";
return TB("Please enter a hostname, e.g., http://localhost:1234");
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;
}
@@ -43,7 +47,7 @@ public sealed class ProviderValidation
return apiKeyStorageIssue;
if(string.IsNullOrWhiteSpace(apiKey))
return "Please enter an API key.";
return TB("Please enter an API key.");
return null;
}
@@ -51,15 +55,15 @@ public sealed class ProviderValidation
public string? ValidatingInstanceName(string instanceName)
{
if (string.IsNullOrWhiteSpace(instanceName))
return "Please enter an instance name.";
return TB("Please enter an instance name.");
if (instanceName.Length > 40)
return "The instance name must not exceed 40 characters.";
return TB("The instance name must not exceed 40 characters.");
// The instance name must be unique:
var lowerInstanceName = instanceName.ToLowerInvariant();
if (lowerInstanceName != this.GetPreviousInstanceName() && this.GetUsedInstanceNames().Contains(lowerInstanceName))
return "The instance name must be unique; the chosen name is already in use.";
return TB("The instance name must be unique; the chosen name is already in use.");
return null;
}
@@ -70,7 +74,7 @@ public sealed class ProviderValidation
return null;
if (model == default)
return "Please select a model.";
return TB("Please select a model.");
return null;
}
@@ -78,7 +82,7 @@ public sealed class ProviderValidation
public string? ValidatingProvider(LLMProviders llmProvider)
{
if (llmProvider == LLMProviders.NONE)
return "Please select a provider.";
return TB("Please select a provider.");
return null;
}
@@ -89,7 +93,7 @@ public sealed class ProviderValidation
return null;
if (host == Host.NONE)
return "Please select a host.";
return TB("Please select a host.");
return null;
}
@@ -100,7 +104,7 @@ public sealed class ProviderValidation
return null;
if (inferenceProvider is HFInferenceProvider.NONE)
return "Please select an Hugging Face inference provider.";
return TB("Please select an Hugging Face inference provider.");
return null;
}