views:

425

answers:

3

Hello,

I was searching for a plugin/gem solution to extend the native rails i18n for storing my translations into my database. Maybe I used the wrong search terms, but all I found was the information, that changing the backend IS actually possible and this blog entry which descripes how to write my own backend.

It's hard to imagine, that all those rails apps out there having their translations stored in yml-files or every developer wrote own backends!

Do you know working solutions for this? Storing multiline texts in yml really gets me down! ;)

Thanks and greets,

Joe

A: 

You might want to try http://github.com/joshmh/globalize2/tree/master

Aram Verstegen
Hello Aram,okay, globalize makes it easy to translate model related content, but what about all the static content like imprint, about, e-mail content etc?
Joe
I imagine you would have to write your own backend then. What exactly are you trying to do?
Aram Verstegen
My current project has to handle with a lot of description texts - but because it'll get more dynamic in future we decided to use rails from the beginning. Now our yml-files have more than 1000 lines! Perhaps I'll create a model and store serialized key-value pairs in it. Not beautiful at all, but a compromise..
Joe
+3  A: 

I finally found what I was looking for with the help of Sven Fuchs:

http://github.com/dylanz/i18n_backend_database/tree/master

This quite awesome plugin by Dylan Stamat does exactly what the name indicates and additionally handles the caching!

Sven also mentioned, that the current branch of i18n/active_record provides an ActiveRecord backend as well:

[http://github.com/svenfuchs/i18n/blob/active_record/lib/i18n/backend/active_record.rb][2]

Some discussion about this topic is going on in the goolge i18n user group:

http://groups.google.com/group/rails-i18n/browse_thread/thread/6b7ba3c401890a7e

Issue solved, thanks to Mr I18n Sven Fuchs! ;)

P.S.: ooohps, just one link for unlucky new users. Sorry folks, copy and paste is your friend! ;)

Joe
Nice! Good to hear you have a nice solution. Thanks for sharing, too.
Aram Verstegen
A: 

We had a good experience with fast_gettext

it has a DB-backed backend that comes with a controller to do the translations over the web. The caching is built-in, though we had to code pre-loading of all of the translations on boot (it is much faster then get them one-by-one with caching).

Vitaly Kushner
Thanks Vitaly, I'll give it a try!
Joe