# Display website content in multilanguage

**URL:** <https://www.ruby-forum.com/t/display-website-content-in-multilanguage/144926>\
**Category:** Rails\
**Created:** [August 4, 2008, 1:16pm UTC](https://www.ruby-forum.com/t/display-website-content-in-multilanguage/144926 "2008-08-04T13:16:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ganana\_srishti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e480ec/32.png) [@ganana\_srishti](https://www.ruby-forum.com/u/ganana_srishti)\
**Post date:** [August 4, 2008, 1:16pm UTC](https://www.ruby-forum.com/t/display-website-content-in-multilanguage/144926/1 "2008-08-04T13:16:29Z")

</div>

Hi,  
how to display the website content in multilanguage… for example  
french and english… etc

plz reply if you know any solution …

---

<div class="post-metadata">

**Author:** ![ganana\_srishti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e480ec/32.png) [@ganana\_srishti](https://www.ruby-forum.com/u/ganana_srishti)\
**Post date:** [August 4, 2008, 2:10pm UTC](https://www.ruby-forum.com/t/display-website-content-in-multilanguage/144926/2 "2008-08-04T14:10:57Z")

</div>

There is some new stuff coming out in edge for this, but, in  
production we are using the getText gem. It is great because it dumps  
to industry standard .po files which we send off for translation.

You simply mark all strings like this: \<%= \_(“Hello World”)%\> in your  
views, or just \_(“Hello”) in your code and running the updatepo task  
will find them and dump them to file.

I’ve been doing multilingual sites for a long time and found this tool  
to be one of the best. A lot of people like Globalize, but personally  
I don’t like the idea of storing everything in the database as you  
then have to give your translators access to the db and they have to  
learn a new tool. The translation company we use already use and know  
poEdit.

We are at the point now where we can add a new language to our system  
in just a couple of hours (new translations and a few new images).

On Aug 4, 1:16 pm, “Pragash Mr.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![ganana\_srishti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e480ec/32.png) [@ganana\_srishti](https://www.ruby-forum.com/u/ganana_srishti)\
**Post date:** [August 4, 2008, 4:31pm UTC](https://www.ruby-forum.com/t/display-website-content-in-multilanguage/144926/3 "2008-08-04T16:31:01Z")

</div>

I find this quite interesting, but how would it work with text that’s  
not coming directly from the app, but a database?

You can’t just say \<%= \_(@product.category.name) =\> , right?

---

<div class="post-metadata">

**Author:** ![ganana\_srishti](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e480ec/32.png) [@ganana\_srishti](https://www.ruby-forum.com/u/ganana_srishti)\
**Post date:** [August 5, 2008, 5:44pm UTC](https://www.ruby-forum.com/t/display-website-content-in-multilanguage/144926/4 "2008-08-05T17:44:01Z")

</div>

We treat ‘data’ based translations differently, sorry. Didn’t think  
about that when I wrote the above. We have a general translations  
table that we use for stuff like that and do a lookup on it (caching  
the result).

So something like

class Translation \< ActiveRecord::Base  
def self.translation(str, lang)  
Translation.find\_by\_base\_and\_lang(str,lang)  
end  
end

That is very rough and off the top of my head as I don’t have the code  
in front of me. I keep meaning to write up how we do this on my blog,  
but haven’t yet.  
there are pros and cons to this approach. It really comes down to how  
much you are translating.

On Aug 4, 4:31 pm, Stefan B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
