How can I change the page direction based on the local setting of the user? from left to right to right-to-left? Should this be done using JS only, or there is a better way? please note that I need to Change to value, not check the current culture settings.
Using ASP.NET MVC5
Thanks
To set the text direction of the whole page in HTML 5, you can set the dir
attribute on the html
or body
element. (In HTML 5 the dir
attribute can be used on any element).
For instance if you're setting the CurrentThread CurrentCulture in the request, you can use the following in your view:
<html
dir="@(System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft? "rtl" : "ltr")">
Based on http://afana.me/post/aspnet-mvc-internationalization.aspx
Note that if you're using a CSS library such as bootstrap, you'll also need to get an rtl-modified version of the CSS, because the page direction won't affect css rules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With