Initial commit - MassTech UI
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.JSInterop;
|
||||
|
||||
namespace UI.Config.PostBuild
|
||||
{
|
||||
public static class CultureRetrieval
|
||||
{
|
||||
public static async Task RetriveCulture(this IServiceProvider services)
|
||||
{
|
||||
|
||||
|
||||
var js = services.GetRequiredService<IJSRuntime>();
|
||||
var cultureName = await js.InvokeAsync<string>("cultureInfo.get") ?? "en";
|
||||
|
||||
if (cultureName.Contains("|"))
|
||||
{
|
||||
var cultureParts = cultureName.Split('|');
|
||||
var cPart = cultureParts.FirstOrDefault(p => p.StartsWith("c="));
|
||||
if (cPart != null)
|
||||
{
|
||||
cultureName = cPart.Substring(2);
|
||||
}
|
||||
}
|
||||
|
||||
var culture = new CultureInfo(cultureName);
|
||||
CultureInfo.DefaultThreadCurrentCulture = culture;
|
||||
CultureInfo.DefaultThreadCurrentUICulture = culture;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user