Simple Translated Storage of ActiveRecord Columns

There are several solutions for storing translations, but most of them involve additional migrations for each  translated column. A more as-you-go solution offers translated_attributes Rails Plugin

  • stores all translations into one ‘translations’ table
  • AR-like interface (validations/update_attributes etc works)
  • performance (only one request to translations table for any amount of translated columns)
class User < ActiveRecord::Base
  translated_attributes :name, :about, :description
end

User.new.name = 'Myself' #stores name_in_#{I18n.locale}
User.new.name_in_de = "Ich"
...

Have a look and tell me your opinion!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s