Skip to content
Browse files

add wrapper for msgmerge to workaround gettext bug with "empty" pot f…

  • Loading branch information...
1 parent caffbfa commit dd64d68b79cc41d3457c4abb6e2ec998b9721df8 @hagabaka hagabaka committed
Showing with 27 additions and 0 deletions.
  1. +6 −0 Rakefile
  2. +21 −0 bin/msgmerge-wrapper.rb
6 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['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
21 bin/msgmerge-wrapper.rb
@@ -0,0 +1,21 @@
+# 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
+msgmerge = ENV['REAL_MSGMERGE_PATH'] || 'msgmerge'
+defpo = ARGV.shift
+output = `#{msgmerge} #{defpo} #{ARGV.join ' '}`
+output = if output.empty?
+STDOUT.write output

0 comments on commit dd64d68

Please sign in to comment.
Something went wrong with that request. Please try again.