jzohrab / lute

DEPRECATED: LUTE (Learning Using Texts) is a self-hosted web app for learning language through reading, based on Learning with Texts (LWT)
The Unlicense
119 stars 10 forks source link

Broken RTL languages support. #67

Closed shetozz closed 1 year ago

shetozz commented 1 year ago

Description

RTL display is broken, it's not completely LTR either, I'll provide Arabic text. Without diacritics (which represent short vowels), it shows words correctly, but in the wrong order LTR instead of RTL, but when I add the diacritics, it loses its ability to show connected letters mostly.

Another point is, Titles show completely fine, with the diacritics and in the correct order.

Reproduce

صَبَاحُ الخَير.md

This is the file if you wanna try it on your system.

Edit: text from the file ... SORT OF ... even copying and pasting it here makes it behave strangely. The exclamation marks belong on the left of the first two lines. :-)

خالِد: صَبَاحُ الخَيرِ!
خُلُود: صَبَاحُ النُّور!
خالِد: كَيفَ حَالُكِ؟
خُلُود: بِخَيرٍ، وَأَنْتَ؟
خَالِد: فِي أَحْسَنِ حالٍ. ما اسمُكِ؟
خُلُود: اسمي خُلُودُ، وأَنتَ، ما اسمُكَ؟
خَالِد: أَنا خَالِد، تَشَرَّفْتُ بِلِقَائِكِ.
خُلُود: الشَّرَفُ لِي.

Screenshot of the text file:

image

Screenshots Expected behavior With diacritics (AKA short vowels) Without diacritics

Extra software info, if not already included in the Description:

shetozz commented 1 year ago

Adding letters with diacritics in the character field, and it solved one of the problems, which is the inability to connect letters when diacritics are present, now, we have the other one which is the wrong word order.

jzohrab commented 1 year ago

Thanks @shetozz for the info, I'll take a quick look to start to get a handle on the issue.

jzohrab commented 1 year ago

To explore, I've created a branch, hack_issue_67_RTL_text and started making some hacky changes to it, just to get an idea of what's involved.

By hardcoding dir="rtl" in a few places, I have the following:

image

I haven't looked into the language word regex much, so you'll see that the "?" at the end of some sentences is included as part of the term. Also note that the exclamation mark is on the wrong end of the sentence.

I don't know if the Term form (top right form) needs to do the text as right-to-left for the text boxes ... maybe it's good enough for just the text itself to be right to left, and all the text input boxes could be as-is. (I understand that this is biased towards Western/Roman languages :-) I don't know how to easily switch all the layouts around!) Also, the term definitions aren't right-to-left, I'm assuming that they're entering the defs in English or similar. Lots of variables, I'm not sure how to work it all out.

A sample pop-up:

image

I know the terms aren't related, just wanted to see what would happen.

Also note the text editing is still left-aligned:

image

Wow this language looks tricky.

In short, perhaps just changing the layout of the text itself would be good enough ... not perfect, but good enough. I don't know, haven't studied such a language, and so am flying blind!

jzohrab commented 1 year ago

@shetozz - if all we have to do to make this somewhat functional (as a first iteration) is add dir="rtl" to a page, that's quite quick ... but I don't know what the implications would be.

Would you be willing to try out a special build, work with it for a bit, and see what problems you run into? I don't know enough of the language to know if what I'm doing is right or not. We could use a special release, like lute-rtl-beta-v1 or something, and you could install it the same way you install Lute regularly, try it out for a while with some stories or something, and see how it goes. My turnaround time for releasing fixes might not be great ... but who knows, maybe it's simple. I looked at how LWT (Learning with Texts) handles it, and it seems like the impact is minimal.

shetozz commented 1 year ago

I'll be more than happy to try it out and test it, just keep in mind that I'm a noob when it comes to programming, I'll install it with some instructions. As for the fix itself, I think having an RTL text is enough for now, for the definitions, we can have a switch or something in the future to give the user choice to use English or Arabic for definitions. But for now, I'll try the RTL text field.

jzohrab commented 1 year ago

No problem, it will be a regular install just like you do right now. I'll only do the RTL text itself, everything else will be left-to-right.

jzohrab commented 1 year ago

Hi @shetozz, I've created a new "beta" release for RTL language support.

https://github.com/jzohrab/lute/releases/tag/rtl-beta-v0.1

You can delete your existing Lute installation (assuming you haven't actually used it for anything!!) and install the beta release just like you did with the prior release. This beta release pre-defines Arabic and a short Arabic sample story (along with all the other languages).

Ping me on Discord with any questions you might have. New discord channel: #right-to-left-languages. Thanks! Jeff

jzohrab commented 1 year ago

Good enough to be merged into the dev branch, at least as a first release.

jzohrab commented 1 year ago

Was launched in 2.1.1. :tada: