Search code examples
ruby-on-railsglobalize

Loading translation data under Globalize gem


Rails applications using Globalize gem generate a database table for a givenmodel's translations named givenmodel_translations with each attribute defined in the givenmodel.rb file.

However starting with a pre-existing data where translation data needs to be created in the translations table - say from a CSV file - there is no railsish way of calling the table. note: this model has also image size validations and works with slugs to find objects One cannot call from the console

GivenmodelTranslation.create( :locale => row[0], :title => row[1] [...] )

How can such data be populated?


Solution

  • Globalize creates namespaced translation models:

    Givenmodel::Translation
    

    However I haven't seen it documented so it could change in the next versions.