[gettext-u-en] empty output from msgmerge should not be interpreted as error
Yaohan Chen
yaohan.chen at gmail.com
Thu Jun 5 18:13:55 EDT 2008
Hello,
I noticed that if a ruby file has no translatable strings, and a pot file is
created from it, then running update_pofiles again will cause an error with
such output:
po/file.pot
. done.
Failed to merge with po/file.pot
New .pot was copied to tmp.pot~
Check these po/pot-files. It may have syntax errors or something wrong.
The cause of this is that GNU gettext's msgmerge (0.17) seems to never output
anything when the def.po and ref.pot files are identical. But if you supply a
switch -o output.po, the output.po file will be untouched. Also msgmerge
prints ". done." in stderr as usually, without any error message. I think
this suggests that empty output from msgmerge does not indicate an error in
the pot file, only that no change is needed.
Following is my proposed patch.
? msgmerge-empty-output.diff
Index: lib/gettext/utils.rb
===================================================================
RCS file: /var/cvs/gettext/gettext/lib/gettext/utils.rb,v
retrieving revision 1.7
diff -u -r1.7 utils.rb
--- lib/gettext/utils.rb 6 May 2008 17:36:43 -0000 1.7
+++ lib/gettext/utils.rb 5 Jun 2008 22:06:54 -0000
@@ -60,13 +60,14 @@
cont = io.read
end
end
- if cont.empty?
+ unless $?.success?
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 = File.read(defpo) if cont.empty?
cont.sub!(/(Project-Id-Version\:).*$/, "\\1 #{app_version}\\n\"")
File.open(defpo, "w") do |out|
out.write(cont)
More information about the gettext-users-en
mailing list