Guest User

Untitled

a guest
Jan 23rd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. """A management command for extracting translation messages for the whole project."""
  2.  
  3. import glob
  4. import os
  5.  
  6. from django.conf import settings
  7. from django.core.management.base import NoArgsCommand
  8.  
  9.  
  10. class Command(NoArgsCommand):
  11. help = "Make and compile all translation messages for the whole project."
  12.  
  13. def handle_noargs(self, **options):
  14. root = settings.PROJECT_ROOT
  15. manage_py = os.path.join(root, "manage.py")
  16. makemessages = "%s makemessages -v0 --all --extension='.txt,.html,.json'" % manage_py
  17. compilemessages = "%s compilemessages" % manage_py
  18. # top level messages
  19. self.run(makemessages + " --ignore='apps/*'")
  20. self.run(compilemessages)
  21. # application-specific messages
  22. for app_dir in glob.glob(os.path.join(root, "apps", "*")):
  23. if os.path.isdir(os.path.join(app_dir, "locale")):
  24. os.chdir(app_dir)
  25. self.run(makemessages)
  26. self.run(compilemessages)
  27.  
  28. def run(self, cmd):
  29. print cmd
  30. os.system(cmd)
Add Comment
Please, Sign In to add comment