Module: Transync::Runner

Defined in:
lib/transync/runner.rb

Overview

2713 = unicode check mark 2717 = unicode cross mark

Constant Summary collapse

PATH =
TransyncConfig::CONFIG['XLIFF_FILES_PATH']

Class Method Summary collapse

Class Method Details

.initObject



16
17
18
19
# File 'lib/transync/runner.rb', line 16

def self.init
  init = Init.new(PATH)
  init.run
end

.sync(mode) ⇒ Object



11
12
13
14
# File 'lib/transync/runner.rb', line 11

def self.sync(mode)
  sync = TranslationSync.new(PATH, mode)
  sync.run(mode)
end

.testObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/transync/runner.rb', line 21

def self.test
  TransyncConfig::CONFIG['FILES'].each do |file|
    xliff_files = XliffTransReader.new(PATH, file, TransyncConfig::CONFIG['LANGUAGES'])
    puts "\u{2713} '#{file}' have all the keys for all languages in XLIFF files.".colorize(:green) if xliff_files.valid?

    TransyncConfig::CONFIG['LANGUAGES'].each do |language|
      trans_sync = TranslationSync.new(PATH, 'test', file)

      if trans_sync.diff(language).keys.length == 0
        puts "\u{2713} '#{file}.#{language}' XLIFF is in sync with GDoc.".colorize(:green)
      else
        puts "\u{2717} '#{file}.#{language}' XLIFF is NOT in sync with GDoc. See diff!".colorize(:red)
      end
    end

    puts '----------'
  end
end

.updateObject



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/transync/runner.rb', line 40

def self.update
  TransyncConfig::CONFIG['FILES'].each do |file|
    xliff_files = XliffTransReader.new(PATH, file, TransyncConfig::CONFIG['LANGUAGES'])
    clean = xliff_files.fill_with_missing_keys

    if clean
      puts "\u{2713} '#{file}' already have all the keys in all the XLIFF files".colorize(:green)
    else
      puts "\u{2717} '#{file}' already DID NOT have all the keys in all the XLIFF files. But they were added automatically for you.".colorize(:red)
    end
  end
end