#36010: compilemessages reports errors only once
-------------------------------------+-------------------------------------
     Reporter:  Balazs Endresz       |                     Type:  Bug
       Status:  new                  |                Component:
                                     |  Internationalization
      Version:  5.1                  |                 Severity:  Normal
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
 When calling `compilemessages` for a locale that has invalid entries it
 prints out the errors correctly first.
 But any subsequent calls just say that it's `already compiled and up to
 date`.
 This is because `msgfmt` updates the last modified date of the mo file
 even if it's invalid, and then django will skip that locale afterwards:
 
https://github.com/django/django/blob/main/django/core/management/commands/compilemessages.py#L153

 This can reproduced by calling compilemessages twice in
 `django/tests/i18n/test_compilation.py`:

 {{{#!python
 class CompilationErrorHandling(MessageCompilationTests):
     def test_error_reported_by_msgfmt(self):
         # po file contains wrong po formatting.
         with self.assertRaises(CommandError):
             call_command("compilemessages", locale=["ja"], verbosity=0)

         # subsequent calls should still fail
         with self.assertRaises(CommandError):
             call_command("compilemessages", locale=["ja"], verbosity=0)  #
 currently this doesn't raise CommandError
 }}}

 One way of fixing this is perhaps doing the validation separately first,
 e.g. with `mo_path = "NUL" if os.name == "nt" else "/dev/null"` and then
 calling `msgfmt` again with the actual `mo_path` only if that passes.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36010>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070193c5b90256-f45f4527-2292-4b4f-b510-55335b529d41-000000%40eu-central-1.amazonses.com.

Reply via email to