我正在使用 Globalize2。我想用 db:seed 为不同的语言环境填充数据库:en、de 和 ru。那么有没有更好的解决方案:
categories = [{ :en => 'Health & Beauty', :ru => 'Красота и здоровье', :de => 'Beauty & Gesundheit'},
{ :en => 'Baby', :ru => 'Детские товары', :de => 'Baby' }]
categories.each_index do |i|
I18n.locale = 'en'
Category.create(:name => categories[i][:en])
I18n.locale = 'ru'
cat = Category.find(:last)
cat.name = categories[i][:ru]
cat.save
I18n.locale = 'de'
cat.name = categories[i][:de]
cat.save
end
?