makemessages doesn't say anything if you forget to specify a locale

Hi!

I’ve just been pulling my hair out trying to figure out why makemessages wasn’t working for me. Turns out I was forgetting the -l flag to specify a locale.

You have to pass either --all, -a for all locales, --locale LOCALE, -l LOCALE for a specific locale, or --exclude EXCLUDE, -x EXCLUDE to exclude a specific locale.

Shouldn’t this command fail in some way if none of the these flags are passed? I’d be happy to try and contribute something if this sounds like a good idea.

The exact command I was running (on Django 2.2.10) was:

django-admin makemessages -d djangojs -i project/static -i node_modules -i dist -i docs

So I wasn’t passing any locale flags, but the command doesn’t output anything pointing out this mistake.

Unless anyone else pipes up with a reason why, then I agree with you - it seems foolish to have a silent error if you run it without any locales specified.

It seems this is implemented already:

I’ll keep looking into it.

The problems seems to be that locale is None evaluates to False, since its default value is [].

Changing line 332 to

if (not locale and not exclude and not process_all) or self.domain is None:

Should fix this. I’ll check the contributing docs to see how I should go about submitting a PR.

Yup, that seems like it could definitely be the issue!

That was it. I’ve written a fix in my own fork, with a passing test. Does this need to be reported as a bug before creating a PR?

You can make the bug and PR at the same time - just ensure they mention each other/link across so the Fellows know how to triage appropriately.

Done. Thanks for the help!