28.12.07
Posted in Projects, Python at 11:28 am by Guy
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.
Read the rest of this entry »
Permalink
22.12.07
Posted in PHP, vim at 1:52 pm by Guy
I’m working on a website and we decided to localize it using GNU gettext. Soon enough I found it tiring to wrap each string manually in _( and ) and also to do it in Smarty (using {t}string{/t}. So I decided that I need a macro that will let highlight the string that needs translation and the macro will wrap for me.
I ended up writing two macros one for PHP files (but it’s also good for C/C++ etc.) and one for smarty.
:vmap tg di_(<ESC>pa)<ESC>
:vmap ts di{t}<ESC>pa{/t}<ESC>
To use these macros just highlight the string for translation in vim’s visual mode and press tg (or ts), and your string will be wrapped for translation.
Permalink
04.12.07
Posted in PHP at 3:53 pm by Guy
When working with Smarty, a PHP templating engine, I discovered that while the regular truncate modifier works great on ASCII strings, it doesn’t work with multibyte strings, i.e. UTF-8 encoded strings. This leads to problems in internationalization (i18n), as UTF-8 is the popular encoding for non-Latin alphabets nowdays. The problem can be solved by modifying the built-in truncate modifier and create a new one that takes an additional argument, the charset of the string, and acts accordingly. The new modified modifier, mb_truncate is implemented below.
Read the rest of this entry »
Permalink