I am new to Rails and I need to implement internationalization in an application.
Till now I looked through r18n-rails, globalize3 and gettext_i18n_rails.
I have to internationalize the templates text along with some DB data (some categories as an example).
I like the way gettext_i18n_rails works with templates text but it doesn’t provide any solution for DB data (or does it?). From other side r18n-rails and globalize3 seem to do the job for DB data but not for templates. At first I thought to combine them (globalize or r18n + gettext_i18n_rails) but this could nod be a good idea, especially if this is gonna be a big project.
So my question is:
What is the best I18n approach for Rails 3 considering templates text + DB text + project size?
The best approach in Rails 3 is using the built-in mechanism, the I18n gem.
I am not sure if I understand you problem with the DB data. If you define the categories in the database, just add an i18n key to them and in the model return the translated title.
e.g.
you then can use the translated_title method for displaying the category’s title.
If you have more questions about I18n in Rails, we just did a series on our blog:
Internationalization (I18n) API in Ruby on Rails 3 (Part I)
Internationalization (I18n) API in Ruby on Rails 3 (Part II)
Part 3 is coming out next week, with a PDF including all the topics.