
from django.core.management import call_command
from django.core.management.base import BaseCommand
from django.conf import settings


class Command(BaseCommand):
    help = "Run `makemessages` and `makemessagesios` commands."

    def handle(self, *args, **options):
        self.stdout.write("Launch translation of %s languages." % len(settings.LANGUAGES))
        self.stdout.write("%s" % str(settings.LANGUAGES))
        for code, __ in settings.LANGUAGES:
            self.stdout.write("Run translation for %s language ..." % code)
            call_command('makemessages', locale=[code], extension=['py', 'html', 'rml'])
            self.stdout.write("Run iOS translation for %s language ..." % code)
            call_command('makemessagesios', code)
