def msgmerge(defpo, refpo, app_version)
$stderr.print defpo + " "
cmd = ENV["MSGMERGE_PATH"] || "msgmerge"
cont = ""
if FileTest.exist? defpo
`#{cmd} --help`
unless $? && $?.success?
raise _("`%{cmd}' may not be found. \nInstall GNU Gettext then set PATH or MSGMERGE_PATH correctly.") % {:cmd => cmd}
end
remove_bom(defpo)
cont = `#{cmd} #{defpo} #{refpo}`
else
File.open(refpo) do |io|
cont = io.read
end
end
if cont.empty?
failed_filename = refpo + "~"
FileUtils.cp(refpo, failed_filename)
$stderr.puts _("Failed to merge with %{defpo}") % {:defpo => defpo}
$stderr.puts _("New .pot was copied to %{failed_filename}") %{:failed_filename => failed_filename}
raise _("Check these po/pot-files. It may have syntax errors or something wrong.")
else
cont.sub!(/(Project-Id-Version\:).*$/, "\\1 #{app_version}\\n\"")
File.open(defpo, "w") do |out|
out.write(cont)
end
end
self
end