views:

198

answers:

3

While I have experience developing Rails apps in English, I am a blank slate when it comes to handling globalization, so please don't shoot me in the head if my question 'doesn't make sense' :)

I have been asked to add multi language feature to a part of a Rails app that I am working on. Initially its only going to be 2 languages, French and German. The content that will be translated (which is in English now) is rendered using partials at the moment hence I am getting a bit inclined on creating partials with different languages and then based on the users language selection call the relevant partial - Would you recommend this approach?

Although it seems a heavy weight solution for this particular purpose, but I am also looking at the Rails Globalize plugin. This seems to appeal if I look at the long term gains, something like what if later I am asked to translate the entire app.

Any insights on what would be a proper structured approach to handle globalization in Rails?

Many Thanks

+1  A: 

Hey there,

This is a great article on how to use Ruby's GetText to localise you Rails App.

Blounty
I'd vote this down if I had enough repetition ;) As Andy points out above, Rails has had built-in i18n since 2.2, and I'd strongly recommend on using it - either as is, or with a the added functionality of a plugin such as Globalize2
Casper Fabricius
Don't write off GetText yet - last time I checked, it was a still noticeably faster solution. And more importantly, I think the syntax is better. For one, _("Hello world") looks better than t(:hello_world), but more importantly, the you have to keep one less translation file set - your default language texts are there in the source.
Toms Mikoss
+4  A: 

Have you had a look at the i18n (internationalization) API that is in Rails itself as of 2.2? It makes it easy to store your language translation files as .yml files, so a fr.yml and a de.yml or whatever. It also steps through different approaches of making languages accessible via browser prefs, or URLs, subdomains, etc. In your HTML template files you use symbols to specify the keys for the string you've translated. At least in my basic usage and testing, it was very easy to work with.

Andy Atkinson
+2  A: 

I preffer using translator instead of Rail's i18n, since the former handles "scoping of translation" automatically. I recommend you give it a look.

egarcia