#29144: `DjangoTranslation.merge` loses catalog fallbacks
     Reporter:  Patryk Zawadzki      |                    Owner:  Patryk
                                     |  Zawadzki
         Type:  Bug                  |                   Status:  assigned
    Component:                       |                  Version:  2.0
  Internationalization               |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0

Comment (by Matt Westcott):

 Very happy to see this being addressed! (We were bitten by this on
 Wagtail... https://github.com/wagtail/wagtail/issues/3600 )

 When I looked into this some time ago, I think I stumbled at the point of
 making Django's precedence rules behave correctly with gettext's: to be
 totally correct, I believe it should apply all of Django's translation-
 finding rules (LOCALE_PATHS in sequence, then INSTALLED_APPS in sequence,
 then Django's own) for the most specific locale (`de_DE.ISO8859-1`),
 followed by the same sequence of rules for the next locale (`de_DE`), and
 so on.

 In the case of the current PR, I suspect that there are some possible
 setups where this ordering isn't strictly followed, but as far as I can
 see, this only arises when there are three or more locale identifiers in
 play. (The primary catalog is built up with a `dict.update`, as per
 Django's existing code, but the fallbacks are added to the end of the
 chain - as per the gettext implementation of `add_fallback`. So, after
 it's finished pulling in all the translations, the final order of
 precedence will be all of the `de_DE.ISO8859-1` translations, followed by
 `de_DE` and `de.ISO8859-1` and `de` for each app - rather than all of the
 `de_DE.ISO8859-1` translations, followed by all of the `de_DE`
 translations, followed by all of the `de.ISO8859-1` translations...).
 Obviously, this is an incredibly obscure and minor point relative to the
 issue being fixed here (and doing it 100% correctly probably requires
 replicating or monkeypatching gettext internals), so I'm happy for this to
 be accepted as-is. I'm only raising this as a gotcha in case a more alert
 reviewer notices a more severe side-effect :-)

Ticket URL: <https://code.djangoproject.com/ticket/29144#comment:2>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to