st3v3nmw / obsidian-spaced-repetition

Fight the forgetting curve by reviewing flashcards & entire notes on Obsidian.md
https://www.stephenmwangi.com/obsidian-spaced-repetition/
MIT License
1.44k stars 182 forks source link

RTL Support Please #335

Closed safrilth closed 2 weeks ago

safrilth commented 2 years ago

Is your feature request related to a problem? Please describe. I use rtl plugin for some language written from right to left.. it works for editor and preview mode, but not flashcard mode..

Editor Mode : editor

Preview / Reading Mode : Reading

Flashcard Mode : flashcard

Describe the solution you'd like Flashcard should be display something like Preview / Reading Mode. the solution can be something to detect if display are using RTL or not (based on frontmatters showed in editor mode above ) : if yes, then display flashcard with RTL mode activated

danzilberdan commented 7 months ago

Hey. This will be awesome! Cannot use the plugin for my native language right now :( Great plugin though! Dan.

ronzulu commented 7 months ago

Shalom and/or salam @danzilberdan

Just to get some background, I translated a recent comment I posted using google translate: image

However, when I pasted it into Obsidian the RTL didn't match: image

Then when I changed the Obsidian editor setting for RTL it did display correctly: image

Can we assume that this fix only needs to work Obsidian itself is set for RTL?

Are you using the Obsidian RTL Plugin. I note that it requires the same frontmatter as per the OP:

---
direction: rtl
---

Cheers Ronny

danzilberdan commented 7 months ago

Understood. When changing Obsidian's default direction to RTL it works. But it is not useful because I type most of my notes LTR and just some in RTL. I am using Obsidian RTL Plugin and using the frontmatter as you have written.

ronzulu commented 7 months ago

I've made a simple change (using the HTML dir="rtl" mechanism) which hopefully works.

I've changed yesterday's text to be a question (with Obsidian RTL on):: image

And Obsidian RTL off: image

The flashcard (I think) displays correctly with this test code (Obsidian RTL off): image

Note that I haven't installed the Obsidian RTL Plugin

Testing

Could you please try out this test version of plug-in. main_335A.zip

You will need to copy that to the obsidian plug-in folder, e.g. D:\Obsidian\Obsidian\.obsidian\plugins\obsidian-spaced-repetition

Then reload the plug-in, or restart obsidian.

Note that the display of flashcards is currently hard coded for RTL (i.e. doesn't check the direction frontmatter)

danzilberdan commented 7 months ago

Perfect! And event better if it would parse the frontmatter. Amazing!

ronzulu commented 6 months ago

Great that it worked. I've now added the frontmatter check so hopefully this is complete now. main_335B.zip

I've also updated the flashcard "quick edit" modal to also honor the frontmatter direction setting, so if you could please verify that that works as well.

image

image

If all ok, then I'll create the PR so that it can be merged into the next mainstream release.

Cheers Ronny

ronzulu commented 6 months ago

Hi @issam-seghir

I've noticed that you contributed the Arabic translation to this plug-in and thought you might be interested in the requested RTL functionality that I've implemented.

It's in beta testing at the moment, and was wondering if you would be able to test as well. The latest code is the B version in my previous post above.

This new feature is probably only relevant if you have both LTR and RTL flashcards within the one vault, and use the direction frontmatter attribute, as per the Obsidian RTL Plugin.

Any feedback appreciated.

Cheers Ronny

ronzulu commented 2 weeks ago

This has been released into the latest mainstream release 1.12.5