Class: GetText::Tools::MsgMerge
- Inherits:
-
Object
- Object
- GetText::Tools::MsgMerge
- Includes:
- GetText
- Defined in:
- lib/gettext/tools/msgmerge.rb,
lib/gettext/tools/poparser.rb
Defined Under Namespace
Classes: Config, Merger, PoData
Constant Summary collapse
Constants included from GetText
BOM_UTF8, MOFile, MoFile, PoParser
Class Method Summary collapse
-
.run(*arguments) ⇒ void
Merge a po-file inluding translated messages and a new pot-file.
Instance Method Summary collapse
-
#check_command_line_options(*options) ⇒ Object
:nodoc:.
-
#parse_arguments(*options) ⇒ Object
:nodoc:.
-
#run(*options) ⇒ Object
:nodoc:.
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, #set_cgi, #set_current_locale, #set_locale, #set_output_charset, #sgettext, #textdomain, #textdomain_to, #update_pofiles, #update_pofiles_org
Class Method Details
.run(*arguments) ⇒ void
This method returns an undefined value.
Merge a po-file inluding translated messages and a new pot-file.
448 449 450 |
# File 'lib/gettext/tools/msgmerge.rb', line 448 def run(*arguments) new.run(*arguments) end |
Instance Method Details
#check_command_line_options(*options) ⇒ Object
:nodoc:
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
# File 'lib/gettext/tools/msgmerge.rb', line 460 def (*) #:nodoc: , output = parse_arguments(*) config = Config.new config.output = output config.defpo = [0] config.refpot = [1] if config.defpo.nil? raise ArgumentError, _("definition po is not given.") elsif config.refpot.nil? raise ArgumentError, _("reference pot is not given.") end config end |
#parse_arguments(*options) ⇒ Object
:nodoc:
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
# File 'lib/gettext/tools/msgmerge.rb', line 477 def parse_arguments(*) #:nodoc: parser = OptionParser.new parser. = _("Usage: %s def.po ref.pot [-o output.pot]") % $0 #parser.summary_width = 80 parser.separator("") description = _("Merges two Uniforum style .po files together. " + "The def.po file is an existing PO file with " + "translations. The ref.pot file is the last " + "created PO file with up-to-date source " + "references. ref.pot is generally created by " + "rgettext.") parser.separator(description) parser.separator("") parser.separator(_("Specific options:")) output = nil parser.on("-o", "--output=FILE", _("write output to specified file")) do |out| output = out end #parser.on("-F", "--fuzzy-matching") parser.on("-h", "--help", _("Display this help and exit")) do puts(parser.help) exit(true) end parser.on_tail("--version", _("display version information and exit")) do puts(VERSION) exit(true) end parser.parse!() [, output] end |
#run(*options) ⇒ Object
:nodoc:
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 |
# File 'lib/gettext/tools/msgmerge.rb', line 516 def run(*) #:nodoc: config = (*) parser = POParser.new parser.ignore_fuzzy = false defpo = parser.parse_file(config.defpo, PO.new) refpot = parser.parse_file(config.refpot, PO.new) merger = Merger.new result = merger.merge(defpo, refpot) p result if $DEBUG print result.generate_po if $DEBUG if config.output.is_a?(String) File.open(File.(config.output), "w+") do |file| file.write(result.to_s) end else puts(result.to_s) end end |