Code

Opened 3 years ago

Closed 2 years ago

Last modified 7 months ago

#16903 closed New feature (fixed)

Add '--no-location' option for 'makemessages' command

Reported by: alpar Owned by: nobody
Component: Core (Management commands) Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: yes UI/UX: no

Description

The attached patch adds a --no-location option for the makemessages management command. It is against svn trunk revision -r16861. Please consider adding it to the svn repo.

Rational: Location comments in the .po files can are very annoying when they are version controlled, because changes in the source codes will trigger a lot of changes in the .po files, even when the strings to be translated are not affected. The obvious remedy for this is using --no-location.

Attachments (3)

no-location.patch (5.3 KB) - added by alpar 3 years ago.
no-location-with-tests.patch (6.6 KB) - added by alpar 3 years ago.
Tests added
no-location-3.patch (7.9 KB) - added by alpar 2 years ago.
Fix tests, add docs

Download all attachments as: .zip

Change History (14)

Changed 3 years ago by alpar

comment:1 follow-up: Changed 3 years ago by aaugustin

  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

It would be nice to add a test in tests/regressiontests/i18n/commands.

comment:2 follow-up: Changed 3 years ago by alpar

A novice question. Assume I have a sole checkout of django svn trunk. What is the easiest way to run its tests? (All of them, or just a specific one, such as NoWrapExtractorTests).

comment:3 in reply to: ↑ 2 Changed 3 years ago by aaugustin

The fastest way to run all the tests is:

% cd tests
% PYTHONPATH=.. python runtests.py --settings=test_sqlite

That will take some time, because there are more than 4000 tests. You can find more details — in particular, how to run a subset of the tests — in the contributing guide: https://docs.djangoproject.com/en/1.3/internals/contributing/#running-the-unit-tests

Changed 3 years ago by alpar

Tests added

comment:4 in reply to: ↑ 1 ; follow-up: Changed 3 years ago by alpar

Replying to aaugustin:

It would be nice to add a test in tests/regressiontests/i18n/commands.

The newly attached patch also performs some basic tests. Let me know if this is sufficient or not.

(Thanks for the help on testing.)

comment:5 in reply to: ↑ 4 Changed 2 years ago by alpar

Is there anything to do for me in order to get this patch merged into the svn version?

comment:6 Changed 2 years ago by julien

  • Needs documentation set
  • Patch needs improvement set

The patch and tests look good. One note though: the tests currently can be running until you import NoLocationExtractorTests in regressiontests.i18n.tests.py under the if can_run_extraction_tests condition. Could you also update the test method names to test_location_enabled() and test_location_disabled().

Finally, some documentation should be added for this new option: https://docs.djangoproject.com/en/dev/ref/django-admin/#makemessages

Thanks for the great work!

Changed 2 years ago by alpar

Fix tests, add docs

comment:7 Changed 2 years ago by alpar

Please find the revised patch attached.
Changes compared to the previous version:

  • Doc added to docs/ref/django-admin.txt
  • Import NoLocationExtractorTests from tests/regressiontests/i18n/tests.py
  • Change the test function names to the suggested ones.

comment:8 Changed 2 years ago by julien

  • Triage Stage changed from Accepted to Ready for checkin

Looks great, thank you!

comment:9 Changed 2 years ago by julien

  • Resolution set to fixed
  • Status changed from new to closed

In [17081]:

Fixed #16903 -- Added --no-location option to the makemessages command to not write '#: filename:line' comment lines in language files. Thanks to alpar for the suggestion and patch.

comment:10 Changed 7 months ago by Ramiro Morales <ramiro@…>

In 4b715fc05a75c375d5afe1860ce748ae2a2e290b:

Fixed #21209 -- .po file path comments on Windows.

Literals from source files with Django template language syntax don't
have a '.py' suffix anymore.

Also, the '.\' prefix is preserved to respect GNU gettext behavior on
that platform.

Refs #16903.

comment:11 Changed 7 months ago by Ramiro Morales <ramiro@…>

In d16753eecd3c97c781382fbb4c119f6bae314487:

[1.6.x] Fixed #21209 -- .po file path comments on Windows.

Literals from source files with Django template language syntax don't
have a '.py' suffix anymore.

Also, the '.\' prefix is preserved to respect GNU gettext behavior on
that platform.

Refs #16903.

4b715fc05a from master.

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.