Sha256: c752f9e45dacee505e12846c70f5473d78dc487d3396304ffeb88a18532d9ea6

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

# LolitaTranslations


### Install

    gem "lolita"
    gem "lolita-translation"

### Usage
    
1. Call `translations :title, :body` in your model and pass column names to translate.
2. Add `tab :translation` into `lolita do ....` block to see the translation tab.
3. Add `Article.sync_translation_table!` to your `db/seeds.rb` and run it.

### Examples

Translations table holds only translations, but not the original data from default_locale, so:

    I18n.default_locale = :en
    I18n.locale = :lv
    
    a = Article.create :title => "Title in EN"
    a.title # returns blank, because current locale is LV and there is no translation in it
    #=> ""
    I18n.locale = :en
    a.title
    #=> "Title in EN"
    a.translations.create :title => "Title in LV", :locale => 'lv'
    I18n.locale = :lv
    a.title 
    #=> "Title in LV"

When a "find" is executed and current language is not the same as default language then `:translations` are added to `:includes` to pre fetch all translations.

The `ModelNameTranslation` class is created for you automaticly with all validations for ranslated fields. Of course you can create it manualy for custom vlidations and other.


### Credits

Inspired by http://github.com/dmitry/has_translations

### License 

Copyright © 2011 ITHouse. See LICENSE.txt for further details.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lolita-translation-0.0.4 README.md