mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-07-04 01:22:57 +00:00
Improved I18N system (#445)
This commit is contained in:
parent
f8dbc186fb
commit
cfc2103b43
@ -11,16 +11,16 @@ namespace Build.Commands;
|
|||||||
public sealed partial class CollectI18NKeysCommand
|
public sealed partial class CollectI18NKeysCommand
|
||||||
{
|
{
|
||||||
private const string START_TAG1 = """
|
private const string START_TAG1 = """
|
||||||
T("
|
T("
|
||||||
""";
|
""";
|
||||||
|
|
||||||
private const string START_TAG2 = """
|
private const string START_TAG2 = """
|
||||||
TB("
|
TB("
|
||||||
""";
|
""";
|
||||||
|
|
||||||
private const string START_TAG3 = """
|
private const string START_TAG3 = """
|
||||||
T(@"
|
T(@"
|
||||||
""";
|
""";
|
||||||
|
|
||||||
private const string END_TAG = """
|
private const string END_TAG = """
|
||||||
")
|
")
|
||||||
|
@ -2529,3 +2529,12 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::WRITER::T3948127789"] = "Suggestion"
|
|||||||
|
|
||||||
-- Your stage directions
|
-- Your stage directions
|
||||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::WRITER::T779923726"] = "Your stage directions"
|
UI_TEXT_CONTENT["AISTUDIO::PAGES::WRITER::T779923726"] = "Your stage directions"
|
||||||
|
|
||||||
|
-- Unknown option
|
||||||
|
UI_TEXT_CONTENT["AISTUDIO::SETTINGS::DATAMODEL::LANGBEHAVIOREXTENSIONS::T3964902774"] = "Unknown option"
|
||||||
|
|
||||||
|
-- Choose the language manually.
|
||||||
|
UI_TEXT_CONTENT["AISTUDIO::SETTINGS::DATAMODEL::LANGBEHAVIOREXTENSIONS::T3988034966"] = "Choose the language manually."
|
||||||
|
|
||||||
|
-- Choose the language automatically, based on your system language.
|
||||||
|
UI_TEXT_CONTENT["AISTUDIO::SETTINGS::DATAMODEL::LANGBEHAVIOREXTENSIONS::T485389934"] = "Choose the language automatically, based on your system language."
|
||||||
|
@ -206,6 +206,10 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Event.PLUGINS_RELOADED:
|
case Event.PLUGINS_RELOADED:
|
||||||
|
this.Lang = await this.SettingsManager.GetActiveLanguagePlugin();
|
||||||
|
I18N.Init(this.Lang);
|
||||||
|
this.LoadNavItems();
|
||||||
|
|
||||||
await this.InvokeAsync(this.StateHasChanged);
|
await this.InvokeAsync(this.StateHasChanged);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -447,6 +447,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::CHATCOMPONENT::T636393754"] = "Verschiebe
|
|||||||
-- Show your workspaces
|
-- Show your workspaces
|
||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::CHATCOMPONENT::T733672375"] = "Zeige deine Arbeitsbereiche"
|
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::CHATCOMPONENT::T733672375"] = "Zeige deine Arbeitsbereiche"
|
||||||
|
|
||||||
|
-- Start new chat in workspace "{0}"
|
||||||
|
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::CHATCOMPONENT::T896906391"] = "Neuen Chat im Arbeitsbereich \"{0}\" starten"
|
||||||
|
|
||||||
-- Region
|
-- Region
|
||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::CONFIDENCEINFO::T1227782301"] = "Region"
|
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::CONFIDENCEINFO::T1227782301"] = "Region"
|
||||||
|
|
||||||
@ -2059,7 +2062,7 @@ UI_TEXT_CONTENT["AISTUDIO::LAYOUT::MAINLAYOUT::T2864211629"] = "Bitte warten Sie
|
|||||||
UI_TEXT_CONTENT["AISTUDIO::LAYOUT::MAINLAYOUT::T2929332068"] = "Unterstützer"
|
UI_TEXT_CONTENT["AISTUDIO::LAYOUT::MAINLAYOUT::T2929332068"] = "Unterstützer"
|
||||||
|
|
||||||
-- Writer
|
-- Writer
|
||||||
UI_TEXT_CONTENT["AISTUDIO::LAYOUT::MAINLAYOUT::T2979224202"] = "Schreiber"
|
UI_TEXT_CONTENT["AISTUDIO::LAYOUT::MAINLAYOUT::T2979224202"] = "Schreiben"
|
||||||
|
|
||||||
-- Show details
|
-- Show details
|
||||||
UI_TEXT_CONTENT["AISTUDIO::LAYOUT::MAINLAYOUT::T3692372066"] = "Details anzeigen"
|
UI_TEXT_CONTENT["AISTUDIO::LAYOUT::MAINLAYOUT::T3692372066"] = "Details anzeigen"
|
||||||
@ -2528,3 +2531,12 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::WRITER::T3948127789"] = "Vorschlag"
|
|||||||
|
|
||||||
-- Your stage directions
|
-- Your stage directions
|
||||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::WRITER::T779923726"] = "Ihre Regieanweisungen"
|
UI_TEXT_CONTENT["AISTUDIO::PAGES::WRITER::T779923726"] = "Ihre Regieanweisungen"
|
||||||
|
|
||||||
|
-- Unknown option
|
||||||
|
UI_TEXT_CONTENT["AISTUDIO::SETTINGS::DATAMODEL::LANGBEHAVIOREXTENSIONS::T3964902774"] = "Unbekannte Option"
|
||||||
|
|
||||||
|
-- Choose the language manually.
|
||||||
|
UI_TEXT_CONTENT["AISTUDIO::SETTINGS::DATAMODEL::LANGBEHAVIOREXTENSIONS::T3988034966"] = "Sprache manuell auswählen."
|
||||||
|
|
||||||
|
-- Choose the language automatically, based on your system language.
|
||||||
|
UI_TEXT_CONTENT["AISTUDIO::SETTINGS::DATAMODEL::LANGBEHAVIOREXTENSIONS::T485389934"] = "Sprache automatisch anhand Ihrer Systemsprache auswählen."
|
||||||
|
@ -447,6 +447,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::CHATCOMPONENT::T636393754"] = "Move the c
|
|||||||
-- Show your workspaces
|
-- Show your workspaces
|
||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::CHATCOMPONENT::T733672375"] = "Show your workspaces"
|
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::CHATCOMPONENT::T733672375"] = "Show your workspaces"
|
||||||
|
|
||||||
|
-- Start new chat in workspace "{0}"
|
||||||
|
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::CHATCOMPONENT::T896906391"] = "Start new chat in workspace \"{0}\""
|
||||||
|
|
||||||
-- Region
|
-- Region
|
||||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::CONFIDENCEINFO::T1227782301"] = "Region"
|
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::CONFIDENCEINFO::T1227782301"] = "Region"
|
||||||
|
|
||||||
@ -2059,7 +2062,7 @@ UI_TEXT_CONTENT["AISTUDIO::LAYOUT::MAINLAYOUT::T2864211629"] = "Please wait for
|
|||||||
UI_TEXT_CONTENT["AISTUDIO::LAYOUT::MAINLAYOUT::T2929332068"] = "Supporters"
|
UI_TEXT_CONTENT["AISTUDIO::LAYOUT::MAINLAYOUT::T2929332068"] = "Supporters"
|
||||||
|
|
||||||
-- Writer
|
-- Writer
|
||||||
UI_TEXT_CONTENT["AISTUDIO::LAYOUT::MAINLAYOUT::T2979224202"] = "Writer"
|
UI_TEXT_CONTENT["AISTUDIO::LAYOUT::MAINLAYOUT::T2979224202"] = "Writing"
|
||||||
|
|
||||||
-- Show details
|
-- Show details
|
||||||
UI_TEXT_CONTENT["AISTUDIO::LAYOUT::MAINLAYOUT::T3692372066"] = "Show details"
|
UI_TEXT_CONTENT["AISTUDIO::LAYOUT::MAINLAYOUT::T3692372066"] = "Show details"
|
||||||
@ -2529,3 +2532,12 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::WRITER::T3948127789"] = "Suggestion"
|
|||||||
-- Your stage directions
|
-- Your stage directions
|
||||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::WRITER::T779923726"] = "Your stage directions"
|
UI_TEXT_CONTENT["AISTUDIO::PAGES::WRITER::T779923726"] = "Your stage directions"
|
||||||
|
|
||||||
|
-- Unknown option
|
||||||
|
UI_TEXT_CONTENT["AISTUDIO::SETTINGS::DATAMODEL::LANGBEHAVIOREXTENSIONS::T3964902774"] = "Unknown option"
|
||||||
|
|
||||||
|
-- Choose the language manually.
|
||||||
|
UI_TEXT_CONTENT["AISTUDIO::SETTINGS::DATAMODEL::LANGBEHAVIOREXTENSIONS::T3988034966"] = "Choose the language manually."
|
||||||
|
|
||||||
|
-- Choose the language automatically, based on your system language.
|
||||||
|
UI_TEXT_CONTENT["AISTUDIO::SETTINGS::DATAMODEL::LANGBEHAVIOREXTENSIONS::T485389934"] = "Choose the language automatically, based on your system language."
|
||||||
|
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
using AIStudio.Tools.PluginSystem;
|
||||||
|
|
||||||
|
namespace AIStudio.Settings.DataModel;
|
||||||
|
|
||||||
|
public static class LangBehaviorExtensions
|
||||||
|
{
|
||||||
|
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(LangBehaviorExtensions).Namespace, nameof(LangBehaviorExtensions));
|
||||||
|
|
||||||
|
public static string Name(this LangBehavior langBehavior) => langBehavior switch
|
||||||
|
{
|
||||||
|
LangBehavior.AUTO => TB("Choose the language automatically, based on your system language."),
|
||||||
|
LangBehavior.MANUAL => TB("Choose the language manually."),
|
||||||
|
|
||||||
|
_ => TB("Unknown option")
|
||||||
|
};
|
||||||
|
}
|
@ -1,12 +0,0 @@
|
|||||||
namespace AIStudio.Settings.DataModel;
|
|
||||||
|
|
||||||
public static class LangBehaviorExtensions
|
|
||||||
{
|
|
||||||
public static string Name(this LangBehavior langBehavior) => langBehavior switch
|
|
||||||
{
|
|
||||||
LangBehavior.AUTO => "Choose the language automatically, based on your system language.",
|
|
||||||
LangBehavior.MANUAL => "Choose the language manually.",
|
|
||||||
|
|
||||||
_ => "Unknown option"
|
|
||||||
};
|
|
||||||
}
|
|
@ -13,7 +13,7 @@ namespace AIStudio.Settings;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The settings manager.
|
/// The settings manager.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class SettingsManager(ILogger<SettingsManager> logger, RustService rustService)
|
public sealed class SettingsManager
|
||||||
{
|
{
|
||||||
private const string SETTINGS_FILENAME = "settings.json";
|
private const string SETTINGS_FILENAME = "settings.json";
|
||||||
|
|
||||||
@ -23,8 +23,18 @@ public sealed class SettingsManager(ILogger<SettingsManager> logger, RustService
|
|||||||
Converters = { new TolerantEnumConverter() },
|
Converters = { new TolerantEnumConverter() },
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly ILogger<SettingsManager> logger = logger;
|
private readonly ILogger<SettingsManager> logger;
|
||||||
private readonly RustService rustService = rustService;
|
private readonly RustService rustService;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The settings manager.
|
||||||
|
/// </summary>
|
||||||
|
public SettingsManager(ILogger<SettingsManager> logger, RustService rustService)
|
||||||
|
{
|
||||||
|
this.logger = logger;
|
||||||
|
this.rustService = rustService;
|
||||||
|
this.logger.LogInformation("Settings manager created.");
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The directory where the configuration files are stored.
|
/// The directory where the configuration files are stored.
|
||||||
|
30
app/MindWork AI Studio/Tools/PluginSystem/I18N.cs
Normal file
30
app/MindWork AI Studio/Tools/PluginSystem/I18N.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
namespace AIStudio.Tools.PluginSystem;
|
||||||
|
|
||||||
|
public class I18N : ILang
|
||||||
|
{
|
||||||
|
public static readonly I18N I = new();
|
||||||
|
private static readonly ILogger<I18N> LOG = Program.LOGGER_FACTORY.CreateLogger<I18N>();
|
||||||
|
|
||||||
|
private ILanguagePlugin language = PluginFactory.BaseLanguage;
|
||||||
|
|
||||||
|
private I18N()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Init(ILanguagePlugin language) => I.language = language;
|
||||||
|
|
||||||
|
#region Implementation of ILang
|
||||||
|
|
||||||
|
public string T(string fallbackEN)
|
||||||
|
{
|
||||||
|
LOG.LogWarning("Using I18N.I.T without namespace and type is probably wrong, because the I18N key collection process of the build system will not find those keys.");
|
||||||
|
return this.GetText(this.language, fallbackEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string T(string fallbackEN, string? typeNamespace, string? typeName)
|
||||||
|
{
|
||||||
|
return this.GetText(this.language, fallbackEN, typeNamespace, typeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
@ -12,8 +12,8 @@ public static class ILangExtensions
|
|||||||
typeName ??= type.Name;
|
typeName ??= type.Name;
|
||||||
typeNamespace ??= type.Namespace!;
|
typeNamespace ??= type.Namespace!;
|
||||||
|
|
||||||
// When the type's name ends with `1 or 2`, etc. (i.e., generic classes), remove it:
|
// When the type's name ends with `1 or `2, etc. (i.e., generic classes), remove it:
|
||||||
if(typeName.Contains("`"))
|
if(typeName.Contains('`'))
|
||||||
typeName = typeName[..typeName.IndexOf('`')];
|
typeName = typeName[..typeName.IndexOf('`')];
|
||||||
|
|
||||||
var ns = $"{typeNamespace}::{typeName}".ToUpperInvariant().Replace(".", "::");
|
var ns = $"{typeNamespace}::{typeName}".ToUpperInvariant().Replace(".", "::");
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
# v0.9.42, build 217 (2025-05-xx xx:xx UTC)
|
# v0.9.42, build 217 (2025-05-xx xx:xx UTC)
|
||||||
- Added the writing style "Changelog" to the rewrite & improve text assistant. This helps to create changelogs for your projects.
|
- Added the writing style "Changelog" to the rewrite & improve text assistant. This helps to create changelogs for your projects.
|
||||||
- Added an option to load PDF files directly into the translation, text summarization, and legal check assistants as a preview prototype for testing before release.
|
- Added an option to load PDF files directly into the translation, text summarization, and legal check assistants as a preview prototype for testing before release.
|
||||||
|
- Added more text content to the localization system.
|
||||||
- Improved the model selection for OpenAI by removing all `o1-pro` models. These models cannot be used right now, since OpenAI introduced a new API, which is not yet supported by MindWork AI Studio.
|
- Improved the model selection for OpenAI by removing all `o1-pro` models. These models cannot be used right now, since OpenAI introduced a new API, which is not yet supported by MindWork AI Studio.
|
||||||
- Improved the internal plugin maintenance so that removed resources are now removed from the file system.
|
- Improved the internal plugin maintenance so that removed resources are now removed from the file system.
|
||||||
- Improved the app settings to apply the chosen language immediately.
|
- Improved the app settings to apply the chosen language immediately.
|
||||||
- Improved chat name generation to prevent the inclusion of line breaks, tabs, and other special characters.
|
- Improved chat name generation to prevent the inclusion of line breaks, tabs, and other special characters.
|
||||||
- Fixed an issue where empty lines in source code were being ignored by the Markdown renderer. Thanks My Nihongo for fixing this bug in the `MudBlazor.Markdown` repository.
|
- Fixed an issue where empty lines in source code were being ignored by the Markdown renderer. Thanks My Nihongo for fixing this bug in the `MudBlazor.Markdown` repository.
|
||||||
- Fixed the localization assistant not being able to load the localization file when used in the release app.
|
- Fixed the localization assistant not being able to load the localization file when used in the release app.
|
||||||
|
- Fixed the localization of the navigation component.
|
||||||
- Upgraded Rust & .NET dependencies.
|
- Upgraded Rust & .NET dependencies.
|
Loading…
Reference in New Issue
Block a user