Module: GetText::RMsgfmt

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

Overview

:nodoc:

Constant Summary collapse

VERSION =
GetText::VERSION
DATE =

:nodoc:

%w($Date: 2008/07/26 06:59:34 $)[1]

Constants included from GetText

CACHE_BOUND_TARGET_MAX_SIZE

Class Method Summary collapse

Methods included from GetText

N_, Nn_, _, add_default_locale_path, bindtextdomain, bindtextdomain_to, bound_target, bound_targets, cached=, cached?, cgi, cgi=, clear_cache, create_mofiles, current_textdomain_info, each_textdomain, find_targets, gettext, included, locale, locale=, msgmerge, msgmerge_all, n_, ngettext, npgettext, ns_, nsgettext, output_charset, output_charset=, p_, pgettext, remove_all_textdomains, rgettext, rmsgfmt, rmsgmerge, s_, set_cgi, set_locale, set_locale_all, set_output_charset, setlocale, sgettext, textdomain, textdomain_to, update_pofiles

Class Method Details

.check_optionsObject

:nodoc:



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
69
70
# File 'lib/gettext/rmsgfmt.rb', line 43

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} #{VERSION} (#{DATE})"
	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
# File 'lib/gettext/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.open(targetfile).read, data)
  data.save_to_file(output_path)
end