Module: GetText::RMsgfmt

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

Overview

:nodoc:

Constant Summary

Constants included from GetText

BOM_UTF8, VERSION

Class 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, p_, pgettext, remove_bom, rgettext, rmsgfmt, rmsgmerge, set_cgi, set_locale, set_output_charset, sgettext, textdomain, update_pofiles, update_pofiles_org

Class Method Details

.check_optionsObject

:nodoc:



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
66
67
68
# File 'lib/gettext/tools/rmsgfmt.rb', line 41

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:



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

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.open(targetfile).read, data)
  data.save_to_file(output_path)
end