# Best way to internationalize content from database

**URL:** <https://www.ruby-forum.com/t/best-way-to-internationalize-content-from-database/190985>\
**Category:** Rails\
**Created:** [July 1, 2010, 10:36pm UTC](https://www.ruby-forum.com/t/best-way-to-internationalize-content-from-database/190985 "2010-07-01T22:36:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![andersonleite](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/45deac/32.png) [@andersonleite](https://www.ruby-forum.com/u/andersonleite)\
**Post date:** [July 1, 2010, 10:36pm UTC](https://www.ruby-forum.com/t/best-way-to-internationalize-content-from-database/190985/1 "2010-07-01T22:36:58Z")

</div>

Hello all.

It’s ok to internationalize thing at app using rails, but how to deal  
with content from database ?

What’s the best aproach ? I don’t wanna do things like:

\<% if english %\>  
\<%= obj.name\_english%\>  
\<% else %\>  
\<%= obj.name\_japanese%\>  
\<% end %\>

The best way is to do all at controller ? model ?

How do you thing is the better approach ?

Thanks

---

<div class="post-metadata">

**Author:** ![andersonleite](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/45deac/32.png) [@andersonleite](https://www.ruby-forum.com/u/andersonleite)\
**Post date:** [July 1, 2010, 11:09pm UTC](https://www.ruby-forum.com/t/best-way-to-internationalize-content-from-database/190985/2 "2010-07-01T23:09:13Z")

</div>

Anderson L. wrote:

> Hello all.
> 
> It’s ok to internationalize thing at app using rails, but how to deal  
> with content from database ?

I think that may not be a good approach. I think it’s better to keep  
translated strings in PO files – that way, you can hand them off to  
translators.

Take a look at fast\_gettext for this. It’s nicer than Rails’ own I18N.

> What’s the best aproach ? I don’t wanna do things like:
> 
> \<% if english %\>  
> \<%= obj.name\_english%\>  
> \<% else %\>  
> \<%= obj.name\_japanese%\>  
> \<% end %\>
> 
> The best way is to do all at controller ? model ?
> 
> How do you thing is the better approach ?
> 
> Thanks

---

<div class="post-metadata">

**Author:** ![andersonleite](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/45deac/32.png) [@andersonleite](https://www.ruby-forum.com/u/andersonleite)\
**Post date:** [July 1, 2010, 11:48pm UTC](https://www.ruby-forum.com/t/best-way-to-internationalize-content-from-database/190985/3 "2010-07-01T23:48:57Z")

</div>

Hello Marnen

"keep translated strings in PO files "

but think about a content management system that users put information  
about a new protuct in english and portuguese.

It’s easy to use i18n for labels…but…what about the product  
description ??

I can’t put product description into a PO file…it has to come from a  
database…

---

<div class="post-metadata">

**Author:** ![andersonleite](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/45deac/32.png) [@andersonleite](https://www.ruby-forum.com/u/andersonleite)\
**Post date:** [July 2, 2010, 7:54am UTC](https://www.ruby-forum.com/t/best-way-to-internationalize-content-from-database/190985/4 "2010-07-02T07:54:31Z")

</div>

Anderson L. wrote:

> Hello Marnen
> 
> "keep translated strings in PO files "
> 
> but think about a content management system that users put information  
> about a new protuct in english and portuguese.
> 
> It’s easy to use i18n for labels…but…what about the product  
> description ??
> 
> I can’t put product description into a PO file…it has to come from a  
> database…

Quite true. At that point, it makes sense to have a table with  
product\_id, language\_id, and description fields.

–Â  
Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

Sent from my iPhone

---

<div class="post-metadata">

**Author:** ![andersonleite](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/45deac/32.png) [@andersonleite](https://www.ruby-forum.com/u/andersonleite)\
**Post date:** [July 3, 2010, 12:25pm UTC](https://www.ruby-forum.com/t/best-way-to-internationalize-content-from-database/190985/5 "2010-07-03T12:25:20Z")

</div>

Have you considered this [GitHub - joshmh/globalize2: The second incarnation of Globalize for Rails](http://github.com/joshmh/globalize2) ?
