Forum: Ruby on Rails Separating views by locale?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Duane M. (Guest)
on 2009-01-14 23:55
I'm thinking this has to be a common question, but thus far I haven't
found it, maybe somebody can point me in the right direction.

If I've got a controller Foo, and a page views/foo/index.rhtml, and I
want to handle multiple languages, I'm thinking that one way to go would
be to create views/foo/en/index.rhtml, views/foo/fr/index.rhtml, ... and
so on for each supported locale.  Then instead of the default:
  def index
    render :action=>:index

I could do something like this:
  def index
    render :action=>"#{locale}/index"

Question 1 is, would that work?  I'm hacking on the code now so I'm sure
I'll find out in two minutes.

Question 2 is, assuming that this does work, what would be the best way
to chain in at a higher level so I didn't have to do this for every
single method of every controller?  I'm reading the docs on
ActionController and ActionView but not seeing any obvious places.

Please note that I am already in the process of doing string
externalization into config/locales/fr.yml and so on.  I'm just
exploring this different strategy for situations where I've got
substantial blocks of content in the views that might be better served
with a clone of the entire page.
This topic is locked and can not be replied to.