feat: localization added

This commit is contained in:
Mikhail Shabanov committed 2021-04-07 12:32:17 +02:00
1 parent 2fba32b5b4
commit c035f78340
15 files changed
+542 -19

No files matched your search

@@ -0,0 +1,14 @@
using MediatR;
namespace WotBlitzStatisticsPro.Blazor.Messages
{
public class ChangeCurrentCultureMessage: INotification
{
public string CultureName { get; }
public ChangeCurrentCultureMessage(string cultureName)
{
CultureName = cultureName;
}
}
}
@@ -0,0 +1,9 @@
namespace WotBlitzStatisticsPro.Blazor.Model
{
public class UserSettings
{
public const string UserSettingsLocalStorageKey = "user-settings";
public string Culture { get; set; } = "en-US";
}
}
@@ -2,23 +2,24 @@
@using MediatR
@using WotBlitzStatisticsPro.Blazor.Messages
@using WotBlitzStatisticsPro.Blazor.Model
@inject IStringLocalizer<App> Localize
@inject IMediator Mediator
<div class="splash">
<div class="splash-content">
<RadzenLabel Text="Welcome to WOT Blitz statistics application!" Style="margin: 30px 0px 100px 0px"></RadzenLabel>
<RadzenLabel Text=@Localize["Welcome to WOT Blitz statistics application!"] Style="margin: 30px 0px 100px 0px"></RadzenLabel>
<RadzenButton Click=@(async args => { await Mediator.Publish(new LoginToWgMessage()); })
Icon="vpn_key"
Text="Login with WG.net ID"
Style="width: 250px; margin: 30px" />
Text=@Localize["Login with WG.net ID"]
Style="width: 300px; margin: 30px" />
<RadzenButton Click=@(async args => { await Mediator.Publish(new OpenSearchDialogMessage(DialogType.FindPlayer)); })
Icon="person_search"
Text="Search player"
Style="width: 250px; margin: 30px" />
Text=@Localize["Search player"]
Style="width: 300px; margin: 30px" />
<RadzenButton Click=@(async args => { await Mediator.Publish(new OpenSearchDialogMessage(DialogType.FindClan)); })
Icon="screen_search_desktop"
Text="Search clan"
Style="width: 250px; margin: 30px" />
Text=@Localize["Search clan"]
Style="width: 300px; margin: 30px" />
</div>
</div>
+17 -1
View File
@@ -1,10 +1,13 @@
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Globalization;
using System.Net.Http;
using System.Threading.Tasks;
using MediatR;
using Microsoft.JSInterop;
using Radzen;
using WotBlitzStatisticsPro.Blazor.Model;
using WotBlitzStatisticsPro.Blazor.Services;
namespace WotBlitzStatisticsPro.Blazor
@@ -15,6 +18,7 @@ namespace WotBlitzStatisticsPro.Blazor
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.Services.AddLocalization(options => options.ResourcesPath = "Resources");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
@@ -24,8 +28,20 @@ namespace WotBlitzStatisticsPro.Blazor
builder.Services.AddMediatR(typeof(Program));
builder.Services.AddSingleton<NavigationMessagesInterceptor>();
builder.Services.AddScoped<ILocalStorageService, LocalStorageService>();
await builder.Build().RunAsync();
var host = builder.Build();
// Reading Current Culture from LocalStorage
var localStorageService = host.Services.GetRequiredService<ILocalStorageService>();
var settings = await localStorageService.GetItemAsync<UserSettings>(UserSettings.UserSettingsLocalStorageKey);
if (settings != null)
{
var culture = new CultureInfo(settings.Culture);
CultureInfo.DefaultThreadCurrentCulture = culture;
CultureInfo.DefaultThreadCurrentUICulture = culture;
}
await host.RunAsync();
}
}
}
@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Home" xml:space="preserve">
<value>Startseite</value>
</data>
<data name="Login with WG.net ID" xml:space="preserve">
<value>Anmelden mit WG.net-ID</value>
</data>
<data name="Search clan" xml:space="preserve">
<value>Clan suchen</value>
</data>
<data name="Search player" xml:space="preserve">
<value>Spieler suchen</value>
</data>
<data name="Welcome to WOT Blitz statistics application!" xml:space="preserve">
<value>Willkommen bei der WOT Blitz statistics!</value>
</data>
</root>
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Home" xml:space="preserve">
<value>На главную</value>
</data>
<data name="Login with WG.net ID" xml:space="preserve">
<value>Войти с WG.net ID</value>
</data>
<data name="Search clan" xml:space="preserve">
<value>Поиск клана</value>
</data>
<data name="Search player" xml:space="preserve">
<value>Поиск игрока</value>
</data>
<data name="Welcome to WOT Blitz statistics application!" xml:space="preserve">
<value>Добро пожаловать в WOT Blitz statistics!</value>
</data>
</root>
@@ -0,0 +1,11 @@
using System.Threading.Tasks;
namespace WotBlitzStatisticsPro.Blazor.Services
{
public interface ILocalStorageService
{
Task SetItemAsync<T>(string key, T item);
Task<T> GetItemAsync<T>(string key);
}
}
@@ -0,0 +1,47 @@
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using WotBlitzStatisticsPro.Blazor.Messages;
using WotBlitzStatisticsPro.Blazor.Model;
namespace WotBlitzStatisticsPro.Blazor.Services
{
public class LocalStorageService: ILocalStorageService, INotificationHandler<ChangeCurrentCultureMessage>
{
private readonly IJSRuntime _jsRuntime;
private readonly NavigationManager _navigationManager;
public LocalStorageService(
IJSRuntime jsRuntime,
NavigationManager navigationManager)
{
_jsRuntime = jsRuntime;
_navigationManager = navigationManager;
}
public async Task SetItemAsync<T>(string key, T item)
{
await _jsRuntime.InvokeVoidAsync("localStorage.setItem",
key, JsonSerializer.Serialize(item));
}
public async Task<T> GetItemAsync<T>(string key)
{
var json = await _jsRuntime.InvokeAsync<string>("localStorage.getItem", key);
return string.IsNullOrEmpty(json)
? default
: JsonSerializer.Deserialize<T>(json);
}
public async Task Handle(ChangeCurrentCultureMessage notification, CancellationToken cancellationToken)
{
var currentSettings = await GetItemAsync<UserSettings>(UserSettings.UserSettingsLocalStorageKey) ?? new UserSettings();
currentSettings.Culture = notification.CultureName;
await SetItemAsync(UserSettings.UserSettingsLocalStorageKey, currentSettings);
_navigationManager.NavigateTo(_navigationManager.Uri, forceLoad: true);
}
}
}
@@ -11,6 +11,16 @@
<RadzenLabel Text="WOT Blitz statistics">
</RadzenLabel>
</div>
<div class="col-6 d-flex align-items-center justify-content-end">
<RadzenSplitButton Click=@(LanguageSelected) Icon="language" Text="@CurrentCultureInfo.NativeName" Style="margin:0 .5rem">
<ChildContent>
@foreach (var ci in CultureInfos)
{
<RadzenSplitButtonItem Text="@ci.Value.DisplayName" Value="@ci.Key" />
}
</ChildContent>
</RadzenSplitButton>
</div>
</div>
</ChildContent>
</RadzenHeader>
@@ -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];
}
}
}
}
@@ -1,9 +1,11 @@
@inherits NavMenuBase
@inject IStringLocalizer<App> Localize
<div>
<RadzenPanelMenu Click="@(MenuClicked)">
<RadzenPanelMenuItem Text="Home" Icon="home"></RadzenPanelMenuItem>
<RadzenPanelMenuItem Text="Login with WG.net ID" Icon="vpn_key"></RadzenPanelMenuItem>
<RadzenPanelMenuItem Text="Search player" Icon="person_search"></RadzenPanelMenuItem>
<RadzenPanelMenuItem Text="Search clan" Icon="screen_search_desktop"></RadzenPanelMenuItem>
<RadzenPanelMenuItem Text="@Localize["Home"]" Icon="home"></RadzenPanelMenuItem>
<RadzenPanelMenuItem Text="@Localize["Login with WG.net ID"]" Icon="vpn_key"></RadzenPanelMenuItem>
<RadzenPanelMenuItem Text="@Localize["Search player"]" Icon="person_search"></RadzenPanelMenuItem>
<RadzenPanelMenuItem Text="@Localize["Search clan"]" Icon="screen_search_desktop"></RadzenPanelMenuItem>
</RadzenPanelMenu>
</div>
@@ -1,6 +1,7 @@
using System.Threading.Tasks;
using MediatR;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;
using Radzen;
using WotBlitzStatisticsPro.Blazor.Messages;
using WotBlitzStatisticsPro.Blazor.Model;
@@ -19,6 +20,10 @@ namespace WotBlitzStatisticsPro.Blazor.Shared
[Inject]
public ISearchDialogService SearchDialogService { get; set; }
[Inject]
private IStringLocalizer<App> Localizer { get; set; }
[Parameter]
public EventCallback CloseSideBar { get; set; }
@@ -27,17 +32,17 @@ namespace WotBlitzStatisticsPro.Blazor.Shared
await CloseSideBar.InvokeAsync();
switch (menuItem.Text)
{
case "Home":
case var _ when(Localizer.GetString("Home")) == menuItem.Text:
NavManager.NavigateTo("/");
break;
case "Login with WG.net ID":
case var _ when (Localizer.GetString("Login with WG.net ID")) == menuItem.Text:
await Mediator.Publish(new LoginToWgMessage());
break;
case "Search player":
case var _ when (Localizer.GetString("Search player")) == menuItem.Text:
await Mediator.Publish(new OpenSearchDialogMessage(DialogType.FindPlayer));
//await SearchDialogService.OpenSearchDialog(DialogType.FindPlayer);
break;
case "Search clan":
case var _ when (Localizer.GetString("Search clan")) == menuItem.Text:
await Mediator.Publish(new OpenSearchDialogMessage(DialogType.FindClan));
break;
}
@@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
<BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
</PropertyGroup>
<ItemGroup>
@@ -10,6 +11,7 @@
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="5.0.5" />
<PackageReference Include="Radzen.Blazor" Version="3.2.0" />
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
</ItemGroup>
@@ -5,6 +5,7 @@
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.AspNetCore.Components.WebAssembly.Http
@using Microsoft.Extensions.Localization
@using Microsoft.JSInterop
@using WotBlitzStatisticsPro.Blazor
@using WotBlitzStatisticsPro.Blazor.Shared