Yet Another Rails Translation System

The forthcoming Rails 1.2 addresses the multi-byte text part of the
i18n problem, but not the translation part. I’ve been looking for a
nice simple way to do things, but haven’t found anything which feels
quite right so far.

Inspired by Thomas F.’ minimalist translation script ( http://
mir.aculo.us JavaScript with Thomas Fuchs » Blog Archive » Ruby on Rails i18n revisited ), I’ve created
yet another translation system.

This differs from the gettext _() approach:

  • Unobtrusive format in templates: ``To translate’’ rather than <%= _
    (‘To translate’) %>

  • The string lookup is done once per template at compile time for a
    more efficient system: no repeated lookups on every request.

  • The translated bits can contain code, like ``To translate with a <%
    = number %> of items’’ so order of the inserts can be modified.

  • You can refer to text by a symbol so translations aren’t lost when
    you make minor changes to the text. ``:symbol The text to translate’’

More details, the code, and a sample app, here:

http://www.fluffy.co.uk/rails-translation/

I would appreciate comments on this approach before I start using it
in my app!

Thanks,

Ben