Module: GetText::RMsgfmt

Extended by:
GetText, RMsgfmt
Included in:
RMsgfmt
Defined in:
lib/gettext/tools/rmsgfmt.rb

Overview

:nodoc:

Constant Summary

Constants included from GetText

BOM_UTF8, MOFile, VERSION

Instance Method Summary collapse

Methods included from GetText

N_, Nn_, bindtextdomain, bindtextdomain_to, cgi, cgi=, create_mofiles, create_mofiles_org, gettext, included, locale, msgmerge, ngettext, npgettext, nsgettext, output_charset, pgettext, remove_bom, rgettext, rmsgfmt, rmsgmerge, set_cgi, set_current_locale, set_locale, set_output_charset, sgettext, textdomain, textdomain_to, update_pofiles, update_pofiles_org

Instance Method Details

#check_optionsObject

:nodoc:



44
45
46
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/rmsgfmt.rb', line 44

def check_options # :nodoc:
  output = nil

  opts = OptionParser.new
  opts.banner = _("Usage: %s input.po [-o output.mo]" % $0)
  opts.separator("")
  opts.separator(_("Generate binary message catalog from textual translation description."))
  opts.separator("")
  opts.separator(_("Specific options:"))

  opts.on("-o", "--output=FILE", _("write output to specified file")) do |out|
    output = out
  end

  opts.on_tail("--version", _("display version information and exit")) do
    puts "#{$0} #{GetText::VERSION}"
    puts "#{File.join(Config::CONFIG["bindir"], Config::CONFIG["RUBY_INSTALL_NAME"])} #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
    exit
  end
  opts.parse!(ARGV)

  if ARGV.size == 0
    puts opts.help
    exit 1
  end

  [ARGV[0], output]
end

#run(targetfile = nil, output_path = nil) ⇒ Object

:nodoc:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/gettext/tools/rmsgfmt.rb', line 26

def run(targetfile = nil, output_path = nil) # :nodoc:
  unless targetfile
  targetfile, output_path = check_options
  end
  unless targetfile
  raise ArgumentError, _("no input files")
  end
  unless output_path
  output_path = "messages.mo"
  end

  parser = PoParser.new
  data = MoFile.new

  parser.parse_file(targetfile, data)
  data.save_to_file(output_path)
end