[wp-trac] [WordPress Trac] #39210: switch_to_locale() unloads all plugin and theme translations
WordPress Trac
noreply at wordpress.org
Fri Dec 9 21:37:44 UTC 2016
#39210: switch_to_locale() unloads all plugin and theme translations
--------------------------+------------------------------
Reporter: gchtr | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: I18N | Version: 4.7
Severity: normal | Resolution:
Keywords: needs-patch | Focuses:
--------------------------+------------------------------
Changes (by ocean90):
* keywords: => needs-patch
Comment:
Hello @gchtr, welcome to WordPress Trac!
Thanks for your detailed report!
The language switcher was introduced in [38961]. The first iterations had
support for caching translations during a switch, see
[attachment:26511.diff:ticket:26511]. But this was removed in favour of
`_load_textdomain_just_in_time()`. The committed version had also a change
[https://core.trac.wordpress.org/changeset/38961#file9 to the POMO
library] to store the current path of a translation file. But the part in
the switcher didn't actually work and got removed in
[https://core.trac.wordpress.org/changeset/39330/trunk/src/wp-includes
/class-wp-locale-switcher.php 39330]. So yeah, you're right that the
switcher can't handle translations by themes/plugins which don't have
their translations in `WP_LANG_DIR` which is used by
`_load_textdomain_just_in_time()`.
Sadly we didn't document that in the dev note. It's not really intended
behavior, but it's the current behavior. As a workaround you can use the
new [https://developer.wordpress.org/reference/hooks/change_locale/
change_locale] action. It gets called when a locale is switched or
restored. You can use it to call your custom
`load_(theme|plugin)_textdomain()` function.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39210#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list