Towards a better RTL solution

Events happening in the community are now at Drupal community events on www.drupal.org.
good_man's picture

A comment by @catch caught my attention three days ago:

Is there any way to automate testing for missing RTL css?

So I thought of a solution, similar in goal to localization project (localize.drupal.org) by Gabor. Talked with Gabor about it a little bit, and agreed to write it here to discuss further.

In short, the project will make the process of making RTL themes/modules/css files much more easier. The ultimate goal would be, to not touch or create RTL files again, because they'll be created automatically.

The initial workflow for this project will be:

  • Tokenizer for CSS.
  • Replacing LTR stuff with RTL (read the linked document below).
  • (Maybe) Flipping images horizontally with specific suffix (e.g. foo-ltr.png).
  • Writing the resulted RTL css on file or on screen.

The above steps can be implemented in sandbox -> module, then will try to make it a part of Drupal.org contribution/issues.

I've tried to list all the possible cases for LTR => RTL conversion in this document If you find/know more, tell me.

Some problems/points:

  1. Right now, Drupal adds the RTL files *with* the LTR css files. The pros of this approach is smaller file size *only* for the RTL file (only flip the LTR stuff). The cons is that you need to reset some LTR prop. to the default in RTL file (e.g. left: 10px; in LTR file, will be right: 10px; left: auto; i.e. resetting the LTR prop. to the default, those cases are listed in the document above), also the number of HTTP requests without cache are in worst case, the double. We can discuss whether to change this behaviour (I think it'll be an overhead when migrating to this new system), or to stay with the old behaviour and live with the LTR resetting problem.
  2. We can benefit from /* LTR */ comment in LTR files. I don't think core is using them now (correct me if I'm wrong). Though this comment is not needed if we built/used a good tokenizer. Because some module's maintainers don't write this comment at all, so we can't fully rely on it.
  3. Sometimes, you may want to change the RTL file to add new fonts, different style. We should make sure not to overwrite it.

Related projects:

Ah, no name for this project yet, if you find a good name, write it in comments please.

Internationalization

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: