Designing a Better CSS RTL Converter

About a year and a half ago, I’ve released cssrtl.py, a script that translates CSS code to RTL. The script was designed to be fully autonomous; however, translating CSS code is a complex task, as not all the information needed to make the translation is available in the CSS files. While cssrtl.py did a very good job on some tasks, it falls short in several areas:

  1. When a design update is released, one cannot use previous translation work.
  2. When things don’t go smoothly, it’s hard to find out why.
  3. Complex CSS can’t be translated automatically, as it requires understanding the structure of the corresponding html files and how the CSS will be used by future code.


There are two basic ideas behind building a new and improved replacement for cssrtl.py. The first is that, instead of translating the CSS file, the script will create a patch that translates the code. This would allow one to see the changes required for RTL and easily adapt them to new versions of the CSS code. This also solves the second problem, as it makes clear what changes were made by the script and what is part of the original code. The other change takes the script from trying to be autonomous to human-guided translation. Instead of making all the changes completely by itself, the script only makes trivial changes (which are most changes) and clearly leaves comments guiding the human operator on what work remains to be done. This approach saves a lot of time, as the script only does what it can and doesn’t hinder the translation effort by trying to translate code that it can’t translate properly.

Following this new design for a CSS-to-RTL converter, I’ve built a new version of cssrtl.py. The new version is still premature work, and some work needs to be done before I’ll be able to release it publicly. However, it already proved handy when I adapted a WordPress theme to Hebrew, which I intend to release soon.

Update 2009-08-15: I’ve released the mentioned WordPress theme; it’s the RTL port of the Fusion theme.

2 thoughts on “Designing a Better CSS RTL Converter”

Leave a Reply

Your email address will not be published. Required fields are marked *