Module: I18n::Backend::Weeler::Importer::ClassMethods

Defined in:
lib/i18n/backend/weeler/importer.rb

Instance Method Summary collapse

Instance Method Details

#import(file) ⇒ Object

Loads file and iterates each sheet and row.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/i18n/backend/weeler/importer.rb', line 25

def import(file)
  xls = open_spreadsheet(file)

  first_row = xls.first
  locales = locales_from_xlsx_sheet_row(first_row)
  tranlsations_by_locales = Translation.where(locale: locales).group_by(&:locale)

  xls.each_with_index do |row, index|
    next if index.zero?

    store_translations_from_xlsx_row(tranlsations_by_locales, row, locales)
  end
end