|
|
|
@ -1,10 +1,15 @@ |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using System; |
|
|
|
using System.Globalization; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Volo.Abp.AspNetCore.Components.Web; |
|
|
|
using Volo.Abp.AspNetCore.Components.Web.ExceptionHandling; |
|
|
|
using Volo.Abp.AspNetCore.Components.Web.Security; |
|
|
|
using Volo.Abp.AspNetCore.Mvc.Client; |
|
|
|
using Volo.Abp.Http.Client; |
|
|
|
using Volo.Abp.Modularity; |
|
|
|
using Volo.Abp.Threading; |
|
|
|
using Volo.Abp.UI; |
|
|
|
|
|
|
|
namespace Volo.Abp.AspNetCore.Components.WebAssembly; |
|
|
|
@ -33,4 +38,35 @@ public class AbpAspNetCoreComponentsWebAssemblyModule : AbpModule |
|
|
|
.GetHostBuilder().Logging |
|
|
|
.AddProvider(new AbpExceptionHandlingLoggerProvider(context.Services)); |
|
|
|
} |
|
|
|
|
|
|
|
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
|
|
|
{ |
|
|
|
AsyncHelper.RunSync(() => OnApplicationInitializationAsync(context)); |
|
|
|
} |
|
|
|
|
|
|
|
public async override Task OnApplicationInitializationAsync(ApplicationInitializationContext context) |
|
|
|
{ |
|
|
|
await context.ServiceProvider.GetRequiredService<WebAssemblyCachedApplicationConfigurationClient>().InitializeAsync(); |
|
|
|
await context.ServiceProvider.GetRequiredService<AbpComponentsClaimsCache>().InitializeAsync(); |
|
|
|
await SetCurrentLanguageAsync(context.ServiceProvider); |
|
|
|
} |
|
|
|
|
|
|
|
private async static Task SetCurrentLanguageAsync(IServiceProvider serviceProvider) |
|
|
|
{ |
|
|
|
var configurationClient = serviceProvider.GetRequiredService<ICachedApplicationConfigurationClient>(); |
|
|
|
var utilsService = serviceProvider.GetRequiredService<IAbpUtilsService>(); |
|
|
|
var configuration = await configurationClient.GetAsync(); |
|
|
|
var cultureName = configuration.Localization?.CurrentCulture?.CultureName; |
|
|
|
if (!cultureName.IsNullOrEmpty()) |
|
|
|
{ |
|
|
|
var culture = new CultureInfo(cultureName); |
|
|
|
CultureInfo.DefaultThreadCurrentCulture = culture; |
|
|
|
CultureInfo.DefaultThreadCurrentUICulture = culture; |
|
|
|
} |
|
|
|
|
|
|
|
if (CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft) |
|
|
|
{ |
|
|
|
await utilsService.AddClassToTagAsync("body", "rtl"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|