makemessages too eager to cleanup, makes it hard to debug errors
|Reported by:||airstrike||Owned by:||airstrike|
|Component:||Core (Management commands)||Version:||1.3|
|Severity:||Normal||Keywords:||makemessages .pot .po gettext xgettext translation debug|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||yes||Patch needs improvement:||yes|
./manage.py makemessages always removes .pot files when finished, but sometimes this just makes debugging harder. I propose an option be added to allow for prevent deletion of these files, even when errors occur in the function.
The need for this option arose of an error which was, even when at verbose level 3, resulting in nearly useless debugging information when running ./manage.py makemessages --locale=pt_BR -a -d djangojs -v3:
processing language pt_BR ignoring file .gitignore in . ignoring file .project in . ignoring file .pydevproject in . ignoring file .urls.py.swp in . ignoring file urls.py~ in . processing file athena.js in .\static\js (...) processing file superfish.js in .\static\js processing file grappelli.js in .\static\js\grappelli processing file jquery.grp_collapsible.js in .\static\js\grappelli processing file jquery.grp_collapsible_group.js in .\static\js\grappelli processing file jquery.grp_inline.js in .\static\js\grappelli processing file jquery.grp_related_fk.js in .\static\js\grappelli processing file jquery.grp_related_generic.js in .\static\js\grappelli processing file jquery.grp_related_m2m.js in .\static\js\grappelli processing file jquery.grp_timepicker.js in .\static\js\grappelli Error: errors happened while running msguniq C:\projects\portal\hermes\locale\pt_BR\LC_MESSAGES\djangojs.pot:57: context separator <EOT> within string C:\projects\portal\hermes\locale\pt_BR\LC_MESSAGES\djangojs.pot:58: context separator <EOT> within string msguniq: found 2 fatal errors 
As you can see, it's hard to tell which of these files caused the EOT within string error, but by keeping djangojs.pot and then reading lines 57 and 58, I was able to deduct that athena.js was the file to blame
#: .\static\js\athena.js.c:30 .\static\js\athena.js.c:38 msgid "<EOT>"  msgid_plural "<EOT>"  msgstr "" msgstr ""
 this line translated from Portuguese in this post to help understanding.
 these lines had a EOT character rather than <EOT> that can't be displayed here.
I've attached a simple patch which provides the user with a --keep-pot option to help in edge cases like this one, which simply skips the os.unlink(potfile) call.
Change History (18)
comment:1 Changed 3 years ago by aaugustin
- Needs documentation set
- Needs tests set
- Patch needs improvement set
- Triage Stage changed from Unreviewed to Accepted
Changed 3 years ago by julien
Changed 3 years ago by ramiro
comment:9 Changed 2 years ago by Ramiro Morales <cramm0@…>
- Resolution set to fixed
- Status changed from new to closed