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

RTL support #45

Merged
merged 17 commits into from
Sep 19, 2022
Merged

RTL support #45

merged 17 commits into from
Sep 19, 2022

Conversation

jason-fox
Copy link
Collaborator

Bootstrap 5.2.0 brings full support for RTL languages like Arabic

  • load alternate Bootstrap CSS
  • Amend collapsible CSS
  • Update Nav.xsl to encode images and links in a RTL friendly manner

Screenshot 2022-06-06 at 11 59 36

@jason-fox jason-fox marked this pull request as draft June 6, 2022 10:12
@jason-fox jason-fox added this to the 5.3.2 milestone Jul 3, 2022
@jason-fox
Copy link
Collaborator Author

Stable bootstrap 5.2.0 has released.

Updated CDN to use 5.2.0 and 5.2.0 RTL CSS

@jason-fox jason-fox marked this pull request as ready for review July 21, 2022 19:10
jason-fox and others added 5 commits September 11, 2022 22:01
- load alternate Bootstrap CSS
- Amend collapsible CSS
- Update Nav.xsl to encode images and links in a RTL friendly manner
Signed-off-by: Roger Sheen <roger@infotexture.net>
Comment on lines 113 to 116
<matches
string="${default.language}"
pattern="((ar|arc|bcc|bqi|ckb|dv|fa|glk|he|lrc|mzn|pnb|ps|sd|ug|ur|yi)(\-|$))"
/>
Copy link
Owner

Choose a reason for hiding this comment

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

Will this automatically be applied if the xml:lang attribute is set to one of the corresponding values in the DITA source, or would the user need to change something else to trigger RTL rendering?

Shall we document that somewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Bootstrap LTR or RTL CSS is usually an all or nothing affair. The Bootstrap docs are here Either the whole page of components is displayed RTL or the whole page of components is displayed LTR there is no facility yet to reduce this to the xml:lang attribute level. using the default CSS. This is the reason why the load occurs on the default.language level.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looking into this more deeply, it gets a bit more complex. I've added some RTL documentation 89bbcf4 to explain how it works. The problem is that the first topic usually sets the layout for the whole HTML page, which is fine for mono-lingual documents, but may not be what you want for multi-lingual docs. The question is does the nav go on the left or the right in these cases?

Copy link
Owner

@infotexture infotexture left a comment

Choose a reason for hiding this comment

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

I've added some RTL documentation 89bbcf4 to explain how it works.

👍 Thanks, that definitely helps.
We might want to change this topic's position in the ToC though (see related code comment).

The problem is that the first topic usually sets the layout for the whole HTML page, which is fine for mono-lingual documents, but may not be what you want for multi-lingual docs. The question is does the nav go on the left or the right in these cases?

I'm not sure of the conventions w/r/t ToC placement in RTL docs, but we might be able to get away with the first topic setting that.

If a docset is mostly English with a bit of Arabic, keeping the ToC on the left seems “right”.
If docs contain mostly RTL languages, readers may prefer the ToC on the right, even if they contain bits of LTR text.

build_dita2html5-bootstrap.xml Outdated Show resolved Hide resolved
plugin.xml Outdated Show resolved Hide resolved
plugin.xml Outdated Show resolved Hide resolved
@@ -20,6 +23,17 @@

<xsl:template match="*" mode="addContentToHtmlBodyElement">
<main xsl:use-attribute-sets="main">
<xsl:if test="$BIDIRECTIONAL_DOCUMENT = 'yes'">
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
<xsl:if test="$BIDIRECTIONAL_DOCUMENT = 'yes'">
<xsl:if test="$BIDIRECTIONAL_DOCUMENT = 'yes'">

Customization/xsl/topic.xsl Outdated Show resolved Hide resolved
@@ -12,6 +12,7 @@
<navtitle>Getting Started</navtitle>
</topicmeta>
<topicref navtitle="Introduction" format="dita" href="index.dita"/>
<topicref navtitle="RTL" format="dita" href="rtl.dita"/>
Copy link
Owner

Choose a reason for hiding this comment

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

Since RTL support may not be the first thing everyone needs, should we move this down to the next section (Layout) instead?

I realize the grid system and RTL are not directly related, but some might think of this as “RTL layout”.

Thoughts? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed 5666b38

@infotexture
Copy link
Owner

Apart from the comments above, I think this is shaping up nicely.

I'd be inclined to merge this soon and spawn a release branch to package up a 5.3.2 release, so we can ship the features you've added this summer. I'd do a final round of proofreading on the latest doc updates, but that shouldn't take long.

— Or is there anything else you'd like to add for 5.3.2?

We can always tweak further for 5.3.3, and ship the improvements with dark mode once Bootstrap 5.3 is ready.

@infotexture
Copy link
Owner

@jason-fox Also, this: #46 (comment)

@jason-fox Have you considered speaking about your recent enhancements here at DITA-OT Day in Rotterdam?

✨ I'm sure the new features would be interesting to the audience there.

actions-user and others added 6 commits September 18, 2022 13:15
Co-authored-by: Roger Sheen <roger@infotexture.net>
Co-authored-by: Roger Sheen <roger@infotexture.net>
Co-authored-by: Roger Sheen <roger@infotexture.net>
Co-authored-by: Roger Sheen <roger@infotexture.net>
@jason-fox
Copy link
Collaborator Author

I'd be inclined to merge this soon and spawn a release branch to package up a 5.3.2 release, so we can ship the features you've added this summer. I'd do a final round of proofreading on the latest doc updates, but that shouldn't take long.

Agreed. Dark Mode won't work until a proper Bootstrap 5.3 is released, the current draft doesn't work with 5.2, only with an experimental CSS. I think I have applied the suggestions. Please proofread and release.

@jason-fox
Copy link
Collaborator Author

jason-fox commented Sep 18, 2022

If a docset is mostly English with a bit of Arabic, keeping the ToC on the left seems “right”.
If docs contain mostly RTL languages, readers may prefer the ToC on the right, even if they contain bits of LTR text.

Again looking even further I think I have fixed this now, if --bidi.include=yes

  • the <html> should take the default lang and dir
  • the <main> should be empty
  • the <nav> should take the default dir
  • the <article> should take the lang and dir associated to the topic.

If a docset is mostly English with a bit of Arabic, use defaultLanguage=en to keep the ToC on the left .
If docs contain mostly RTL languages use defaultLanguage=ar to keep the ToC on the right,
If a whole topic is RTL in an otherwise English document, annotate the topic with <topic xml:lang="ar">
if that in turn contain bits of LTR text use dir="ltr"to flip.

@infotexture infotexture merged commit a45e2df into infotexture:develop Sep 19, 2022
@jason-fox jason-fox deleted the feature/rtl branch September 21, 2022 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants