[wp-trac] [WordPress Trac] #58035: Allow to short-circuit load_textdomain()

WordPress Trac noreply at wordpress.org
Fri Mar 31 14:46:28 UTC 2023


#58035: Allow to short-circuit load_textdomain()
-------------------------+--------------------
 Reporter:  ocean90      |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  6.3
Component:  I18N         |    Version:
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+--------------------
 `load_textdomain()` has a filter `override_load_textdomain` which only
 allows to return `true` to prevent further execution of the function.

 This becomes an issue if the filter callback was not able to load the
 file. Returning `true` in this case is not an option because that will
 cause `_load_textdomain_just_in_time()` to return early and not falling
 back to translations provided by a theme/plugin. Returning `false` means
 that `load_textdomain()` does all the work again even we already know that
 the file doesn't exist.

 For this I'm proposing a `pre_load_textdomain` filter which runs before
 the current `override_load_textdomain` filter. This will be consistent
 with the `pre_load_script_translations` filter in
 `load_script_translations()` for JavaScript translations.

 The filter will be useful to plugins which can develop and test
 alternative loading/caching strategies for translations.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58035>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list