Class: GetText::Tools::MsgMerge
- Inherits:
-
Object
- Object
- GetText::Tools::MsgMerge
- Includes:
- GetText
- Defined in:
- lib/gettext/tools/msgmerge.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
constant values
GetText::VERSION
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=, #gettext, included, #locale, #ngettext, #npgettext, #nsgettext, #output_charset, #pgettext, #set_cgi, #set_current_locale, #set_locale, #set_output_charset, #sgettext, #textdomain, #textdomain_to
Class Method Details
.run(*arguments) ⇒ void
This method returns an undefined value.
Merge a po-file inluding translated messages and a new pot-file.
229 230 231 |
# File 'lib/gettext/tools/msgmerge.rb', line 229 def run(*arguments) new.run(*arguments) end |
Instance Method Details
#check_command_line_options(*options) ⇒ Object
:nodoc:
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/gettext/tools/msgmerge.rb', line 241 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:
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/gettext/tools/msgmerge.rb', line 258 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:
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/gettext/tools/msgmerge.rb', line 297 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 |