Module: Transync

Defined in:
lib/transync.rb,
lib/transync/version.rb

Constant Summary collapse

VERSION =
'1.0.3'

Class Method Summary collapse

Class Method Details

.run(mode, test = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/transync.rb', line 7

def self.run(mode, test = nil)
  FileUtils.mkdir('.transync_log') unless Dir.exist?('.transync_log')
  path = TransyncConfig::CONFIG['XLIFF_FILES_PATH']

  if mode == 'x2g' or mode == 'g2x'
    sync = TranslationSync.new(path, mode)
    sync.run(mode, test)
  end

  if mode == 'init'
    init = Init.new(path)
    init.run
  end

  if mode == 'test'
    TransyncConfig::CONFIG['FILES'].each do |file|
      xliff_files = XliffTransReader.new(path, file, TransyncConfig::CONFIG['LANGUAGES'])
      p 'All translation have all keys, great!' if xliff_files.valid?
    end
  end

  if mode == 'update'
    TransyncConfig::CONFIG['FILES'].each do |file|
      xliff_files = XliffTransReader.new(path, file, TransyncConfig::CONFIG['LANGUAGES'])
      xliff_files.fill_with_missing_keys
    end
  end
end