2010-01-20 116 views

回答

1

其实有一个非常简单的插件会为你做到这一点: http://github.com/tomash/easy_globalize2_accessors

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

会自动给你访问器,如:

product.title_en # => "English title" 
product.title_de # => "German title" 
1

假设你的表称为MYTABLE:创建 mytable_translations表模型和使用类似

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

,就像任何其他查询,与汝中的所有记录查找返回。