dokuwiki icon indicating copy to clipboard operation
dokuwiki copied to clipboard

Added support for RTL text in an LTR blog

Open githubsaturn opened this issue 4 years ago • 8 comments

Self explanatory.

I am unsure where details.php is being used. But if it's used for the same format, we'll have to apply the same modification there too.

githubsaturn avatar Feb 22 '21 03:02 githubsaturn

Sorry this is far from self explanatory. Can you please provide details on what exactly this fixes and why it's necessary?

splitbrain avatar Feb 22 '21 14:02 splitbrain

@splitbrain - apologies for being unclear.

As the title suggest, this PR is adding support for RTL text.

More details: dir="auto" helps browser to set the content in the correct direction. You can try the following text as your page content:

صفحه

متن متن متن متن متن متن متن متن متن متن متن

متن متن متن متن متن متن

متن متن

متن متن متن متن متن متن متن متن

Without this PR, it gets rendered left aligned (similar to how Github renders it here).

After this change, this is how it gets rendered: image

githubsaturn avatar Feb 22 '21 23:02 githubsaturn

By setting https://www.dokuwiki.org/config:lang the ltr and rtl are swopped as well. The direction is available as dir attribute to the html element. See e.g. https://codesearch.dokuwiki.org/xref/dokuwiki/lib/tpl/dokuwiki/main.php#16

How is this dir=auto combining with existing one?

Klap-in avatar Feb 22 '21 23:02 Klap-in

Sure, but that's a global config, right? It applies to the entire side.

The change proposed in this PR is to address a case where the site is LTR but one (or some) posts are in RTL language.

The screenshot above is in an example of that - where the site is LTR, but this single post is in RTL language.

Regarding this question:

How is this dir=auto combining with existing one?

Like I said above, if the site is in English, but one post is in an RTL language, this change would cover it.

I haven't tried the reverse, but I assume it is the same. i.e., dir="auto" would left align an English post in and RTL site.

githubsaturn avatar Feb 23 '21 00:02 githubsaturn

Although dir=auto helps somewhat in that case, it would be better (for translation services, like Google Translate, and screenreaders) if you set the correct lang as well. You can do that with the Wrap plugin via <WRAP :fa>متن متن متن</WRAP>. That will translate into <div lang="fa" dir="rtl" [...]>متن متن متن</div>.

selfthinker avatar Feb 24 '21 08:02 selfthinker

Interesting. Wasn't aware of this sorcery.

I still believe dir="auto" is no harm, and it's the way to go as it automatically handles these cases without manual intervention.

But if the community thinks otherwise, feel free to close the PR as there is an alternative solution using WRAP to fix this issue.

githubsaturn avatar Feb 24 '21 13:02 githubsaturn

I don't think it does any harm either.

If you have whole pages in other languages, you could also use the Translation plugin. That can change the whole page's language (and dir) as well (via the translateui setting).

I thought it would change lang and dir on the main content if it is not set to change the whole page's language, but I just checked and noticed that it doesn't do that. I will open an issue for that.

selfthinker avatar Feb 24 '21 15:02 selfthinker

If you set the lang parameters with the ComboStrap plugin, you get the according language and direction set up.

Demo

gerardnico avatar Jun 21 '21 13:06 gerardnico