lib/transync/sync/gdoc_to_xliff.rb in transync-0.1.1 vs lib/transync/sync/gdoc_to_xliff.rb in transync-1.0.0
- old
+ new
@@ -1,16 +1,16 @@
+require_relative 'sync_util'
+
class GdocToXliff
attr_accessor :xliff_translations,
:gdoc_trans_reader,
- :language,
- :logger
+ :language
def initialize(options = {})
self.xliff_translations = options[:xliff_translations]
self.gdoc_trans_reader = options[:gdoc_trans_reader]
self.language = options[:language]
- self.logger = options[:logger]
end
def sync
dirty = false
gdoc_tab_language = gdoc_trans_reader.build_trans_hash(language)
@@ -26,17 +26,15 @@
gdoc_tab_language[:translations].each do |gdoc_trans|
x_trans = xliff_for_language.detect{ |x| x[:key] == gdoc_trans[:key] }
# whole key is missing
if x_trans.nil?
- p "Adding Key: #{gdoc_trans[:key]} to #{file}(#{language}) and value '#{gdoc_trans[:value]}'"
- logger.info "Adding Key: #{gdoc_trans[:key]} to #{file}(#{language}) and value '#{gdoc_trans[:value]}'"
+ SyncUtil.info_diff(file, language, 'Adding', gdoc_trans)
new_xliff_hash[:translations] << gdoc_trans
dirty = true
elsif gdoc_trans[:value] != x_trans[:value]
- p "Changing #{file}(#{language}) #{gdoc_trans[:key]}: '#{x_trans[:value]}' to '#{gdoc_trans[:value]}'"
- logger.info "Changing #{file}(#{language}) #{gdoc_trans[:key]}: '#{x_trans[:value]}' to '#{gdoc_trans[:value]}'"
+ SyncUtil.info_diff(file, language, 'Changing', gdoc_trans)
x_trans[:value] = gdoc_trans[:value]
new_xliff_hash[:translations] << x_trans
dirty = true
else