Opened 10 months ago

Last modified 7 weeks ago

#22617 new Cleanup/optimization

Allow to fix translation -> Fix makemessages to not delete debug data and hide errors (and all similar modules using "msgmerge")

Reported by: Cezary.Wagner Owned by: nobody
Component: Core (Management commands) Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description (last modified by timo)

Please replace code in make messages to not delete *.po files if error occurred and show messages (fix exception later).

Replace this code:

            if errors:
                if status != STATUS_OK:
                    raise CommandError(
                        "errors happened while running msgmerge\n%s" % errors)
                elif self.verbosity > 0:
                    self.stdout.write(errors)

With this code (it shows error root cause and save/copy *.po need to solve this error):

            if errors:
                if status != STATUS_OK:
                    self.stdout.write(errors) # bug exception bellow not shows errors
                    import shutil
                    shutil.copyfile(pofile, '%s.debug' % pofile)
                    raise CommandError(
                        "errors happened while running msgmerge\n%s" % errors)
                elif self.verbosity > 0:
                    self.stdout.write(errors)

All modules using command line tools should report errors and not delete input if error occurred.

Change History (13)

comment:1 Changed 10 months ago by timo

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Does the --keep-pot option not help?

comment:2 Changed 10 months ago by timo

This PR appears related.

comment:3 Changed 10 months ago by Cezary.Wagner

Not known about such option but should not help too much since many bugs is in code - see my pulls on github.

  1. Messages from msgmerge is not presented since bug - exception blocks print out.
  2. --keep-pot is not presented in --help I think so (not checked but never seen it before - o.k. since it from 1.6).

I think problem is with "blocktrans" on 60% - I gave up now - I was done very large project more than 1k strings.

comment:4 Changed 10 months ago by Cezary.Wagner

Push Request on github is related.

comment:5 Changed 10 months ago by timo

I will let someone more familiar with makemessages make a call on whether or not anything needs to be done here, but for some more context, I also closed #22615 and #22616 which are related.

I do see --keep-pot in the help for makemessages on 1.6 (I'm not sure if that's what you are saying in the above comment).

comment:6 Changed 8 months ago by timo

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

comment:7 Changed 8 months ago by anonymous

You not understand this bug really - it is not problem of *.pot bit *.po file. As far as I remember there is not help if I use --keep-pot.

It not helps :)

Read it again "Messages from msgmerge is not presented since bug - exception blocks print out." - I will reopen until we will find some solution - I will not give up now ...

comment:8 Changed 8 months ago by Cezary.Wagner

It is not solve still "Messages from msgmerge is not presented since bug - exception blocks print out." is in force!

You need to known where in django template there is error - --keep-pot allow nothing in this case.

comment:9 Changed 8 months ago by Cezary.Wagner

  • Resolution needsinfo deleted
  • Status changed from closed to new

comment:10 Changed 7 months ago by areski

It seems there is some confusion with this ticket, to clarify:

  • keep-pot option ONLY prevent Django from deleting the temporary .pot
  • this patch ensure that we don't delete the original PO file when msgmerge fails.

I haven't be able to test it as I guess it's a bit tricky to make msgmerge fails.
The PR looks good but I would recommend to move 'import shutil' at the top of the file.

comment:11 Changed 7 months ago by timo

  • Component changed from Uncategorized to Core (Management commands)
  • Description modified (diff)
  • Type changed from Uncategorized to Cleanup/optimization

comment:12 Changed 3 months ago by timgraham

  • Has patch set
  • Triage Stage changed from Unreviewed to Accepted
  • Version changed from 1.6 to master

Let's see if we can get someone to review the patch. Is it feasible to add tests?

comment:13 Changed 7 weeks ago by berkerpeksag

  • Patch needs improvement set
Note: See TracTickets for help on using tickets.
Back to Top