Forum: Rails I18n Multilingual model content

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
9494521f20b539a631f720181c1208a6?d=identicon&s=25 Michael R. (damick)
on 2009-05-11 22:16

I'm looking for some insight in a small problem I have.

I need multilingual input in my models. Lets say you have a Product
model. That product contains title, description and price. The price is
allways the same, but the title and description need to be inputted in
diffrent languages.

I have used the I18n framework build in Rails, so no external plugin and
I would like to keep it that way.

One idea I was playing with is the following model build:


language -> I18n code like EN, BE, FR

But how do I link those 2 together, so that I can show the product
details in the current user language?

Is there a way to pass a variable trough the Product association like

has_one :product_language, :class_name => :product_i18n, :conditions =>
"language = users_current_language_code"

I know I'm on the good track, but I know I'm missing something.

thank you for the insight
E3b4547908d4efc5d1c52efcfc73d5f6?d=identicon&s=25 Wolfram A. (wolframarnold)
on 2009-05-20 09:54
Take a look at the globalize 2 plugin on github:

It covers model translation like you want to do and is recommended by
the author of the I18n Rails guide:
This topic is locked and can not be replied to.