I18n on model attributes

Hi, I have to set those language flags on my website, and depending on which one was selected it should show the pages in specific languages.

Problem is that this translation is also needed for the model attributes.

How should I do that?

Just save many attributes (one for each language) for each attribute I currently have and then set a lot of if’s in my html?

Thank you,


You should have a look at the Rails Internationalization Guide,
especially the part about localizing Active Model attributes.

Simply set the local for the I18n API:
I18n.locale = :de

and translate all the active model attributes:

      user: Dude
        login: "Handle"
      # will translate User attribute "login" as "Handle"

Hope that helps!

You need a config/locales/es.something.yml file that looks like:

      user: Usuario
        name: Nombre

This way you'll have your attribute and models names translated when
you use.
Remember to have the same strings translated for, at least, :en and to
keep an eye on spaces and indents when editing .yml files

form_for :user .... do |f|
f.label :name


Hi Rodrigo,

There are tools available for this sort of thing, but it seems like you need a bit of orientation first. Check out this guide:


For further questions after that, I recommend this group:


Best of luck,

Walter McGinnis

I meant translation of the content of those attributes, not the name of the attributes

Sorry for the misunderstanding.

Globalize gem seems to be what you need: https://github.com/svenfuchs/globalize3