mpcabd / python-arabic-reshaper

Reconstruct Arabic sentences to be used in applications that don't support Arabic
MIT License
395 stars 81 forks source link

Wrong order when English is used inside the text #62

Closed puraminy closed 3 years ago

puraminy commented 3 years ago

I want to print a Persian phrase (right to left) in a python console application. It's okay if all chars are in Persian. However, if it's mixed with English (including the ending dot (.), it shows it incorrectly.

Examples:

این خوب است # this is okay این خوب است. # the dot must be on the left-most side not right (the problem exists even in this editor)

این متن شامل English است.

The last one must be printed as:

.است English این متن شامل

To type the above, I typed it in the wrong order to show the right order!

=========== I used your package with the same problem.

ahmed4end commented 3 years ago

you can split and reorder them in your own i guess, no need to let arabic_reshaper handle them together.

mpcabd commented 3 years ago

If you mix Arabic with non-Arabic, the reshaper will ignore the non-Arabic, and will reshape the Arabic ones. If you are using get_display to reverse the text, it will also ignore the non-Arabic and will reverse the Arabic ones, see the image below.

Screenshot 2020-12-17 at 12 04 15

The text in the text area is entered into the browser, so no reshaping or whatever, only the browser rendering the text correctly. The text below the text area is using get_display over reshape to display it correctly. You can test it yourself here.

Please re-open if it's an issue in the reshaper itself confusing Arabic with non-Arabic characters.