Browse Source

App: Add dir and lang attributes to html tag for Blazor (RTL)

pull/10374/head
Engincan VESKE 5 years ago
parent
commit
0cfef94048
  1. 5
      modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor
  2. 1
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/index.html
  3. 17
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/main.js

5
modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor

@ -60,6 +60,11 @@
"Abp.SelectedLanguage", language.UiCultureName
);
await JsRuntime.InvokeVoidAsync(
"localStorage.setItem",
"Abp.IsRtl", CultureInfo.GetCultureInfo(language.UiCultureName).TextInfo.IsRightToLeft
);
await JsRuntime.InvokeVoidAsync("location.reload");
}
}

1
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/index.html

@ -26,5 +26,6 @@
<script src="global.js?_v=637701705558615007"></script>
<!--/ABP:Scripts-->
<script src="main.js"></script>
</body>
</html>

17
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/main.js

@ -0,0 +1,17 @@
(
function () {
var isRtl = JSON.parse(localStorage.getItem("Abp.IsRtl"));
var htmlTag = document.getElementsByTagName("html")[0];
if (htmlTag) {
var selectedLanguage = localStorage.getItem("Abp.SelectedLanguage");
if (selectedLanguage) {
htmlTag.setAttribute("lang", selectedLanguage);
}
if (isRtl) {
htmlTag.setAttribute("dir", "rtl");
}
}
}
)();
Loading…
Cancel
Save