# Multilingual model content

**URL:** <https://www.ruby-forum.com/t/multilingual-model-content/167848>\
**Category:** Rails\
**Created:** [May 13, 2009, 8:56am UTC](https://www.ruby-forum.com/t/multilingual-model-content/167848 "2009-05-13T08:56:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![roa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e7dd6/32.png) [@roa](https://www.ruby-forum.com/u/roa)\
**Post date:** [May 13, 2009, 8:56am UTC](https://www.ruby-forum.com/t/multilingual-model-content/167848/1 "2009-05-13T08:56:47Z")

</div>

Hi

I’m looking for some insight in a small problem I have. I allready  
posted this in the Rails I18n forum, but didn’t got any respond, so  
maybe it was just the wrong forum.

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:

## Product

id  
price

## ProductI18n

id  
product\_id  
language -\> I18n code like EN, BE, FR  
title  
description

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  
this:

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

---

<div class="post-metadata">

**Author:** ![roa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e7dd6/32.png) [@roa](https://www.ruby-forum.com/u/roa)\
**Post date:** [May 13, 2009, 9:01am UTC](https://www.ruby-forum.com/t/multilingual-model-content/167848/2 "2009-05-13T09:01:44Z")

</div>

On Wed, May 13, 2009 at 8:56 AM, Michael R.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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 wrote a plugin to solve the same problem you have.

[http://github.com/fesplugas/simplified\_translation/tree/master](http://github.com/fesplugas/simplified_translation/tree/master)

Hope that helps.

---

<div class="post-metadata">

**Author:** ![roa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e7dd6/32.png) [@roa](https://www.ruby-forum.com/u/roa)\
**Post date:** [May 13, 2009, 9:09am UTC](https://www.ruby-forum.com/t/multilingual-model-content/167848/3 "2009-05-13T09:09:47Z")

</div>

Francesc E. wrote:

> On Wed, May 13, 2009 at 8:56 AM, Michael R.  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > 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 wrote a plugin to solve the same problem you have.
> 
> [http://github.com/fesplugas/simplified\_translation/tree/master](http://github.com/fesplugas/simplified_translation/tree/master)
> 
> Hope that helps.

Hi Francesc,

it looked good till I started reading further. I saw that you need to  
define every language that you want to support in your attributes. The  
thing I wanted to do is make sure that the list of supported languages  
is dynamic.

---

<div class="post-metadata">

**Author:** ![roa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e7dd6/32.png) [@roa](https://www.ruby-forum.com/u/roa)\
**Post date:** [May 13, 2009, 9:25am UTC](https://www.ruby-forum.com/t/multilingual-model-content/167848/4 "2009-05-13T09:25:49Z")

</div>

On Wed, May 13, 2009 at 9:09 AM, Michael R.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> it looked good till I started reading further. I saw that you need to  
> define every language that you want to support in your attributes. The  
> thing I wanted to do is make sure that the list of supported languages  
> is dynamic.

In that case maybe the translate\_column plugin by Sam Lown may work for  
you.

```
http://www.samlown.com/en/page/RailsTranslateColumnsPluginReadme

```

---

<div class="post-metadata">

**Author:** ![roa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e7dd6/32.png) [@roa](https://www.ruby-forum.com/u/roa)\
**Post date:** [May 13, 2009, 9:31am UTC](https://www.ruby-forum.com/t/multilingual-model-content/167848/5 "2009-05-13T09:31:21Z")

</div>

Hi,

I’m going to take a look at the RailsTranslateColumnsPlugin. Maybe I can  
get some ideas from there.

---

<div class="post-metadata">

**Author:** ![roa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e7dd6/32.png) [@roa](https://www.ruby-forum.com/u/roa)\
**Post date:** [May 13, 2009, 9:26am UTC](https://www.ruby-forum.com/t/multilingual-model-content/167848/6 "2009-05-13T09:26:24Z")

</div>

Hi Michael,

if you want to have dynamic language support the best choice may be:

> **[GitHub - janne/model\_translations: Minimal implementation of Globalize2 style...](https://github.com/janne/model_translations/)**
>
> Minimal implementation of Globalize2 style model translations - GitHub - janne/model\_translations: Minimal implementation of Globalize2 style model translations

or (better)

> **[GitHub - joshmh/globalize2: The second incarnation of Globalize for Rails](https://github.com/joshmh/globalize2/)**
>
> The second incarnation of Globalize for Rails. Contribute to joshmh/globalize2 development by creating an account on GitHub.

and if you want the versions for your translations:

> **[GitHub - joshmh/globalize2\_versioning: Acts\_as\_versioned style versioning for...](https://github.com/joshmh/globalize2_versioning/)**
>
> Acts\_as\_versioned style versioning for Globalize2. Contribute to joshmh/globalize2\_versioning development by creating an account on GitHub.

The only problem with these plugins is that you can’t have the control  
of the translation model (eg.: you cannot have an upload field on  
translations model, it is difficult to apply constraints on translations  
model, etc.), but if your goal is simply translating string fields these  
plugins are great !

---

<div class="post-metadata">

**Author:** ![roa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e7dd6/32.png) [@roa](https://www.ruby-forum.com/u/roa)\
**Post date:** [May 13, 2009, 9:39am UTC](https://www.ruby-forum.com/t/multilingual-model-content/167848/7 "2009-05-13T09:39:19Z")

</div>

Taking a look at the code, maintenance and test coverage in my opinion  
model\_translations  
it’s a better solution than translate\_columns.

```
 http://github.com/janne/model_translations/tree/master

```

On Wed, May 13, 2009 at 9:31 AM, Michael R.

---

<div class="post-metadata">

**Author:** ![roa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8e7dd6/32.png) [@roa](https://www.ruby-forum.com/u/roa)\
**Post date:** [May 13, 2009, 9:43am UTC](https://www.ruby-forum.com/t/multilingual-model-content/167848/8 "2009-05-13T09:43:30Z")

</div>

Francesc E. wrote:

> Taking a look at the code, maintenance and test coverage in my opinion  
> model\_translations  
> it’s a better solution than translate\_columns.
> 
> ```
> http://github.com/janne/model_translations/tree/master
> 
> ```
> 
> On Wed, May 13, 2009 at 9:31 AM, Michael R.

Hmm,

indeed, its looks tidy and support rails i18n. Thank for the input! 🙂
