Provides smart direction detection of any text (mixed or not) - LTR or RTL
All world languages are supported!
Why we need to detect the text direction?
Please look at the two examples below
هذا النص باللغة العربية.
טקסט זה ב עברי.
این متن به زبان فارسی.
Case 1: If the first word in a string is RTL followed by any number of LTR words like English, Spanish, Italian, etc. then the final text direction is RTL.
Case 2: If the string has got 4 LTR words at the beginning followed by a 1 RTL word, then the final direction is RTL.
Case 3: If the string has 5 LTR words or more followed by 1 RTL word, the total direction is LTR.