/i18n-active_record

I18n ActiveRecord backend

Primary LanguageRubyMIT LicenseMIT

I18n::Backend::ActiveRecord

This repository contains the I18n ActiveRecord backend and support code that has been extracted from the I18n.

Installation

For Bundler put the following in your Gemfile:

  gem 'tolk' # as requirement
  gem 'i18n-active_record',
      :git => 'git://github.com/chytreg/i18n-active_record.git',
      :require => 'i18n/active_record'

With this translation model you will be able to manage your translation, and add new translations or languages through
it.

To load I18n::Backend::ActiveRecord into your Rails application, create a new file in config/initializers named locale.rb.

A configuration with cache support for your locale.rb could look like this:

  I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Cache)
  I18n.cache_store = ActiveSupport::Cache.lookup_store(:dalli_store, { :namespace => "project-i18n-#{Rails.env}", :expires_in => 1.month, :compress => true })
  I18n.backend = I18n::Backend::Chain.new(I18n::Backend::ActiveRecord.new, I18n.backend)

Usage

You can now use I18n.t('Your String') to lookup translations in the database.

Maintainers

  • Sven Fuchs