Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """A management command for extracting translation messages for the whole project."""
- import glob
- import os
- from django.conf import settings
- from django.core.management.base import NoArgsCommand
- class Command(NoArgsCommand):
- help = "Make and compile all translation messages for the whole project."
- def handle_noargs(self, **options):
- root = settings.PROJECT_ROOT
- manage_py = os.path.join(root, "manage.py")
- makemessages = "%s makemessages -v0 --all --extension='.txt,.html,.json'" % manage_py
- compilemessages = "%s compilemessages" % manage_py
- # top level messages
- self.run(makemessages + " --ignore='apps/*'")
- self.run(compilemessages)
- # application-specific messages
- for app_dir in glob.glob(os.path.join(root, "apps", "*")):
- if os.path.isdir(os.path.join(app_dir, "locale")):
- os.chdir(app_dir)
- self.run(makemessages)
- self.run(compilemessages)
- def run(self, cmd):
- print cmd
- os.system(cmd)
Add Comment
Please, Sign In to add comment