def handle(self, *args, **options):
        self.options = options

        # go through each dmp_enabled app and compile its mako templates
        for app_config in get_dmp_apps():
            self.compile_mako_files(app_config)

        # add any extra xgettext_options (the regular makemessages doesn't do this, and I need to include other aliases like _(), _z(), etc.
        for opt in options.get('extra_gettext_option', []):
           self.xgettext_options.append(opt)

        # call the superclass command
        return MakeMessagesCommand.handle(self, *args, **options)
示例#2
0
文件: env.py 项目: BeryJu/supervisr
def makemessages(ctx, locale='en'):
    """Create .po files for every supervisr app"""
    setup()
    from django.core.management.commands.makemessages import Command
    from supervisr.core.utils import get_apps, LogOutputWrapper
    # Returns list of app starting with supervisr
    for app in get_apps(exclude=[]):
        # Get apps.py file from class
        app_file = inspect.getfile(app.__class__)
        # Get app basedir and change to it
        app_basedir = os.path.dirname(app_file)
        os.chdir(app_basedir)
        # Create locale dir in case it doesnt exist
        os.makedirs('locale', exist_ok=True)
        LOGGER.info("Building %s", app.__class__.__name__)
        builder = Command(stdout=LogOutputWrapper())
        builder.handle(
            verbosity=1,
            settings=None,
            pythonpath=None,
            traceback=None,
            no_color=False,
            locale=locale.split(','),
            exclude=[],
            domain='django',
            all=False,
            extensions=None,
            symlinks=False,
            ignore_patterns=[],
            use_default_ignore_patterns=True,
            no_wrap=False,
            no_location=False,
            add_location=None,
            no_obsolete=False,
            keep_pot=False,
        )
示例#3
0
    def handle(self, *args, **options):
        dmp = apps.get_app_config('django_mako_plus')
        self.options = options
        if self.options.get('template_dir', []):
            self.SEARCH_DIRS = []
            for subdir in self.options.get('template_dir', []):
                self.SEARCH_DIRS.append(os.path.join('{app_path}', subdir))

        # go through each dmp_enabled app and compile its mako templates
        for app_config in dmp.get_registered_apps():
            self.compile_mako_files(app_config)

        # add any extra xgettext_options (the regular makemessages doesn't do this, and I need to include other aliases like _(), _z(), etc.
        for opt in options.get('extra_gettext_option', []):
           self.xgettext_options.append(opt)

        # call the superclass command
        return MakeMessagesCommand.handle(self, *args, **options)