mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 07:59:47 +00:00
Add language plugin support to MainLayout.
This commit is contained in:
parent
088e4ad7e3
commit
19888ff74d
@ -12,7 +12,7 @@ using DialogOptions = AIStudio.Dialogs.DialogOptions;
|
|||||||
|
|
||||||
namespace AIStudio.Layout;
|
namespace AIStudio.Layout;
|
||||||
|
|
||||||
public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, IDisposable
|
public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILang, IDisposable
|
||||||
{
|
{
|
||||||
[Inject]
|
[Inject]
|
||||||
private SettingsManager SettingsManager { get; init; } = null!;
|
private SettingsManager SettingsManager { get; init; } = null!;
|
||||||
@ -38,6 +38,8 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, IDis
|
|||||||
[Inject]
|
[Inject]
|
||||||
private MudTheme ColorTheme { get; init; } = null!;
|
private MudTheme ColorTheme { get; init; } = null!;
|
||||||
|
|
||||||
|
private ILanguagePlugin Lang { get; set; } = PluginFactory.BaseLanguage;
|
||||||
|
|
||||||
private string PaddingLeft => this.navBarOpen ? $"padding-left: {NAVBAR_EXPANDED_WIDTH_INT - NAVBAR_COLLAPSED_WIDTH_INT}em;" : "padding-left: 0em;";
|
private string PaddingLeft => this.navBarOpen ? $"padding-left: {NAVBAR_EXPANDED_WIDTH_INT - NAVBAR_COLLAPSED_WIDTH_INT}em;" : "padding-left: 0em;";
|
||||||
|
|
||||||
private const int NAVBAR_COLLAPSED_WIDTH_INT = 4;
|
private const int NAVBAR_COLLAPSED_WIDTH_INT = 4;
|
||||||
@ -78,7 +80,7 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, IDis
|
|||||||
// Read the user language from Rust:
|
// Read the user language from Rust:
|
||||||
//
|
//
|
||||||
var userLanguage = await this.RustService.ReadUserLanguage();
|
var userLanguage = await this.RustService.ReadUserLanguage();
|
||||||
this.Logger.LogInformation($"The user language is: '{userLanguage}'");
|
this.Logger.LogInformation($"The OS says '{userLanguage}' is the user language.");
|
||||||
|
|
||||||
// Ensure that all settings are loaded:
|
// Ensure that all settings are loaded:
|
||||||
await this.SettingsManager.LoadSettings();
|
await this.SettingsManager.LoadSettings();
|
||||||
@ -105,6 +107,9 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, IDis
|
|||||||
// Send a message to start the plugin system:
|
// Send a message to start the plugin system:
|
||||||
await this.MessageBus.SendMessage<bool>(this, Event.STARTUP_PLUGIN_SYSTEM);
|
await this.MessageBus.SendMessage<bool>(this, Event.STARTUP_PLUGIN_SYSTEM);
|
||||||
|
|
||||||
|
// Load the language plugin:
|
||||||
|
this.Lang = await this.SettingsManager.GetActiveLanguagePlugin();
|
||||||
|
|
||||||
await this.themeProvider.WatchSystemPreference(this.SystemeThemeChanged);
|
await this.themeProvider.WatchSystemPreference(this.SystemeThemeChanged);
|
||||||
await this.UpdateThemeConfiguration();
|
await this.UpdateThemeConfiguration();
|
||||||
this.LoadNavItems();
|
this.LoadNavItems();
|
||||||
@ -119,6 +124,12 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, IDis
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Implementation of ILang
|
||||||
|
|
||||||
|
public string T(string fallbackEN) => this.GetText(this.Lang, fallbackEN);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Implementation of IMessageBusReceiver
|
#region Implementation of IMessageBusReceiver
|
||||||
|
|
||||||
public string ComponentName => nameof(MainLayout);
|
public string ComponentName => nameof(MainLayout);
|
||||||
|
Loading…
Reference in New Issue
Block a user