QTodoTxt icon indicating copy to clipboard operation
QTodoTxt copied to clipboard

Support for non-latin or language independent markup (2)

Open kmicc opened this issue 9 years ago • 4 comments

(Request from @damascene, taken from #171)

In RTL languages like Arabic, Hebrew, Persian and Urdu text will align to the left instead of the right but those languages are read from right to left. For example: (A) شراء حليب شراء حليب screenshot from 2015-12-22 14 05 26 The first will be aligned to left and the second will be aligned to right in qtodo.

kmicc avatar Dec 22 '15 12:12 kmicc

That looks ugly and is clearly a bug (also look at the position and order of the parenthesis). I think the problem is somewhere in HTML-output of https://github.com/QTodoTxt/QTodoTxt/blob/master/qtodotxt/lib/task_htmlizer.py. I'm not very experienced in RTL-languages, so any hints or contributions are welcome.

kmicc avatar Dec 22 '15 12:12 kmicc

Thank you for splitting it. I would like to note that if priorities are set with numbers the alignment change will not happen (1) شراء حليب will still align to right as normal behavior but because of the (A) letter is before the RTL text then it will align to the left instead of the right.

This same behavior is in gedit and other softwares and this will happen when you but the "x" (complete) character too before the task

damascene avatar Dec 22 '15 12:12 damascene

Since you are using HTML in the output, you can use the dir attribute available in HTML elements. For instance <element dir="rtl"></element> will the make the direction of what's inside element is from right to left. If you prefer to do in CSS, you can CSS attribute direction which also accepts values ltr and rtl.

Now, in case there is a mixed text (contains both LTR and RTL characters), you may want to use something that lets you decide which character has the strongest influence and should decide therefore the direction. Modern browsers like Firefox and Chrome use HTML attribute dir = "auto" to employ their own algorithms to determine the direction in such cases. For more information, see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir.

linostar avatar Dec 27 '15 07:12 linostar

Thanks for your hint. I will have a look.

kmicc avatar Jan 01 '16 16:01 kmicc