December 12th, 2008 By: Daniel
A few more thoughts on handling I18n for real projects.
The way I handled images was pretty simple. Just added this application_helper:
Then I created a directory in public/images for each of the supported locales (e.g. public/images/en-US), put all the images with text in there and I was good to go.
Pagination was handled similarly with a helper to wrap the call to mislav’s will_paginate gem:
Oh and another thing that really helped was using the human_name stuff built in to activerecord. So, for example, everywhere I found an “Agent” in the text instead of an explicit call to translate I could just doAgent.human_name. And for each of Agent’s attributes I could do Agent.human_attribute_name(’name’). And that even works when it’s not a real attribute, but just one of Agent’s public methods (or anything else for that matter). Plus it’ll work for your form labels too, once you install the i18n label plugin. (One caveat though: label User, :username won’t work. It has to be a form_for(@user) do |f| and then yourf.label :username will show the human_attribute_name).