Search code examples
ruby-on-railsinternationalizationglobalize2

how does globalize3 actually work?


Well, I am in the process of internationalising my current project to english and chinese. Works flawless so far for static content with the i18n gem.

Now I installed globalize3 to translate my products, or, to be more precise, to allow the end-user (shop manager) to translate the products while they are created.

Unfortunately the documentation is a little short for globalize3, so I dont really know how to go about it.

I have now

class Product < ActiveRecord::Base
   translates :title, :subtitle, :description, :fallbacks_for_empty_translations => true
   #...
end

and I created the product_translations table through a migration.

I played around in the console a bit, cause I thought I can now do something like:

prods = Product.all
p = prods.first
p.title # works
p.title_en # doesn't work

I know it is going to switch by I18n.locale, but the question is how do I add the translations now to the product_translations table. I would like to do it in the same form when creating a new product or editing. Any hints? Thx...


Solution

  • Solved it by using batch_translations