Sha256: 557e5bdfedd2700b79e19a1bf8e2158ffbca16087fda4e5c315c98c837b4970e

Contents?: true

Size: 1.82 KB

Versions: 2

Compression:

Stored size: 1.82 KB

Contents

h1. I18n::Backend::InlineForms

This repository contains the I18n InlineForms backend and support code that has been extracted from the "I18n":http://github.com/svenfuchs/i18n.

h2. Installation

For Bundler put the following in your Gemfile:

<pre>
  gem 'i18n-inline_forms'
</pre>

Next create a active record model named @Translation@ with the Rails Generator.
Your migration should look like this:

<pre>
  class CreateTranslations < InlineForms::Migration
    def self.up
      create_table :translations do |t|
        t.string :locale
        t.string :key
        t.text   :value
        t.text   :interpolations
        t.boolean :is_proc, :default => false

        t.timestamps
      end
    end

    def self.down
      drop_table :translations
    end
  end
</pre>

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

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

A simple configuration for your locale.rb could look like this:

<pre>
  require 'i18n/backend/inline_forms'
  I18n.backend = I18n::Backend::InlineForms.new
</pre>

A more adavanced example (Thanks Moritz), which uses YAML files and InlineForms for lookups:

<pre>
  require 'i18n/backend/inline_forms'
  I18n.backend = I18n::Backend::InlineForms.new

  I18n::Backend::InlineForms.send(:include, I18n::Backend::Memoize)
  I18n::Backend::InlineForms.send(:include, I18n::Backend::Flatten)
  I18n::Backend::Simple.send(:include, I18n::Backend::Memoize)
  I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)

  I18n.backend = I18n::Backend::Chain.new(I18n::Backend::Simple.new, I18n.backend)
</pre>

h2. Usage

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

h2. Maintainers

* Sven Fuchs


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
i18n-inline_forms-0.2 README.textile
i18n-inline_forms-0.1 README.textile