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,
Rodrigo
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:
en:
activerecord:
models:
user: Dude
attributes:
user:
login: "Handle"
# will translate User attribute "login" as "Handle"
Hope that helps!
You need a config/locales/es.something.yml file that looks like:
es:
[...]
activerecord:
models:
user: Usuario
attributes:
user:
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
...
Regards.
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:
http://guides.rubyonrails.org/i18n.html
For further questions after that, I recommend this group:
http://groups.google.com/group/rails-i18n
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