class GetText::Tools::MsgCat

Public Class Methods

run(*command_line) click to toggle source

(see run)

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

# File lib/gettext/tools/msgcat.rb, line 31
def run(*command_line)
  new.run(*command_line)
end

Public Instance Methods

run(*command_line) click to toggle source

Concatenates po-files.

@param [Array<String>] command_line

The command line arguments for rmsgcat.

@return [void]

# File lib/gettext/tools/msgcat.rb, line 41
def run(*command_line)
  config = Config.new
  config.parse(command_line)

  parser = POParser.new
  parser.report_warning = config.report_warning?
  parser.ignore_fuzzy = !config.include_fuzzy?
  output_po = PO.new
  output_po.order = config.order
  merger = Merger.new(output_po, config)
  config.pos.each do |po_file_name|
    po = PO.new
    parser.parse_file(po_file_name, po)
    merger.merge(po)
  end

  output_po_string = output_po.to_s(config.po_format_options)
  if config.output.is_a?(String)
    File.open(File.expand_path(config.output), "w") do |file|
      file.print(output_po_string)
    end
  else
    puts(output_po_string)
  end
end