Skip to content

Instantly share code, notes, and snippets.

@dorey
Created August 10, 2011 21:31
Show Gist options
  • Save dorey/1138338 to your computer and use it in GitHub Desktop.
Save dorey/1138338 to your computer and use it in GitHub Desktop.
uses python-gettext to compile the binary of translation files instead of the shell "msgfmt" script
# after pip installing python-gettext
# these lines go in django.core.management.commands.compilemessages
# they replace the call to "os.system"
from pythongettext import msgfmt
po = msgfmt.Msgfmt(pf + '.po')
moo_file = pf + '.mo'
with open(moo_file, 'w') as f:
f.write(po.get())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment