我被要求设计一个多语言应用程序,我需要建议,这是Rails的最佳方法。
基本上所有表都有一些不需要的常见字段 被翻译和其他需要翻译的人。
谢谢
答案 0 :(得分:6)
为此目的,将接近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:migrate