Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Feb 9, 2024

Conversation

TheAwiteb
Copy link
Collaborator

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 TheAwiteb requested a review from welpo as a code owner February 9, 2024 12:50
@TheAwiteb
Copy link
Collaborator Author

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

@welpo
Copy link
Owner

welpo commented Feb 9, 2024

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:

  • Set this variable in the i18n files (this way it'll always be accurate).
  • 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.

What are your thoughts?

@welpo welpo changed the title Add support for RTL ✨ feat(i18n): add Right-to-left script support Feb 9, 2024
@TheAwiteb
Copy link
Collaborator Author

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
Copy link
Owner

welpo commented Feb 9, 2024

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
Copy link
Collaborator Author

TheAwiteb commented Feb 9, 2024

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

  • Arabic (ar)
  • Aramaic (arc)
  • Azeri (az)
  • Divehi (dv)
  • Fula (ff)
  • Hebrew (he)
  • Kurdish (ku)
  • N'ko (nqo)
  • Persian (fa)
  • Rohingya (rhg)
  • Syriac (syc)
  • Urdu (ur)

I'll make the is_rtl macro return true for them

@TheAwiteb
Copy link
Collaborator Author

Ok, I think this is better than macros

templates/base.html Outdated Show resolved Hide resolved
@welpo
Copy link
Owner

welpo commented Feb 9, 2024

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

Merging now.

Many thanks for your contribution!!!

@welpo welpo merged commit 1d55a29 into welpo:main Feb 9, 2024
1 check passed
Smtbook pushed a commit to Smtbook/zola-theme-tabi that referenced this pull request Feb 29, 2024
Co-authored-by: welpo <welpo@users.noreply.github.com>
welpo added a commit that referenced this pull request Sep 15, 2024
- Replace directional properties with logical ones.
- Enhance compatibility with right-to-left languages across the site's design.

Related: #257 #262 #270 #272 #274 #368
welpo added a commit that referenced this pull request Sep 15, 2024
- Replace directional properties with logical ones.
- Enhance compatibility with right-to-left languages across the site's design.

Related: #262 #270 #272 #274 #368
welpo added a commit that referenced this pull request Sep 15, 2024
- Replace directional properties with logical ones.
- Enhance compatibility with right-to-left languages across the site's design.

Related: #262 #270 #272 #274 #368
welpo added a commit that referenced this pull request Sep 15, 2024
- Replace directional properties with logical ones.
- Enhance compatibility with right-to-left languages across the site's design.

Related: #262 #270 #272 #274 #368
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants