Added I18N assistant for localization of AI Studio content (#422)
Build and Release / Read metadata (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis updater) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage deb updater) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2025-04-26 18:55:23 +02:00
1 parent 201fb2514d
commit 81030019c7
28 files changed
+750 -158

No files matched your search

+16 -1
View File
@@ -1,6 +1,21 @@
namespace AIStudio.Tools;
public readonly record struct ButtonData(string Text, string Icon, Color Color, string Tooltip, Func<Task> AsyncAction) : IButtonData
public readonly record struct ButtonData(string Text, string Icon, Color Color, string Tooltip, Func<Task> AsyncAction, Func<bool>? DisabledActionParam) : IButtonData
{
public ButtonTypes Type => ButtonTypes.BUTTON;
public Func<bool> DisabledAction
{
get
{
var data = this;
return () =>
{
if (data.DisabledActionParam is null)
return false;
return data.DisabledActionParam();
};
}
}
}
@@ -20,6 +20,24 @@ public static class CommonLanguageExtensions
_ => "Other",
};
public static string ToIETFTag(this CommonLanguages language) => language switch
{
CommonLanguages.AS_IS => string.Empty,
CommonLanguages.EN_US => "en-US",
CommonLanguages.EN_GB => "en-GB",
CommonLanguages.ZH_CN => "zh-CN",
CommonLanguages.HI_IN => "hi-IN",
CommonLanguages.ES_ES => "es-ES",
CommonLanguages.FR_FR => "fr-FR",
CommonLanguages.DE_DE => "de-DE",
CommonLanguages.DE_AT => "de-AT",
CommonLanguages.DE_CH => "de-CH",
CommonLanguages.JA_JP => "ja-JP",
_ => string.Empty,
};
public static string PromptSummarizing(this CommonLanguages language, string customLanguage) => language switch
{
CommonLanguages.AS_IS => "Do not change the language of the text.",
@@ -19,6 +19,10 @@ public enum Components
BIAS_DAY_ASSISTANT,
ERI_ASSISTANT,
// ReSharper disable InconsistentNaming
I18N_ASSISTANT,
// ReSharper restore InconsistentNaming
CHAT,
APP_SETTINGS,
@@ -10,8 +10,11 @@ public static class ComponentsExtensions
public static bool AllowSendTo(this Components component) => component switch
{
Components.NONE => false,
Components.ERI_ASSISTANT => false,
Components.BIAS_DAY_ASSISTANT => false,
Components.I18N_ASSISTANT => false,
Components.APP_SETTINGS => false,
Components.AGENT_TEXT_CONTENT_CLEANER => false,
@@ -36,6 +39,7 @@ public static class ComponentsExtensions
Components.MY_TASKS_ASSISTANT => "My Tasks Assistant",
Components.JOB_POSTING_ASSISTANT => "Job Posting Assistant",
Components.ERI_ASSISTANT => "ERI Server",
Components.I18N_ASSISTANT => "Localization Assistant",
Components.CHAT => "New Chat",
@@ -99,6 +103,7 @@ public static class ComponentsExtensions
Components.JOB_POSTING_ASSISTANT => settingsManager.ConfigurationData.JobPostings.PreselectOptions ? settingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == settingsManager.ConfigurationData.JobPostings.PreselectedProvider) : default,
Components.BIAS_DAY_ASSISTANT => settingsManager.ConfigurationData.BiasOfTheDay.PreselectOptions ? settingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == settingsManager.ConfigurationData.BiasOfTheDay.PreselectedProvider) : default,
Components.ERI_ASSISTANT => settingsManager.ConfigurationData.ERI.PreselectOptions ? settingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == settingsManager.ConfigurationData.ERI.PreselectedProvider) : default,
Components.I18N_ASSISTANT => settingsManager.ConfigurationData.I18N.PreselectOptions ? settingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == settingsManager.ConfigurationData.I18N.PreselectedProvider) : default,
Components.CHAT => settingsManager.ConfigurationData.Chat.PreselectOptions ? settingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == settingsManager.ConfigurationData.Chat.PreselectedProvider) : default,
@@ -29,4 +29,9 @@ public interface ILanguagePlugin
/// Gets the name of the language.
/// </summary>
public string LangName { get; }
/// <summary>
/// Get all keys and texts from the language plugin.
/// </summary>
public IReadOnlyDictionary<string, string> Content { get; }
}
@@ -22,5 +22,7 @@ public sealed class NoPluginLanguage : PluginBase, ILanguagePlugin
public string LangName => string.Empty;
public IReadOnlyDictionary<string, string> Content => new Dictionary<string, string>();
#endregion
}
@@ -101,16 +101,18 @@ public static partial class PluginFactory
}
}
private static async Task<PluginBase> Load(string pluginPath, string code, CancellationToken cancellationToken = default)
public static async Task<PluginBase> Load(string? pluginPath, string code, CancellationToken cancellationToken = default)
{
if(ForbiddenPlugins.Check(code) is { IsForbidden: true } forbiddenState)
return new NoPlugin($"This plugin is forbidden: {forbiddenState.Message}");
var state = LuaState.Create();
// Add the module loader so that the plugin can load other Lua modules:
state.ModuleLoader = new PluginLoader(pluginPath);
if (!string.IsNullOrWhiteSpace(pluginPath))
{
// Add the module loader so that the plugin can load other Lua modules:
state.ModuleLoader = new PluginLoader(pluginPath);
}
// Add some useful libraries:
state.OpenModuleLibrary();
state.OpenStringLibrary();
@@ -141,7 +143,7 @@ public static partial class PluginFactory
if(type is PluginType.NONE)
return new NoPlugin($"TYPE is not a valid plugin type. Valid types are: {CommonTools.GetAllEnumValues<PluginType>()}");
var isInternal = pluginPath.StartsWith(INTERNAL_PLUGINS_ROOT, StringComparison.OrdinalIgnoreCase);
var isInternal = !string.IsNullOrWhiteSpace(pluginPath) && pluginPath.StartsWith(INTERNAL_PLUGINS_ROOT, StringComparison.OrdinalIgnoreCase);
return type switch
{
PluginType.LANGUAGE => new PluginLanguage(isInternal, state, type),
@@ -165,6 +165,9 @@ public sealed class PluginLanguage : PluginBase, ILanguagePlugin
/// <inheritdoc />
public string LangName => this.langName;
/// <inheritdoc />
public IReadOnlyDictionary<string, string> Content => this.content.AsReadOnly();
#endregion
}