Class: Xliff2GdocMain

Inherits:
Object
  • Object
show all
Defined in:
lib/transync/sync/xliff_2_gdoc_main.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Xliff2GdocMain

Returns a new instance of Xliff2GdocMain.



10
11
12
13
14
# File 'lib/transync/sync/xliff_2_gdoc_main.rb', line 10

def initialize(path)
  @path = path
  @config = GdocTrans::CONFIG
  SyncUtil.create_logger('xliff2gdoc')
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/transync/sync/xliff_2_gdoc_main.rb', line 8

def config
  @config
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/transync/sync/xliff_2_gdoc_main.rb', line 8

def path
  @path
end

Instance Method Details

#runObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/transync/sync/xliff_2_gdoc_main.rb', line 16

def run
  @config['FILES'].each do |file|
    xliff_translations = SyncUtil::check_and_get_xliff_files(@config['LANGUAGES'], path, file)

    gdoc_trans_reader = GdocTransReader.new(@config['GDOC'], file)
    gdoc_trans_writer = GdocTransWriter.new(gdoc_trans_reader.worksheet)

    @config['LANGUAGES'].each do |language|
      options = {
        xliff_translations: xliff_translations,
        gdoc_trans_reader: gdoc_trans_reader,
        gdoc_trans_writer: gdoc_trans_writer,
        language: language,
        languages: @config['LANGUAGES']
      }
      xliff_to_gdoc = XliffToGdoc.new(options)
      dirty = xliff_to_gdoc.sync

      # save it back on google drive
      gdoc_trans_writer.worksheet.save if dirty
      SyncUtil.info_clean(file, language, 'was clean. Already has same keys and values inside GDoc') unless dirty
    end
  end
end