Class: Gdoc2XliffMain

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Gdoc2XliffMain

Returns a new instance of Gdoc2XliffMain.



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

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

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



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

def config
  @config
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/transync/sync/gdoc_2_xliff_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
# File 'lib/transync/sync/gdoc_2_xliff_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)

    @config['LANGUAGES'].each do |language|
      options = {
        xliff_translations: xliff_translations,
        gdoc_trans_reader: gdoc_trans_reader,
        language: language
      }

      gdoc_to_xliff = GdocToXliff.new(options)
      dirty, new_xliff_hash = gdoc_to_xliff.sync

      xliff_trans_writer = XliffTransWriter.new(path, file, new_xliff_hash)
      xliff_trans_writer.save if dirty

      SyncUtil.info_clean(file, language, 'was clean. Already has same keys and values inside Xliff') unless dirty
    end
  end
end