]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
add wrapper for msgmerge to workaround gettext bug with "empty" pot files
authorYaohan Chen <yaohan.chen@gmail.com>
Sat, 7 Jun 2008 19:48:53 +0000 (15:48 -0400)
committerYaohan Chen <yaohan.chen@gmail.com>
Sat, 7 Jun 2008 19:50:45 +0000 (15:50 -0400)
Rakefile
bin/msgmerge-wrapper.rb [new file with mode: 0755]

index b44ca95f4bc626e970eb9bc8ac3f497d77d2dcb7..c1bc780e6b7ff44ad409fb9ed3836fdf4bb3c72a 100644 (file)
--- a/Rakefile
+++ b/Rakefile
@@ -37,6 +37,12 @@ end
 
 desc "Update pot/po files."
 task :updatepo do
+  # ruby-gettext treats empty output from msgmerge as error, causing this task to
+  # fail. we provide a wrapper to work around it. see bin/msgmerge-wrapper.rb for
+  # details
+  ENV['REAL_MSGMERGE_PATH'] = ENV['MSGMERGE_PATH']
+  ENV['MSGMERGE_PATH'] = 'bin/msgmerge-wrapper.rb'
+
   require 'gettext/utils'
   plugin_files = Dir.glob('data/rbot/plugins/**/*.rb')
   # all except plugin files use the rbot textdomain
diff --git a/bin/msgmerge-wrapper.rb b/bin/msgmerge-wrapper.rb
new file mode 100755 (executable)
index 0000000..975107e
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/ruby
+# This is a wrapper to msgmerge, it executes msgmerge with the given arguments, and
+# if msgmerge output is empty, prints the content of the file named the first
+# argument. otherwise it prints the output of msgmerge. The wrapper should be
+# "compatible" with the real msgmerge if msgmerge output is non-empty, or if the
+# first argument is the defpo file (instead of an option, or --)
+#
+# The path to msgmerge can be specified in env variable REAL_MSGMERGE_PATH
+#
+# The purpose is to provide a workaround for ruby-gettext, which treats empty output
+# from msgmerge as error in the po file, where it should mean that no modification
+# is needed to the defpo. For updates on the issue follow
+# http://rubyforge.org/pipermail/gettext-users-en/2008-June/000094.html 
+
+
+msgmerge = ENV['REAL_MSGMERGE_PATH'] || 'msgmerge'
+defpo = ARGV.shift
+output = `#{msgmerge} #{defpo} #{ARGV.join ' '}`
+output = File.read(defpo) if output.empty?
+STDOUT.write output
+