mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Set the locale and load the default text domain after plugins are loaded so that plugins can manipulate the locale. Bug 765.
git-svn-id: http://svn.automattic.com/wordpress/trunk@2161 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7f793c6cfe
commit
0e73b09de1
@ -1,20 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
$locale = '';
|
|
||||||
|
|
||||||
// WPLANG is defined in wp-config.
|
|
||||||
if (defined('WPLANG')) {
|
|
||||||
$locale = WPLANG;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($locale)) {
|
|
||||||
$locale = 'en_US';
|
|
||||||
}
|
|
||||||
|
|
||||||
$locale = apply_filters('locale', $locale);
|
|
||||||
|
|
||||||
require_once(ABSPATH . 'wp-includes/streams.php');
|
require_once(ABSPATH . 'wp-includes/streams.php');
|
||||||
require_once(ABSPATH . 'wp-includes/gettext.php');
|
require_once(ABSPATH . 'wp-includes/gettext.php');
|
||||||
|
|
||||||
|
function get_locale() {
|
||||||
|
global $locale;
|
||||||
|
|
||||||
|
if (isset($locale))
|
||||||
|
return $locale;
|
||||||
|
|
||||||
|
// WPLANG is defined in wp-config.
|
||||||
|
if (defined('WPLANG')) {
|
||||||
|
$locale = WPLANG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($locale)) {
|
||||||
|
$locale = 'en_US';
|
||||||
|
}
|
||||||
|
|
||||||
|
$locale = apply_filters('locale', $locale);
|
||||||
|
|
||||||
|
return $locale;
|
||||||
|
}
|
||||||
|
|
||||||
// Return a translated string.
|
// Return a translated string.
|
||||||
function __($text, $domain = 'default') {
|
function __($text, $domain = 'default') {
|
||||||
global $l10n;
|
global $l10n;
|
||||||
@ -65,29 +72,26 @@ function load_textdomain($domain, $mofile) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function load_default_textdomain() {
|
function load_default_textdomain() {
|
||||||
global $l10n, $locale;
|
global $l10n;
|
||||||
|
|
||||||
|
$locale = get_locale();
|
||||||
$mofile = ABSPATH . "wp-includes/languages/$locale.mo";
|
$mofile = ABSPATH . "wp-includes/languages/$locale.mo";
|
||||||
|
|
||||||
load_textdomain('default', $mofile);
|
load_textdomain('default', $mofile);
|
||||||
}
|
}
|
||||||
|
|
||||||
function load_plugin_textdomain($domain) {
|
function load_plugin_textdomain($domain) {
|
||||||
global $locale;
|
$locale = get_locale();
|
||||||
|
|
||||||
$mofile = ABSPATH . "wp-content/plugins/$domain-$locale.mo";
|
$mofile = ABSPATH . "wp-content/plugins/$domain-$locale.mo";
|
||||||
load_textdomain($domain, $mofile);
|
load_textdomain($domain, $mofile);
|
||||||
}
|
}
|
||||||
|
|
||||||
function load_theme_textdomain($domain) {
|
function load_theme_textdomain($domain) {
|
||||||
global $locale;
|
$locale = get_locale();
|
||||||
|
|
||||||
$mofile = get_template_directory() . "/$locale.mo";
|
$mofile = get_template_directory() . "/$locale.mo";
|
||||||
load_textdomain($domain, $mofile);
|
load_textdomain($domain, $mofile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the default domain.
|
|
||||||
load_default_textdomain();
|
|
||||||
|
|
||||||
require_once(ABSPATH . WPINC . '/locale.php');
|
|
||||||
?>
|
?>
|
||||||
|
@ -101,6 +101,12 @@ if ( get_settings('active_plugins') ) {
|
|||||||
|
|
||||||
define('TEMPLATEPATH', get_template_directory());
|
define('TEMPLATEPATH', get_template_directory());
|
||||||
|
|
||||||
|
// Load the default text localization domain.
|
||||||
|
load_default_textdomain();
|
||||||
|
|
||||||
|
// Pull in locale data after loading text domain.
|
||||||
|
require_once(ABSPATH . WPINC . '/locale.php');
|
||||||
|
|
||||||
if ( !get_magic_quotes_gpc() ) {
|
if ( !get_magic_quotes_gpc() ) {
|
||||||
$_GET = add_magic_quotes($_GET );
|
$_GET = add_magic_quotes($_GET );
|
||||||
$_POST = add_magic_quotes($_POST );
|
$_POST = add_magic_quotes($_POST );
|
||||||
|
Loading…
Reference in New Issue
Block a user