Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#17181 closed New feature (fixed)

Allow for specifying multiple locales and domains for makemessages and compilemessages commands

Reported by: Amin Mirzaee Owned by: Craig Blaszczyk
Component: Internationalization Version: 1.3
Severity: Normal Keywords: i18n makemessages compilemessages
Cc: aminland@…, Craig Blaszczyk Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

It is pretty annoying to have to run the commands separately for each language/domain combo without having to do all of them. Lets say only german, spanish, french, and italian have been changed. Your current choices are to run makemessages 8 times (4 each for django and djangojs domains), or to run it for all languages (which in the case of a large project like django itself, will take much much longer).

This patch allows you to specify multiple languages and/or domains when doing translation.

The old way:

django-admin.py makemessages -d django -l de
django-admin.py makemessages -d django -l fr
django-admin.py makemessages -d django -l es
django-admin.py makemessages -d django -l it
django-admin.py makemessages -d djangojs -l de
django-admin.py makemessages -d djangojs -l fr
django-admin.py makemessages -d djangojs -l es
django-admin.py makemessages -d djangojs -l it
django-admin.py compilemessages -l de
django-admin.py compilemessages -l fr
django-admin.py compilemessages -l es
django-admin.py compilemessages -l it

With this patch:

django-admin.py makemessages -d django -d djangojs -l de -l fr -l es -l it
django-admin.py compilemessages -l de -l fr -l es -l it

Backwards compatibility is maintained, and the existing defaults remain.

Attachments (1)

multiple_locales_and_domains.diff (20.1 KB ) - added by Amin Mirzaee 13 years ago.

Download all attachments as: .zip

Change History (12)

by Amin Mirzaee, 13 years ago

comment:1 by Amin Mirzaee, 13 years ago

Cc: aminland@… added

comment:2 by Julien Phalip, 13 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedNew feature

That sounds good to me. I'm just wondering if we should allow "-d django -d djangojs -l de -l fr" or "-d django,djangojs -l de,fr" or both. Note that the "extensions" option of makemessages allows both.

comment:3 by Julien Phalip, 13 years ago

Needs documentation: set
Needs tests: set
Patch needs improvement: set

For the sake of consistency with the --extensions option, let's make it work for both syntaxes above. It'd just be a matter of adding a few split(',')'s to the existing patch. Some documentation and tests would also be needed. Thanks!

comment:4 by Craig Blaszczyk, 12 years ago

Owner: changed from nobody to Craig Blaszczyk

comment:5 by Craig Blaszczyk, 12 years ago

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

I've created a pull request for this https://github.com/django/django/pull/121

comment:6 by Craig Blaszczyk, 12 years ago

Triage Stage: AcceptedFixed on a branch

comment:7 by Craig Blaszczyk, 12 years ago

Cc: Craig Blaszczyk added

comment:8 by Ramiro Morales <cramm0@…>, 12 years ago

In 6158c79dbef832bc8530107ab2d34f04a04471da:

Made (make|compile)messages commands accept multiple locales at once.

Thanks Craig Blaszczyk for the initial patch. Refs #17181.

comment:9 by Ramiro Morales, 12 years ago

Resolution: fixed
Status: newclosed
Triage Stage: Fixed on a branchAccepted

Initial plan was to split the work for the features proposed in the PR in two parts:

a) Add support for multiple locales to makemessages and compilemessages (already done)
b) Add support for multiple gettext domains to makemessages

Regarding feature b:

I found the proposed patch/PR is buggy regarding handling of multiple domains and the file extensions to be processed as pertaining to each one of these domains. Found this while adding tests for the functionality that were missing from the PR.

IMO the new functionality isn't worth the trouble both in terms of support code (relatively simple) and in terms of the command line switches UI needed to allow the user to express arbitrary combinations of domains plus their sets of file extensions.

Conclusion: I'm closing this ticket as fixed having only implemented feature a.

Last edited 12 years ago by Ramiro Morales (previous) (diff)

comment:10 by Ramiro Morales, 12 years ago

Also, I see I've not given credit in the commit message to contributor aminland who is the original author of the code. Thank you for your great work and please excuse my error.

comment:11 by Craig Blaszczyk, 12 years ago

Thanks Ramiro!

Note: See TracTickets for help on using tickets.
Back to Top