Use Interop
This commit is contained in:
@ -16,6 +16,7 @@ using Oqtane.Modules;
|
||||
using Oqtane.Providers;
|
||||
using Oqtane.Services;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.UI;
|
||||
|
||||
namespace Oqtane.Client
|
||||
{
|
||||
@ -92,7 +93,8 @@ namespace Oqtane.Client
|
||||
|
||||
var host = builder.Build();
|
||||
var jsRuntime = host.Services.GetRequiredService<IJSRuntime>();
|
||||
var culture = await jsRuntime.InvokeAsync<string>("oqtaneCulture.get");
|
||||
var interop = new Interop(jsRuntime);
|
||||
var culture = await interop.getCulture();
|
||||
if (culture != null)
|
||||
{
|
||||
var cultureInfo = CultureInfo.GetCultureInfo(culture);
|
||||
|
@ -25,13 +25,15 @@
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
_selectedCulture = _selectedCulture = await JSRuntime.InvokeAsync<string>("oqtaneCulture.get");
|
||||
var interop = new Interop(JSRuntime);
|
||||
_selectedCulture = await interop.getCulture();
|
||||
_supportedCultures = await LocalizationService.GetSupportedCultures();
|
||||
}
|
||||
|
||||
private async Task SetCultureAsync(string culture)
|
||||
{
|
||||
await JSRuntime.InvokeVoidAsync("oqtaneCulture.set", culture);
|
||||
var interop = new Interop(JSRuntime);
|
||||
await interop.setCulture(culture);
|
||||
|
||||
NavigationManager.NavigateTo(NavigationManager.Uri, forceLoad: true);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
using Microsoft.JSInterop;
|
||||
using Microsoft.JSInterop;
|
||||
using Oqtane.Models;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -234,5 +234,32 @@ namespace Oqtane.UI
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<string> getCulture()
|
||||
{
|
||||
try
|
||||
{
|
||||
var culture = await _jsRuntime.InvokeAsync<string>("Oqtane.Interop.getCulture");
|
||||
|
||||
return culture;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Task setCulture(string culture)
|
||||
{
|
||||
try
|
||||
{
|
||||
_jsRuntime.InvokeVoidAsync("Oqtane.Interop.setCulture", culture);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user