Skip to content

Instantly share code, notes, and snippets.

@exallium
Created November 7, 2012 16:56
Show Gist options
  • Save exallium/4032942 to your computer and use it in GitHub Desktop.
Save exallium/4032942 to your computer and use it in GitHub Desktop.
Smart makemessages wrapper to account for gettext statements in CoffeeScript files.
from fabric.api import lcd, local
from importlib import import_module
import sys
def makemessages(settings_module='settings'):
"""
Generates the *.po files for everything.
MAKE SURE YOU RUN collectstatic _BEFORE_ BUILDING THE PO FILES.
:params
settings_module -- settings module name relative to the project's
root directory, being where manage.py lives. Defaults, of course,
to settings.
"""
project_dir = local(
'find . -iname \'manage.py\' | sed \'s/\/manage\.py//g\'',
capture=True
)
sys.path.append(project_dir)
settings_module = import_module(settings_module)
static_root = getattr(settings_module, 'STATIC_ROOT', 'static')
with lcd(project_dir):
local('django-admin.py makemessages -l fr')
local('coffee -c %s/js/*.coffee' % static_root)
local('django-admin.py makemessages -l fr --domain=djangojs')
local("rm `find %s/js/*.coffee -iname '*.coffee' | sed 's/coffee$/js/g'`" % static_root)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment