[wp-trac] [WordPress Trac] #34213: Change priority for loading theme/plugin translations
WordPress Trac
noreply at wordpress.org
Sat Apr 30 12:22:54 UTC 2016
#34213: Change priority for loading theme/plugin translations
------------------------------+-----------------------
Reporter: sebastian.pisula | Owner:
Type: enhancement | Status: reopened
Priority: normal | Milestone: 4.6
Component: I18N | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
------------------------------+-----------------------
Comment (by ocean90):
Replying to [comment:17 swissspidy]:
The other functions have the `$path` handling before the loading part.
Should we change that for all? Example for `load_plugin_textdomain()`:
{{{#!php
<?php
function load_plugin_textdomain( $domain, $deprecated = false,
$plugin_rel_path = false ) {
$locale = get_locale();
/**
* Filter a plugin's locale.
*
* @since 3.0.0
*
* @param string $locale The plugin's current locale.
* @param string $domain Text domain. Unique identifier for
retrieving translated strings.
*/
$locale = apply_filters( 'plugin_locale', $locale, $domain );
$mofile = $domain . '-' . $locale . '.mo';
// Try to load from the languages directory first.
$loaded = load_textdomain( $domain, WP_LANG_DIR . '/plugins/' .
$mofile );
if ( $loaded ) {
return true;
}
// Otherwise, load the textdomain according to the plugin.
if ( false !== $plugin_rel_path ) {
$path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/'
);
} elseif ( false !== $deprecated ) {
_deprecated_argument( __FUNCTION__, '2.7' );
$path = ABSPATH . trim( $deprecated, '/' );
} else {
$path = WP_PLUGIN_DIR;
}
return load_textdomain( $domain, $path . '/' . $mofile );
}
}}}
#micro-optimization
----
I also just noticed that `$mofile` in [attachment:34213.diff] for
`load_theme_textdomain()` is only valid for language packs. The .mo file
has a different naming scheme, from the DocBlock: "The .mo files must be
named based on the locale exactly.".
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34213#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list