[wp-trac] [WordPress Trac] #52438: Theme translations in WP_LANG_DIR are loaded twice, no (logical) way to override from a (child) theme.

WordPress Trac noreply at wordpress.org
Tue Nov 12 13:37:45 UTC 2024


#52438: Theme translations in WP_LANG_DIR are loaded twice, no (logical) way to
override from a (child) theme.
---------------------------------------+-----------------------
 Reporter:  captain.crash              |       Owner:  (none)
     Type:  defect (bug)               |      Status:  reopened
 Priority:  normal                     |   Milestone:
Component:  I18N                       |     Version:  5.6
 Severity:  minor                      |  Resolution:
 Keywords:  needs-patch needs-testing  |     Focuses:
---------------------------------------+-----------------------
Changes (by captain.crash):

 * status:  closed => reopened
 * resolution:  worksforme =>


Comment:

 Replying to [comment:6 swissspidy]:
 > Can't reproduce this at first glance. Code to reproduce would be
 helpful.

 A first glance after almost four years? Nice.
 I understand that this is a minor thing, but all the code to reproduce was
 there or linked to in my original report.

 Changes to `_load_textdomain_just_in_time()` seem to have fixed the double
 loading issue, but the underlying problems remain.

 1) What is the condition, now found
 [[https://core.trac.wordpress.org/browser/tags/6.6/src/wp-
 includes/l10n.php#L1402|here]], supposed to be doing? If `isset( $l10n[
 $domain ] )` is `false`, how could the condition after `||` ever be
 `true`? But, if that part gets evaluated, then the call to
 `_load_textdomain_just_in_time()` might use `return load_textdomain(
 $domain, $mofile, $locale );` as a return value and that could already
 load a .mo file (see
 [[https://core.trac.wordpress.org/browser/tags/6.6/src/wp-
 includes/l10n.php#L710|here]]) which is way too early and not desired in
 this place.

 2) I'm trying to override some translation strings from within a child
 theme for a (parent) theme that has online translations stored into
 WP_LANG_DIR/themes/parentdomain-locale.mo. I put my divergent translations
 for the parent theme into my child theme CHILD/languages/parentdomain-
 locale.mo, so I do not lose them during updates. Obviously, I want these
 to take precedence. How am I supposed to make these load **before** the
 ones in WP_LANG_DIR/themes/domain-locale.mo?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52438#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list