views:

135

answers:

2

Hi, Is there any possibility to extract globalize2 translation for specified locale without setting

I18n.locale = :ru 

as i know - i can extract ALL translations using

model.translations

but maybe there are simplest way to extract only for one language?

+1  A: 

Suppose that your table is called mytable: Create a Model for the mytable_translations table and use something like

MyTableTranslations.find(:all, :conditions => {:locale => :ru } )

and, like any other query, all records with the ru locate are returned.

Veger
+1  A: 

There's actually a pretty simple plugin that will do this for you: http://github.com/tomash/easy_globalize2_accessors

 class Product
    translates :title, :description
    globalize_accessors :pl, :en, :de
  end

will automatically give you accessors like:

product.title_en # => "English title"
product.title_de # => "German title"
Kyle Fox