在里面wp-includes/l10n.php
您将找到函数get_locale()
. 它提供了一个过滤器;您可以设置语言并忽略常量:
function get_locale() {
global $locale;
if ( isset( $locale ) )
return apply_filters( \'locale\', $locale );
// WPLANG is defined in wp-config.
if ( defined( \'WPLANG\' ) )
$locale = WPLANG;
// If multisite, check options.
if ( is_multisite() ) {
// Don\'t check blog option when installing.
if ( defined( \'WP_INSTALLING\' ) || ( false === $ms_locale = get_option( \'WPLANG\' ) ) )
$ms_locale = get_site_option(\'WPLANG\');
if ( $ms_locale !== false )
$locale = $ms_locale;
}
if ( empty( $locale ) )
$locale = \'en_US\';
return apply_filters( \'locale\', $locale );
}
要更改每个插件,请使用过滤器
\'locale\'
. 示例:
add_filter( \'locale\', \'wpse_52419_change_language\' );
function wpse_52419_change_language( $locale )
{
return \'de_DE\';
}