lib/transync/sync/sync_util.rb in transync-0.1.1 vs lib/transync/sync/sync_util.rb in transync-1.0.0
- old
+ new
@@ -1,5 +1,6 @@
+require 'logger'
require_relative '../xliff_trans/xliff_trans_reader'
module SyncUtil
def self.check_and_get_xliff_files(languages, path, file, create = false)
@@ -17,8 +18,28 @@
end
p 'Missing translations were added!' if create and added
xliff_translations
+ end
+
+ def self.info_clean(file, language, message)
+ msg = "#{file} (#{language}) - #{message}"
+ SyncUtil.log_and_puts(msg)
+ end
+
+ def self.info_diff(file, language, operation, trans)
+ msg = "#{file} (#{language}) - #{operation}: '#{trans[:key]}' => '#{trans[:value]}'"
+ SyncUtil.log_and_puts(msg)
+ end
+
+ def self.log_and_puts(msg)
+ p msg
+ @logger.info msg
+ end
+
+ def self.create_logger(direction)
+ # gdoc2xliff or xliff2gdoc
+ @logger = Logger.new(".transync_log/#{direction}.log", 'monthly')
end
end