Class: GetText::Tools::MsgMerge

Inherits:
Object
  • Object
show all
Defined in:
lib/gettext/tools/msgmerge.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run(*command_line) ⇒ void

This method returns an undefined value.

Merge a po-file inluding translated messages and a new pot-file.

This method is provided just for convenience. It equals to new.run(*command_line).

Parameters:

  • command_line (Array<String>)

    command line arguments for rmsgmerge.



37
38
39
# File 'lib/gettext/tools/msgmerge.rb', line 37

def run(*command_line)
  new.run(*command_line)
end

Instance Method Details

#run(*command_line) ⇒ void

This method returns an undefined value.

Merge a po-file inluding translated messages and a new pot-file.

Parameters:

  • command_line (Array<String>)

    command line arguments for rmsgmerge.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/gettext/tools/msgmerge.rb', line 47

def run(*command_line)
  config = Config.new
  config.parse(command_line)

  parser = POParser.new
  parser.ignore_fuzzy = false
  definition_po = PO.new
  reference_pot = PO.new
  parser.parse_file(config.definition_po, definition_po)
  parser.parse_file(config.reference_pot, reference_pot)

  merger = Merger.new(reference_pot, definition_po, config)
  result = merger.merge
  result.order = config.order
  p result if $DEBUG
  print result.generate_po if $DEBUG

  if config.output.is_a?(String)
    File.open(File.expand_path(config.output), "w+") do |file|
      file.write(result.to_s(config.po_format_options))
    end
  else
    puts(result.to_s(config.po_format_options))
  end
end