Default textdomain loading cleanup. Fix for bug 230.
git-svn-id: https://develop.svn.wordpress.org/trunk@1817 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f95b24fb39
commit
ac3556c7aa
@ -115,6 +115,9 @@ class gettext_reader {
|
|||||||
$meta = $this->ORIGINALS[$num];
|
$meta = $this->ORIGINALS[$num];
|
||||||
$length = $meta[0];
|
$length = $meta[0];
|
||||||
$offset = $meta[1];
|
$offset = $meta[1];
|
||||||
|
if (! $length) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
$this->STREAM->seekto($offset);
|
$this->STREAM->seekto($offset);
|
||||||
$data = $this->STREAM->read($length);
|
$data = $this->STREAM->read($length);
|
||||||
return (string)$data;
|
return (string)$data;
|
||||||
|
@ -3,8 +3,6 @@ $parentpath = dirname(dirname(__FILE__));
|
|||||||
|
|
||||||
require_once($parentpath.'/wp-config.php');
|
require_once($parentpath.'/wp-config.php');
|
||||||
|
|
||||||
$curpath = dirname(__FILE__).'/';
|
|
||||||
|
|
||||||
$locale = '';
|
$locale = '';
|
||||||
|
|
||||||
// WPLANG is defined in wp-config.
|
// WPLANG is defined in wp-config.
|
||||||
@ -16,20 +14,8 @@ if (empty($locale)) {
|
|||||||
$locale = 'en_US';
|
$locale = 'en_US';
|
||||||
}
|
}
|
||||||
|
|
||||||
$mofile = $curpath . "languages/$locale.mo";
|
require_once(ABSPATH . 'wp-includes/streams.php');
|
||||||
|
require_once(ABSPATH . 'wp-includes/gettext.php');
|
||||||
require($curpath . 'streams.php');
|
|
||||||
require($curpath . 'gettext.php');
|
|
||||||
|
|
||||||
// If the mo file does not exist or is not readable, or if the locale is
|
|
||||||
// en_US, do not load the mo.
|
|
||||||
if ( is_readable($mofile) && ($locale != 'en_US') ) {
|
|
||||||
$input = new FileReader($mofile);
|
|
||||||
} else {
|
|
||||||
$input = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$l10n['default'] = new gettext_reader($input);
|
|
||||||
|
|
||||||
// Return a translated string.
|
// Return a translated string.
|
||||||
function __($text, $domain = 'default') {
|
function __($text, $domain = 'default') {
|
||||||
@ -67,6 +53,10 @@ function __ngettext($single, $plural, $number, $domain = 'default') {
|
|||||||
function load_textdomain($domain, $mofile) {
|
function load_textdomain($domain, $mofile) {
|
||||||
global $l10n;
|
global $l10n;
|
||||||
|
|
||||||
|
if (isset($l10n[$domain])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( is_readable($mofile)) {
|
if ( is_readable($mofile)) {
|
||||||
$input = new FileReader($mofile);
|
$input = new FileReader($mofile);
|
||||||
} else {
|
} else {
|
||||||
@ -76,6 +66,14 @@ function load_textdomain($domain, $mofile) {
|
|||||||
$l10n[$domain] = new gettext_reader($input);
|
$l10n[$domain] = new gettext_reader($input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function load_default_textdomain() {
|
||||||
|
global $l10n, $locale;
|
||||||
|
|
||||||
|
$mofile = ABSPATH . "wp-includes/languages/$locale.mo";
|
||||||
|
|
||||||
|
load_textdomain('default', $mofile);
|
||||||
|
}
|
||||||
|
|
||||||
function load_plugin_textdomain($domain) {
|
function load_plugin_textdomain($domain) {
|
||||||
global $locale;
|
global $locale;
|
||||||
|
|
||||||
@ -90,5 +88,8 @@ function load_theme_textdomain($domain) {
|
|||||||
load_textdomain($domain, $mofile);
|
load_textdomain($domain, $mofile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load the default domain.
|
||||||
|
load_default_textdomain();
|
||||||
|
|
||||||
require($curpath . 'locale.php');
|
require($curpath . 'locale.php');
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user