This is a re-release of a script of mine that helps convert CSS layouts to RTL. I originally released it about a year ago but it was lost when I moved to the new blog. The script,
cssrtl.py, utilizes a bunch of regular expressions to translate a given CSS layout to RTL.
You can download the script from here:
Using the script is pretty simple. Just pass the name of the script to
cssrtl.py and he will automatically translate it for you.
python cssrt.py main.css
You can use the
-o flag to specify a different output file instead of overwriting the existing file.
If the CSS style for the body tag is missing a
direction statement, you should add the
-d flag to the list of command line arguments. This will cause the script to add one for you when translating the layout.
python cssrtl.py --help for more information.
While this script is pretty useful as it is, it still isn’t perfect. The major limitation, is that the script doesn’t automatically mirrors images used in the layout. So if your layout contains images you will need to flip them manually (however the script will position them in right place by automatically). Another limitation is that the script doesn’t alway handle correctly scripts with IE hacks, so it always good to keep a backup and manually check the result on IE.
Overall, despite some (minor) limitations, the script is very useful, and it helped me a lot when having to translate CSS layouts to RTL. I’ve successfully used it to translate WordPress, Joomla, Druple and MediaWiki themes with minimal intervention on my side, thus saving a lot of my time. If you find the script useful, it will be nice of your to send a word. Also the script is released under the GPL so if you have any patches/improvements, please send them.