]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/l10n.php
Wordpress 2.3.2
[autoinstalls/wordpress.git] / wp-includes / l10n.php
similarity index 63%
rename from wp-includes/wp-l10n.php
rename to wp-includes/l10n.php
index 213294335570c59d56f2cdc047d06d57e05b5bc2..4dba679896d29ca0e2512d12fdadc29a1a9a1f98 100644 (file)
@@ -1,30 +1,23 @@
 <?php
-
-if ( defined('WPLANG') && '' != constant('WPLANG') ) {
-       include_once(ABSPATH . 'wp-includes/streams.php');
-       include_once(ABSPATH . 'wp-includes/gettext.php');
-}
-
 function get_locale() {
        global $locale;
 
        if (isset($locale))
-               return $locale;
+               return apply_filters( 'locale', $locale );
 
        // WPLANG is defined in wp-config.
        if (defined('WPLANG'))
                $locale = WPLANG;
-       
+
        if (empty($locale))
-               $locale = 'en_US';
+               $locale = '';
 
        $locale = apply_filters('locale', $locale);
 
        return $locale;
 }
 
-// Return a translated string.    
-function __($text, $domain = 'default') {
+function translate($text, $domain) {
        global $l10n;
 
        if (isset($l10n[$domain]))
@@ -33,14 +26,24 @@ function __($text, $domain = 'default') {
                return $text;
 }
 
+// Return a translated string.
+function __($text, $domain = 'default') {
+       return translate($text, $domain);
+}
+
 // Echo a translated string.
 function _e($text, $domain = 'default') {
-       global $l10n;
+       echo translate($text, $domain);
+}
 
-       if (isset($l10n[$domain]))
-               echo apply_filters('gettext', $l10n[$domain]->translate($text), $text);
-       else
-               echo $text;
+function _c($text, $domain = 'default') {
+       $whole = translate($text, $domain);
+       $last_bar = strrpos($whole, '|');
+       if ( false == $last_bar ) {
+               return $whole;
+       } else {
+               return substr($whole, 0, $last_bar);
+       }
 }
 
 // Return the plural form.
@@ -48,7 +51,7 @@ function __ngettext($single, $plural, $number, $domain = 'default') {
        global $l10n;
 
        if (isset($l10n[$domain])) {
-               return $l10n[$domain]->ngettext($single, $plural, $number);
+               return apply_filters('ngettext', $l10n[$domain]->ngettext($single, $plural, $number), $single, $plural, $number);
        } else {
                if ($number != 1)
                        return $plural;
@@ -75,23 +78,33 @@ function load_default_textdomain() {
        global $l10n;
 
        $locale = get_locale();
-       $mofile = ABSPATH . "wp-includes/languages/$locale.mo";
-       
+       if ( empty($locale) )
+               $locale = 'en_US';
+
+       $mofile = ABSPATH . LANGDIR . "/$locale.mo";
+
        load_textdomain('default', $mofile);
 }
 
-function load_plugin_textdomain($domain, $path = 'wp-content/plugins') {
+function load_plugin_textdomain($domain, $path = false) {
        $locale = get_locale();
-       
+       if ( empty($locale) )
+               $locale = 'en_US';
+
+       if ( false === $path )
+               $path = PLUGINDIR;
+
        $mofile = ABSPATH . "$path/$domain-$locale.mo";
        load_textdomain($domain, $mofile);
 }
 
 function load_theme_textdomain($domain) {
        $locale = get_locale();
-       
+       if ( empty($locale) )
+               $locale = 'en_US';
+
        $mofile = get_template_directory() . "/$locale.mo";
        load_textdomain($domain, $mofile);
 }
 
-?>
\ No newline at end of file
+?>