Ability to change culture

This commit is contained in:
hishamco
2020-12-02 02:04:34 +03:00
parent c4d1b16abb
commit 75556070d6
3 changed files with 21 additions and 2 deletions

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
@ -10,6 +11,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.JSInterop;
using Oqtane.Modules;
using Oqtane.Providers;
using Oqtane.Services;
@ -89,6 +91,14 @@ namespace Oqtane.Client
}
var host = builder.Build();
var jsRuntime = host.Services.GetRequiredService<IJSRuntime>();
var culture = await jsRuntime.InvokeAsync<string>("oqtaneCulture.get");
if (culture != null)
{
var cultureInfo = CultureInfo.GetCultureInfo(culture);
CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;
}
ServiceActivator.Configure(host.Services);