Class: GetText::Tools::MsgCat

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run(*command_line) ⇒ void

This method returns an undefined value.

Concatenates po-files.

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

Parameters:

  • command_line (Array<String>)

    The command line arguments for rmsgcat.



31
32
33
# File 'lib/gettext/tools/msgcat.rb', line 31

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

Instance Method Details

#run(*command_line) ⇒ void

This method returns an undefined value.

Concatenates po-files.

Parameters:

  • command_line (Array<String>)

    The command line arguments for rmsgcat.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# 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