我被要求设计一个多语言应用程序,我需要一些建议,哪种方法是使用Rails的最佳方法。
基本上,所有的表都有一些不需要翻译的公共字段,还有一些需要翻译的字段。
谢谢
发布于 2011-09-19 04:39:50
为此,将接近gem globalize3。易于使用。
在您的gemfile中:
gem 'globalize'型号:
class Article < ActiveRecord::Base
translates :title, :text
end和迁移:
class CreateArticles < ActiveRecord::Migration
def up
create_table :articles do |t|
t.timestamps
end
Article.create_translation_table! :title => :string, :text => :text
end
def down
drop_table :articles
Article.drop_translation_table!
end
end然后运行
rake db:migratehttps://stackoverflow.com/questions/7464030
复制相似问题