-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Add RTL Support #2367
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
base: master
Are you sure you want to change the base?
Add RTL Support #2367
Conversation
I'm running my Persian blog based on these changes, and it seems works perfectly. https://zakariafatahi.ir/ |
hello @cotes2020 I just wanted to check if there’s anything else needed from my side to move this PR forward or if there are any concerns about merging it. |
Hi there, this is an excellent PR and thank you for your effort! Since there are quite a lot of changes, I’ll need to find some time to review it. Please don’t worry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for leaving this PR pending for so long. Here is my initial review:
-
Defining different webfonts for specific languages is too complex and will make the project harder to maintain. Therefore, for languages other than English, it's better to use the system's default fonts.
-
If you want to achieve automatic enabling of the RTL (right-to-left) attribute by intelligently identifying the language, then the configuration file does not need new settings. The Liquid code can identify which languages are RTL.
Thank you for the review! Regarding the font: I agree it's better to keep things simple for maintainability. That said, the default English font renders quite poorly for RTL languages in practice. For now, I’ve removed the custom fonts as suggested, but I’ll experiment with a simpler approach in a future PR—likely by adding something like this to config.yml file: # Font Configuration
fonts:
# Base font for body text
base: ["Source Sans Pro", "Microsoft Yahei", sans-serif]
# Font for headings
heading: ["Lato", "Microsoft Yahei", sans-serif]
# Optional: Google Fonts to load
google_fonts:
# - "Roboto:400,700"
# - "Montserrat:700" I'll open a separate PR for this to keep things clean. As for RTL detection via Liquid: I had tested that path, but couldn’t find a reliable way to automatically detect RTL languages purely within Liquid. I’ve simplified the implementation significantly in this PR to make it easier to manage. Thanks again! |
Hey @zakariaf I just saw your RTL - it looks really awesome! I did however notice one thing - not sure if it's intentional or not In the default LTR version, the button to copy the header link is right next to the title |
aec9f3a
to
9a165d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... but couldn’t find a reliable way to automatically detect RTL languages purely within Liquid.
Use this code to automatically detect RTL:
{% assign _lang_code = lang | split: '-' | first %}
{%- case _lang_code -%}
{%- when 'ar', 'fa', 'he', 'iw', 'kd', 'pk', 'ps', 'ug', 'ur', 'yi' -%}
{% assign dir = 'rtl' %}
{%- endcase -%}
Additionally, please move the newly added files in _data/locales
to a separate PR. The file _posts/2025-04-20-rtl-test-persian.md
doesn't need to be included in the repository either.
Hey @Nicolai9852, thanks for catching that! I think it was a mistake — I just fixed it. Appreciate you pointing it out! |
@cotes2020 Thanks so much for the suggestions! I’ve applied all of them. Also, I just created another PR for the new locale files: |
fix: add dir variables and update comments for clarity on language and direction detection fix: update HTML lang and dir attributes to use correct language variables from lang.html feat: add Persian RTL test post with comprehensive content and formatting feat: add RTL font loader to support appropriate font loading based on page language feat: add RTL styles and font support for Arabic, Persian, and Urdu languages feat: enhance RTL support by adding additional languages to the configuration fix: remove pin attribute from Persian RTL test post feat: add comprehensive RTL support documentation fix: update comment to clarify lang and dir attributes usage in HTML layout fix: improve formatting of RTL content creation instructions in documentation fix: swap float directions for images in Persian RTL content fix: remove duplicated font source and unicode-range for RTL fonts fix: update font weights for RTL language stylesheets fix: add spaces to read time unit and prompt for better formatting fix: reorder RTL font loader inclusion for rendering after googlefonts fix: update RTL language configuration to use 'fa' instead of 'fa-IR' for better compatibility fix: add transform to sidebar for better responsiveness in RTL layout fix: add RTL Support feature to README fix: update RTL support comments for clarity fix: enhance RTL support documentation for clarity and usability fix: correct meta format in fa.yml for clarity Signed-off-by: Zakaria Fatahi <[email protected]> fix: improve sidebar transform handling for RTL layout in mobile refactor: remove RTL font loader and associated styles for cleaner codebase refactor: streamline RTL support configuration and enhance language direction detection chore: remove obsolete RTL support documentation refactor: remove RTL configuration and streamline language direction detection chore: remove RTL support mention from README refactor: remove obsolete Persian RTL test post for cleaner codebase refactor: adjust anchor float and margin for improved RTL styling refactor: remove rtl.scss from main.scss and move to _scss/base refactor: revert all changes about locale files feat: dir is an optional attribute of html element Co-authored-by: Cotes Chung <[email protected]> Signed-off-by: Zakaria Fatahi <[email protected]> refactor: add padding and border styles for access panel in RTL refactor: adjust archive styles for improved RTL layout feat: add padding styles for categories in RTL layout feat: add margin styles for list items in page category for RTL layout feat: add margin styles for tag spans in RTL layout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The search bar and the trending tags and TOC in the panel are still not vertically aligned. Please test each page locally first. Thank you!
- adjust margins for post-meta and post-tags - enhance page category and tag structure - fix category trigger rotate - adjust margin for .pin class
I tried to check everything, I think all are fixed now. |
Add RTL Support to Jekyll Theme Chirpy
Type of change
Description
This PR adds comprehensive Right-to-Left (RTL) language support to the Chirpy theme. It enables the theme to automatically detect RTL languages and apply appropriate styling, making it accessible to users of Arabic, Kurdish, Persian, Urdu, and other RTL languages.
The implementation:
Important behavior to note: When viewing a page with an RTL language code (e.g.,
lang: fa
,lang: ar
andrtl: true
), the theme will automatically switch to RTL mode for that page and use the appropriate locale. This is standard behavior for internationalized websites and follows web accessibility best practices.Key components:
lang.html
to detect RTL languagesrtl.scss
with comprehensive RTL stylingNew Files
_sass/rtl.scss
: Contains RTL-specific styles for layout and UI elements_data/locales/
: locale files as reference implementation:fa-IR.yml
: Persian (Modified)ku-IQ.yml
: Kurdish (Sorani)ur-PK.yml
: Urdups-AF.yml
: Pashtodv-MV.yml
: Dhivehi_posts/2025-04-20-rtl-test-persian.md
: Persian translation of the sample post(text-and-typography) showcasing all theme featuresModified Files
_sass/main.scss
: Added import for rtl.scss_includes/lang.html
: Added RTL detection logic_layouts/default.html
: Added dir attribute to HTML tag_config.yml
: Added RTL configuration optionsThis change enhances accessibility for millions of users worldwide who read and write in RTL languages without affecting any existing functionality.
Screenshots
Additional context
This implements a non-breaking enhancement that makes the theme more accessible to global users.
Note: The implementation requires a small addition to
head.html
to include the RTL font loader, which I've documented in the PR.This closes the issue #1928 too