Haml modification for i18n

| No Comments | No TrackBacks

I'm using the haml plugin in my rails application. In haml you can output plaintext like this:

Since i never output plaintext in my view because i use i18n i decided to modify haml:

So instead of outputting plaintext, you supply a i18n-key and haml outputs the translated text that belongs to that key.

The modification is quick & dirty and just a few lines long:
Go to the haml precompiler.rb and find the render_tag method. There should be a 'switch action' switch. Add the following lines to the switch:
This assumes that '_' is the method that is used for i18n. You can even append parameters:
This invokes _('my.i18n.key.here',:param1 => 'value')

No TrackBacks

TrackBack URL: http://ragmaanir.mypresident.de/mt/mt-tb.cgi/8

Leave a comment