Add gettext filter. fixes #2258

git-svn-id: https://develop.svn.wordpress.org/trunk@3425 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2006-01-10 22:53:40 +00:00
parent 968ef86cf7
commit 1ea86684f4
1 changed files with 14 additions and 20 deletions

View File

@ -12,13 +12,11 @@ function get_locale() {
return $locale; return $locale;
// WPLANG is defined in wp-config. // WPLANG is defined in wp-config.
if (defined('WPLANG')) { if (defined('WPLANG'))
$locale = WPLANG; $locale = WPLANG;
}
if (empty($locale)) { if (empty($locale))
$locale = 'en_US'; $locale = 'en_US';
}
$locale = apply_filters('locale', $locale); $locale = apply_filters('locale', $locale);
@ -29,22 +27,20 @@ function get_locale() {
function __($text, $domain = 'default') { function __($text, $domain = 'default') {
global $l10n; global $l10n;
if (isset($l10n[$domain])) { if (isset($l10n[$domain]))
return $l10n[$domain]->translate($text); return apply_filters('gettext', $l10n[$domain]->translate($text), $text);
} else { else
return $text; return $text;
}
} }
// Echo a translated string. // Echo a translated string.
function _e($text, $domain = 'default') { function _e($text, $domain = 'default') {
global $l10n; global $l10n;
if (isset($l10n[$domain])) { if (isset($l10n[$domain]))
echo $l10n[$domain]->translate($text); echo apply_filters('gettext', $l10n[$domain]->translate($text), $text);
} else { else
echo $text; echo $text;
}
} }
// Return the plural form. // Return the plural form.
@ -64,15 +60,13 @@ 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])) { if (isset($l10n[$domain]))
return; return;
}
if ( is_readable($mofile)) { if ( is_readable($mofile))
$input = new CachedFileReader($mofile); $input = new CachedFileReader($mofile);
} else { else
return; return;
}
$l10n[$domain] = new gettext_reader($input); $l10n[$domain] = new gettext_reader($input);
} }