[wp-trac] [WordPress Trac] #39210: switch_to_locale() unloads all plugin and theme translations
WordPress Trac
noreply at wordpress.org
Mon Feb 11 09:46:08 UTC 2019
#39210: switch_to_locale() unloads all plugin and theme translations
-------------------------------------------------+-------------------------
Reporter: gchtr | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future
| Release
Component: I18N | Version: 4.7
Severity: normal | Resolution:
Keywords: has-patch needs-unit-tests dev- | Focuses:
feedback |
-------------------------------------------------+-------------------------
Comment (by dd32):
Replying to [comment:1 ocean90]:
> 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()`.
Just to add a note that this isn't quite correct (anymore), themes/plugins
which have their translations in `WP_LANG_DIR` and are using
`_load_textdomain_just_in_time()` are definitely affected by this, as
[37113]/#37855 cause *any* unloaded textdomain (whether specifically
requested, or not) to not be re-loadable.
One work-around is to simply disable the `never reload a textdomain`
functionality using this one-liner:
`add_filter( 'change_locale', function() { $GLOBALS['l10n_unloaded'] =
array(); } );```
Another would be a core change like [attachment:"39210.3.diff"] which adds
a flag to `unload_textdomain()` to allow the language switcher to indicate
that the locale can be reloaded if needed by
`_load_textdomain_just_in_time()`.
[attachment:"39210.3.diff"] doesn't attempt to fix the scenario where a
theme/plugin is loading it's own translations, just the WordPress.org-
provided translations. @ocean90 what do you think about at least adding
that?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39210#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list