class GetText::Tools::MsgCat::Config

@private

Attributes

include_fuzzy[W]

(see include_fuzzy?)

order[RW]

@return [:reference, :msgid] The sort key.

output[RW]

@return [String] The output file name.

output_obsolete_entries[W]
po_format_options[RW]

@return [Hash] The PO format options. @see PO#to_s @see POEntry#to_s

pos[RW]

@return [Array<String>] The input PO file names.

remove_header_fields[R]

@return [Array<String>] The field names to be removed from

header entry.
report_warning[W]
update_po_revision_date[W]

Public Class Methods

new() click to toggle source
# File lib/gettext/tools/msgcat.rb, line 198
def initialize
  @pos = []
  @output = nil
  @order = nil
  @po_format_options = {
    :max_line_width => POEntry::Formatter::DEFAULT_MAX_LINE_WIDTH,
  }
  @include_fuzzy = true
  @report_warning = true
  @output_obsolete_entries = true
  @remove_header_fields = []
  @update_po_revision_date = false
end

Public Instance Methods

include_fuzzy?() click to toggle source

@return [Boolean] Whether includes fuzzy entries or not.

# File lib/gettext/tools/msgcat.rb, line 213
def include_fuzzy?
  @include_fuzzy
end
output_obsolete_entries?() click to toggle source

@return [Boolean] Whether outputs obsolete entries or not.

# File lib/gettext/tools/msgcat.rb, line 223
def output_obsolete_entries?
  @output_obsolete_entries
end
parse(command_line) click to toggle source
# File lib/gettext/tools/msgcat.rb, line 233
def parse(command_line)
  parser = create_option_parser
  @pos = parser.parse(command_line)
end
report_warning?() click to toggle source

@return [Boolean] Whether reports warning messages or not.

# File lib/gettext/tools/msgcat.rb, line 218
def report_warning?
  @report_warning
end
update_po_revision_date?() click to toggle source

@return [Boolean] Whether updates PO-Revision-Date header

field or not.
# File lib/gettext/tools/msgcat.rb, line 229
def update_po_revision_date?
  @update_po_revision_date
end

Private Instance Methods

create_option_parser() click to toggle source
# File lib/gettext/tools/msgcat.rb, line 239
def create_option_parser
  parser = OptionParser.new
  parser.version = GetText::VERSION
  parser.banner = _("Usage: %s [OPTIONS] PO_FILE1 PO_FILE2 ...") % $0
  parser.separator("")
  parser.separator(_("Concatenates and merges PO files."))
  parser.separator("")
  parser.separator(_("Specific options:"))

  parser.on("-o", "--output=FILE",
            _("Write output to specified file"),
            _("(default: the standard output)")) do |output|
    @output = output
  end

  parser.on("--sort-by-msgid",
            _("Sort output by msgid")) do
    @order = :msgid
  end

  parser.on("--sort-by-location",
            _("Sort output by location")) do
    @order = :reference
  end

  parser.on("--sort-by-file",
            _("Sort output by location"),
            _("It is same as --sort-by-location"),
            _("Just for GNU gettext's msgcat compatibility")) do
    @order = :reference
  end

  parser.on("--[no-]sort-output",
            _("Sort output by msgid"),
            _("It is same as --sort-by-msgid"),
            _("Just for GNU gettext's msgcat compatibility")) do |sort|
    @order = sort ? :msgid : nil
  end

  parser.on("--no-location",
            _("Remove location information")) do |boolean|
    @po_format_options[:include_reference_comment] = boolean
  end

  parser.on("--no-translator-comment",
            _("Remove translator comment")) do |boolean|
    @po_format_options[:include_translator_comment] = boolean
  end

  parser.on("--no-extracted-comment",
            _("Remove extracted comment")) do |boolean|
    @po_format_options[:include_extracted_comment] = boolean
  end

  parser.on("--no-flag-comment",
            _("Remove flag comment")) do |boolean|
    @po_format_options[:include_flag_comment] = boolean
  end

  parser.on("--no-previous-comment",
            _("Remove previous comment")) do |boolean|
    @po_format_options[:include_previous_comment] = boolean
  end

  parser.on("--no-all-comments",
            _("Remove all comments")) do |boolean|
    @po_format_options[:include_all_comments] = boolean
  end

  parser.on("--width=WIDTH", Integer,
            _("Set output page width"),
            "(#{@po_format_options[:max_line_width]})") do |width|
    @po_format_options[:max_line_width] = width
  end

  parser.on("--[no-]wrap",
            _("Break long message lines, longer than the output page width, into several lines"),
            "(#{@po_format_options[:max_line_width] >= 0})") do |wrap|
    if wrap
      max_line_width = POEntry::Formatter::DEFAULT_MAX_LINE_WIDTH
    else
      max_line_width = -1
    end
    @po_format_options[:max_line_width] = max_line_width
  end

  parser.on("--no-fuzzy",
            _("Ignore fuzzy entries")) do |include_fuzzy|
    @include_fuzzy = include_fuzzy
  end

  parser.on("--no-report-warning",
            _("Don't report warning messages")) do |report_warning|
    @report_warning = report_warning
  end

  parser.on("--no-obsolete-entries",
            _("Don't output obsolete entries")) do
    @output_obsolete_entries = false
  end

  parser.on("--[no-]update-po-revision-date",
            _("Update PO-Revision-Date header field")) do |update|
    @update_po_revision_date = update
  end

  parser.on("--remove-header-field=FIELD",
            _("Remove FIELD from header"),
            _("Specify this option multiple times to remove multiple header fields")) do |field|
    @remove_header_fields << field
  end

  parser
end