mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-21 18:37:18 +02:00
feat: localization added
This commit is contained in:
1 parent
2fba32b5b4
commit
c035f78340
15 files changed
+542
-19
No files matched your search
@@ -1,7 +1,13 @@
|
||||
using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.JSInterop;
|
||||
using Radzen;
|
||||
using Radzen.Blazor;
|
||||
using WotBlitzStatisticsPro.Blazor.Messages;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Blazor.Shared
|
||||
{
|
||||
@@ -10,11 +16,33 @@ namespace WotBlitzStatisticsPro.Blazor.Shared
|
||||
[Inject]
|
||||
private DialogService DialogService { get; set; }
|
||||
|
||||
[Inject]
|
||||
private IMediator Mediator { get; set; }
|
||||
|
||||
public RadzenSidebar Sidebar0;
|
||||
public RadzenBody Body0;
|
||||
public bool SidebarExpanded { get; set; } = false;
|
||||
public bool BodyExpanded { get; set; } = true;
|
||||
|
||||
public Dictionary<string, CultureInfo> CultureInfos { get; set; } = new()
|
||||
{
|
||||
{ "en-US", new CultureInfo("en-US", false)},
|
||||
{ "ru-RU", new CultureInfo("ru-RU", false)},
|
||||
{ "de-DE", new CultureInfo("de-DE", false)}
|
||||
};
|
||||
|
||||
public CultureInfo CurrentCultureInfo
|
||||
{
|
||||
get => CultureInfo.CurrentCulture;
|
||||
set
|
||||
{
|
||||
if (CultureInfo.CurrentCulture != value)
|
||||
{
|
||||
Mediator.Publish(new ChangeCurrentCultureMessage(value.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
//if (httpContextAccessor != null && httpContextAccessor.HttpContext != null &&
|
||||
@@ -31,8 +59,6 @@ namespace WotBlitzStatisticsPro.Blazor.Shared
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
|
||||
}
|
||||
|
||||
public void InvertSideBar()
|
||||
@@ -40,5 +66,13 @@ namespace WotBlitzStatisticsPro.Blazor.Shared
|
||||
SidebarExpanded = !SidebarExpanded;
|
||||
BodyExpanded = !BodyExpanded;
|
||||
}
|
||||
|
||||
public void LanguageSelected(RadzenSplitButtonItem item)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
CurrentCultureInfo = CultureInfos[item.Value];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user