[wp-trac] [WordPress Trac] #34114: Remove the requirement to call load_plugin_textdomain() or load_theme_textdomain()
WordPress Trac
noreply at wordpress.org
Sun Jan 3 04:28:36 UTC 2016
#34114: Remove the requirement to call load_plugin_textdomain() or
load_theme_textdomain()
-------------------------------------------------+-------------------------
Reporter: johnbillion | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future
Component: I18N | Release
Severity: normal | Version:
Keywords: dev-feedback has-patch has-unit- | Resolution:
tests | Focuses:
-------------------------------------------------+-------------------------
Comment (by nacin):
> The first time core encounters a localised string with a textdomain that
has not already been loaded, it should look for a corresponding MO file
first in the WP_LANG_DIR/plugins directory and then in the
WP_LANG_DIR/themes directory, and load it if it's found.
Very smart approach, @johnbillion. And @swissspidy, a very elegant patch
with some solid tests.
The main problem here is we'll double the number of `file_exists()`
checks, as at the time of call, we don't know whether to look in `plugins`
or `themes`. I think there's a decent way out of this one.
There's only ever going to be one or two themes, so maybe we can do that
one a bit differently — perhaps by always calling it and eating the 2 or 4
`file_exists()` checks — and then using `load_plugin_textdomain()` inside
`get_translations_for_domain()`. Thus `2p + 2t + 2c` (where c is child
theme and can be 0), rather than `4(p + t + c)`. That's still a change
from what we have now, which is `2( p + t + c)`.
That's still not great, as there's a good chance a plugin is
internationalized but not translated, which means we're burning
`file_exists()` checks on those sites. This includes en_US sites, by the
way.
The underlying `stat()` call isn't going to be terribly expensive in most
situations, but we should still seek to avoid unnecessary calls with
whatever is reasonable.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34114#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list