December 12th, 2008 By: Daniel
A few more thoughts on handling I18n for real projects.
Images
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
Pagination was handled similarly with a helper to wrap the call to mislav’s will_paginate gem:
activerecord
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).
December 12th, 2008 at 10:36 am
December 20th, 2008 at 6:13 pm
def t_will_paginate(collection = nil, options = {})
will_paginate collection, {:prev_label => t(’constants.will_paginate.previous’),
:next_label => t(’constants.will_paginate.next’)}.merge(options)
end
January 31st, 2009 at 1:29 am
how can i put the next button at the left side?
and also, how can i put square brackets before the first link and after the last link which the user can not click.
February 4th, 2009 at 9:54 am