Created
November 7, 2012 16:56
-
-
Save exallium/4032942 to your computer and use it in GitHub Desktop.
Smart makemessages wrapper to account for gettext statements in CoffeeScript files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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