Skip to content

Instantly share code, notes, and snippets.

@whalesalad
Created August 6, 2013 17:01
Show Gist options
  • Save whalesalad/6166393 to your computer and use it in GitHub Desktop.
Save whalesalad/6166393 to your computer and use it in GitHub Desktop.
Quick and dirty Rakefile for a Wordpress project I maintain. Automates the conversion of .po files to .mo files. In this example, it uses all the .po files in the ./lang directory. Also note that I installed gettext via homebrew so the msgfmt binary is not on my path. Rather than muck with my path and risk screwing up OS X's built-in gettext stu…
MSGFMT = "/usr/local/Cellar/gettext/0.18.2/bin/msgfmt"
task :export_mo do |t|
po_files = Dir.glob(File.dirname(__FILE__) + '/lang/*.po')
po_files.each do |po|
mo = po.gsub(/.po\Z/, '.mo')
sh "#{MSGFMT} -o '#{mo}' '#{po}'"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment