Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html direction by language? (if english dir=ltr if arabic dir=rtl)

Can I do that?

I mean if, for example, the contents of the <div> is Hebrew or Arabic, float the <div> right and give it a dir="rtl" attribute. And, if the contents of the <div> is English, float to the left and change the dir attribute to "ltr".

Ss that possible?

like image 338
Pinokyo Avatar asked Jan 29 '26 07:01

Pinokyo


1 Answers

If you don't know the language, you can use regular expression to find hebrew or arabic characters, and then set the direction accordingly.

Use regular expressions to find Hebrew: Javascript - how to find hebrew?

All unicode blocks, which you can use to edit the above solution to fit also Arabic: http://www.regular-expressions.info/unicode.html#block

like image 76
Gideon Avatar answered Jan 30 '26 20:01

Gideon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!