Designing a Better a CSS RTL Convertor

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 lacks on several issues:

  1. When a design update is released, one cannot use previous translation work.
  2. When things don't go smooth, it's hard to find out why.
  3. Complex CSS can't be translated automatically, as it requires understanding of 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, instead of translating the CSS file, the script will create a patch that translates the code. This would allow to see the changes required for RTL changes and easily adapt new version of the CSS code. This also solves the second problem, as it makes clear what changes where made by the script and what are 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 remained to be done. This approach saves a lot of time as the script works only does what it can and doesn't hinder the translation efforts by trying to translate code that it can't translate properly.

Following this new design for CSS to RTL convertor, 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 revealed itself 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 RTL port of the Fusion theme.

2 thoughts on “Designing a Better a CSS RTL Convertor

Leave a Reply

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