- 
      
- 
        Save paltman/1184967 to your computer and use it in GitHub Desktop. 
    translate
  
        
  
    
      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
    
  
  
    
  | """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) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment