Change text direction for all pages

2020-07-10 20:21发布

问题:

I am working on a web project that can be in multi langauges, i have done all of that, i still have one thing.

the pages when shows in english is from left to right.

some languages on my website needs to be from right to left

Note please, my question is about the whole page not the text in fields.

how can i do that please?

I am using this code for launching threads for many languages.

Thread.CurrentThread.CurrentCulture = new CultureInfo(CultureName);
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;

I don't know what i think that the previous code could be helpful in order to achieve my goal.

回答1:

bool Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft

See as example: http://afana.me/category/Website-Optimization.aspx?page=2

To flip the whole page use either HTML tag attributes

<body dir="rtl" align="right">

or CSS properties on body tag

direction:rtl; text-align:right;

Direction is to control BiDi for the language script. Align is used to control visual display alignment.



回答2:

You can use this code in _Layout to Change text direction for all pages: in body tag

<body dir="@(System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft? "rtl" : "ltr")">



回答3:

I found this, hope it helps:

http://fortysevenmedia.com/blog/archives/styling_right-to-left_text_with_css_on_a_multi-lingual_site/

...and the site they made:

http://musicthoughts.com/

try the language links at the bottom.

They make use of the dir="rtl" attribute with some other minor changes to their css.