welpo / tabi

A modern Zola theme with search, multilingual support, optional JavaScript, a perfect Lighthouse score, and a focus on accessibility.
https://welpo.github.io/tabi/
MIT License
97 stars 32 forks source link

✨ feat(i18n): add Right-to-left script support #262

Closed TheAwiteb closed 4 months ago

TheAwiteb commented 4 months ago

Add support for RTL languages, such as Arabic and Hebrew, by adding the dir attribute to the body tag if the language is RTL.

What changes did you make?

I added the extra.rtl and extra.lang_rtl.<lang> to the config, with this change, we can specify the languages that are RTL and the dir attribute will be added to the body tag.

TheAwiteb commented 4 months ago

As I saw, after experimenting with writing an article in Arabic, this is the only change to support RTL

welpo commented 4 months ago

Hi Awiteb!

Thanks for this PR! I am curious: did you consider other options to implement this?

To avoid adding an extra variable and simplify the workflow, I thought of these two options:

What are your thoughts?

TheAwiteb commented 4 months ago

Have an internal list of RTL languages inside the tabi templates. Check if current language matches one of the list. If so, implement the body change.

I like this, so should I add it to the is_rtl macro right?

welpo commented 4 months ago

Even though it will only be used once (as far as I can foresee), I think using the macro is a good idea, yes.

That way we can centralise the logic on one spot.

TheAwiteb commented 4 months ago

As I found, there is only 12 RTL languages which is

I'll make the is_rtl macro return true for them

TheAwiteb commented 4 months ago

Ok, I think this is better than macros

welpo commented 4 months ago

I've made that change + minor stuff (spacing; rename variable).

Merging now.

Many thanks for your contribution!!!