Code

Opened 3 years ago

Closed 18 months ago

Last modified 18 months ago

#17181 closed New feature (fixed)

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

Reported by: aminland Owned by: jakul
Component: Internationalization Version: 1.3
Severity: Normal Keywords: i18n makemessages compilemessages
Cc: aminland@…, jakul 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 aminland 3 years ago.

Download all attachments as: .zip

Change History (12)

Changed 3 years ago by aminland

comment:1 Changed 3 years ago by aminland

  • Cc aminland@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 3 years ago by julien

  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to New 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 Changed 3 years ago by julien

  • 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 Changed 2 years ago by jakul

  • Owner changed from nobody to jakul

comment:5 Changed 2 years ago by jakul

  • 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 Changed 2 years ago by jakul

  • Triage Stage changed from Accepted to Fixed on a branch

comment:7 Changed 2 years ago by jakul

  • Cc jakul added

comment:8 Changed 18 months ago by Ramiro Morales <cramm0@…>

In 6158c79dbef832bc8530107ab2d34f04a04471da:

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

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

comment:9 Changed 18 months ago by ramiro

  • Resolution set to fixed
  • Status changed from new to closed
  • Triage Stage changed from Fixed on a branch to Accepted

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 18 months ago by ramiro (previous) (diff)

comment:10 Changed 18 months ago by ramiro

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 Changed 18 months ago by jakul

Thanks Ramiro!

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.