Separating views by locale?


#1

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
end

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

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.