Browse Source

Blazor UI: Add "rtl" class to body if the current language is RTL.

pull/5957/head
Halil İbrahim Kalkan 6 years ago
parent
commit
100f6f09b8
  1. 10
      framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Microsoft/AspNetCore/Components/WebAssembly/Hosting/AbpWebAssemblyHostBuilderExtensions.cs

10
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Microsoft/AspNetCore/Components/WebAssembly/Hosting/AbpWebAssemblyHostBuilderExtensions.cs

@ -51,7 +51,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting
using (var scope = serviceProvider.CreateScope())
{
await InitializeModulesAsync(scope.ServiceProvider);
SetCurrentLanguage(scope);
await SetCurrentLanguageAsync(scope);
}
}
@ -63,9 +63,10 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting
}
}
private static void SetCurrentLanguage(IServiceScope scope)
private async static Task SetCurrentLanguageAsync(IServiceScope scope)
{
var configurationClient = scope.ServiceProvider.GetRequiredService<ICachedApplicationConfigurationClient>();
var utilsService = scope.ServiceProvider.GetRequiredService<IAbpUtilsService>();
var configuration = configurationClient.Get();
var cultureName = configuration.Localization?.CurrentCulture?.CultureName;
if (!cultureName.IsNullOrEmpty())
@ -74,6 +75,11 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Hosting
CultureInfo.DefaultThreadCurrentCulture = culture;
CultureInfo.DefaultThreadCurrentUICulture = culture;
}
if (CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft)
{
await utilsService.AddClassToTagAsync("body", "rtl");
}
}
}
}

Loading…
Cancel
Save