[wp-trac] [WordPress Trac] #62337: i18n: Translation is not applied in load_theme_textdomain() function

WordPress Trac noreply at wordpress.org
Tue Nov 19 10:55:05 UTC 2024


#62337: i18n: Translation is not applied in load_theme_textdomain() function
--------------------------------------+-------------------------
 Reporter:  wildworks                 |       Owner:  swissspidy
     Type:  defect (bug)              |      Status:  reviewing
 Priority:  normal                    |   Milestone:  6.7.1
Component:  I18N                      |     Version:  6.7
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+-------------------------

Comment (by timwhitlock):

 Replying to [comment:35 swissspidy]:
 > What‘s your use case for that and why do unload_textdomain &
 load_textdomain() not work for you in that case?

 My plugin lets users override GlotPress translations with their own custom
 translation files. It does this by listening on the `load_textdomain`
 action hook. When the original MO is requested, a custom file is loaded if
 one exists. If both exist, they are merged.

 You can see the code if you like here: https://github.com/loco/wp-
 loco/blob/master/src/hooks/LoadHelper.php

 WP 6.7 breaks this function for the reasons well noted in this thread.
 Premature JIT invocation is a pervasive problem, and one out of my
 control. With 1+ million installs, you can imagine my inbox is full of
 some quite angry people.

 So to answer your question - **I can't call `unload_textdomain`**, because
 my code won't run until hooks fire. Which they now don't. Only the text
 domain provider can make that fix. My users will be lucky if that happens
 fast enough, or at all.

 In order to restore previous functionality myself I would have have to
 forcefully unload all text domains when my plugin starts up. I don't want
 to do that, partly for performance. But if 6.7.1 doesn't rectify the issue
 I may have to.

 It's worth noting that unloading NOOP translations does indeed cover a lot
 of the most common cases, but not all of them. I don't see a good reason
 to be deliberately be so selective, other than to protect the performance
 gains for which this change was [I assume] primarily made. I respect the
 need for performance, but not at the expense of broken websites.

 Ideally I'd like to see an action hook that gets fired for
 `load_theme_textdomain` and `load_plugin_textdomain`. This would allow
 people to fix the problem as they see fit without compromising performance
 for everyone else.

 Sorry for such a long answer, but I've lived and breathed this problem for
 the past week.
 Thanks for your consideration!

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


More information about the wp-trac mailing list