Hi all,
I've been poking at globalize with Rails Edge, and it's dying because of the Rails overhaul of ActionView and templates, but in a good cause. The following Rails 2.0 change:
multiple controller view paths
renders localized templates trivial to do. It seems to me the best solution at this point is to simply ditch lib/globalize/lib/rails/action_view.rb and just let users move this into the main application logic like so: (taken from a sample application.rb):
before_filter :set_locale
# Determines the user's language of choice
def set_locale
(...typical code that among other things sets @locale to user's locale here...)
# use the user's locale in their view path
prepend_view_path File.join(File.dirname(__FILE__), '..', "views/localized/#{@locale}")
end
This particular solution will cause Rails to go look in views/localized/[locale]/ first and then fall back to the normal structure. So for instance, I have views/users/show.html.erb as the default, and then I have views/localized/fr/users/show.html.erb. When the viewer's locale is set to 'fr' the latter is the version that will appear.
This allows for individual-application control over how localized templates are managed, sequesters these templates nicely, and eliminates the need for globalize itself to be modified for future versions of Rails if future changes happen in this area.
Does anyone have thoughts on this? See a problem I've missed with this solution?