Skip to content

Conversation

@julienmalard
Copy link

@julienmalard julienmalard commented Dec 12, 2017

I arranged the RTD stylesheet to allow support for rtl (right-to-left) languages.

A few points:

  • Text direction is determined by the page content, not the language declared. Therefore, only pages that are actually written in (or have at least the first heading translated to) a rtlscript will appear as rtl.
  • The entire page is mirrored, including navigation, etc.
  • This works pretty much impeccably well on Firefox including with responsive design, which supports rtl detection.
  • For browsers that do not have support for rtl detection (:dir(rtl) attribute) yet, it works passably well (a few odd paragraph alignments and borders, and the navigation is still on the left side). But at least rtl text is readable, even on these browsers (the current RTD theme displays RTL text in the wrong order). And it is expected that other browsers will add rtl detection support soon, so this should be a temporary problem.

In summary, this pull request:

  • Appears to work perfectly for Firefox.
  • Works better than the current theme on other browsers.
  • Has no impact on left-to-right pages, no matter what browser is used.

For an example, see our partially translated Urdu site in which I overrode the default RTD theme with this one:
http://tinamit.readthedocs.io/ur/latest/docu/Conectado.html

Fixes #498

@ericholscher
Copy link
Member

Thanks for the contribution. However, these changes have been made to our CSS files, not our actual base SASS templates. They should be made there to be integrated into the theme properly:

https://github.com/rtfd/sphinx_rtd_theme/tree/master/sass

More docs on how to contribute and build things are here: https://github.com/rtfd/sphinx_rtd_theme#contributing-or-modifying-the-theme

@julienmalard
Copy link
Author

Ah, thank you! I will try to learn SASS and get back to you then.

@Blendify
Copy link
Member

To me, it appears that the css file changes are not needed at all. Also, I would rather set this up as a theme option that should default to auto or ltr

@Blendify Blendify self-requested a review December 16, 2017 05:10
Copy link
Member

@Blendify Blendify left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my above comment

@julienmalard
Copy link
Author

julienmalard commented Dec 16, 2017 via email

@agjohnson agjohnson added the PR: work in progress Pull request is not ready for full review label Dec 24, 2017
Copy link
Member

@Blendify Blendify left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert changes to sphinx_rtd_theme/static/css/theme.css

@Blendify
Copy link
Member

Blendify commented Jan 7, 2018

NM I just did.

@julienmalard
Copy link
Author

Thank you! I am trying to incorporate all of the css changes I had made into the original sass files (will update once I think I have finished).

@agjohnson agjohnson added this to the v0.4.0 milestone Mar 29, 2018
@agjohnson agjohnson removed this from the v0.4.0 milestone Jun 7, 2018
@agjohnson agjohnson modified the milestones: 0.5, 0.6 Jun 7, 2018
@strophy
Copy link

strophy commented Oct 10, 2018

Just checking in on progress with this issue - I am also using RTL languages and have hacked together some CSS conditional on the language being used, but would much prefer to have this done at the SASS level, since my overrides break some of the layout. Is there a more elegant way to do this until 0.5 milestone is reached?

If anyone is interested in the CSS, see this site: https://docs.dash.org/ar/latest/

@julienmalard
Copy link
Author

Hi,
Thanks for checking up! I really should get back to this...

I have learned SASS since my last comment and was recently searching for an automated gulp extension to add conditional RTL rules, but can't seem to find any. So I think I wil have to try to do this at the SASS level, property-by-property.

I will try to get to this next week, and would be very happy to collaborate. My code for now detects the first word of a page and decides whether it is RTL or LTR language (so that it automatically sets the direction as translations are added and made).

شكرا
-ژولئیں

@strophy
Copy link

strophy commented Oct 10, 2018

I'm not familiar with SASS so won't be much help unfortunately.... RTD sets the language correctly in the HTML tag though, so maybe you could try and detect direction based on that instead? My link above also modifies the CSS to move the navigation to the right of the page, but some more work is needed there to get this functioning properly on small screens.

@julienmalard
Copy link
Author

Hello,

Thanks! The problem I ran into with language tags is that there are a ton of languages that use different writing systems, and I did not fancy having to make a list of all possible languages that use each of the RTL scripts (arabic, divehi, hebrew, nko and probably a few others I have overlooked!), especially since there are quite a few languages that use arabic variants...

Out of interest, what differences are there between your implementation and mine (https://tinamit.readthedocs.io/ur/latest/docu/Modelo.html), navigation bar aside? I will try to keep the best of both for the final SASS version.

Will keep you posted,
Julien

@strophy
Copy link

strophy commented Oct 10, 2018

I think yours focuses more on text styles, while the main thing I tried to do was play with the navigation. I also integrated the CSS in a different way from conf.py, and use a different style of language selector. I might try and get the toc-expand toggles properly aligned and fix the breadcrumbs and GitHub link over the next few days, keep an eye on this file to see if anything useful is in there for you: https://github.com/dashpay/docs/blob/master/_static/style.css

@strophy
Copy link

strophy commented Oct 15, 2018

I've made more changes to the CSS overrides on my site and quite happy with the way it is looking now. Most changes are to get the navigation tree working correctly, and I integrated changes from #291 as well to fix indentation of lists. I'm not able to convert this to SASS, but hope this is useful to someone.

CSS: https://github.com/dashpay/docs/blob/master/_static/style.css
Result: https://docs.dash.org/ar/latest/

@strophy
Copy link

strophy commented Oct 26, 2018

I've added conditional CSS to support Arabic on small screens (mobile) as well. A language switcher was also added, although this does not exist in the parent theme, so that CSS would need to be removed if this was to be integrated into the Sphinx RTD theme one day.

CSS: https://github.com/dashpay/docs/blob/master/_static/style.css
Result: https://docs.dash.org/ar/latest/

@julienmalard
Copy link
Author

Interesting! I love the language switcher; much easier to find than on the original RTD theme.

@julienmalard
Copy link
Author

Hello,

I got it to work with SASS! At least mostly. If anyone could get the little arrows on the next and previous buttons to work it would be appreciated. :)

Please let me know if this looks better now.
Regards,
Julien Malard

@julienmalard
Copy link
Author

Hello,
Any news?
-Julien Malard

@julienmalard
Copy link
Author

Hello,
Any news? Please let me know if I can contribute anything.

@AustinShalit AustinShalit mentioned this pull request Aug 1, 2020
@Blendify
Copy link
Member

This is updated in #986 please follow the discussion there instead

@Blendify Blendify closed this Nov 25, 2020
@Blendify Blendify modified the milestones: 1.1, 1.0 Apr 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: work in progress Pull request is not ready for full review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants