diff --git a/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor b/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor index bfc970c436..6f89696075 100644 --- a/modules/basic-theme/src/Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme/Themes/Basic/LanguageSwitch.razor +++ b/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"); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/index.html b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/index.html index 5c5b4f161d..6fb36c2b23 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/index.html +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/index.html @@ -26,5 +26,6 @@ + diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/main.js b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/main.js new file mode 100644 index 0000000000..a1f62022d8 --- /dev/null +++ b/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"); + } + } + } +)(); \ No newline at end of file