--- /dev/null +++ wordpress-3.3.mod/wp-includes/pomo/native.php @@ -0,0 +1,233 @@ + + * @url http://oss.tiggerswelt.net/wordpress/3.3.0/ + * @license http://creativecommons.org/licenses/by-sa/3.0/de/ Creative Commons Attribution-Share Alike 3.0 Germany + **/ + + // Check if gettext-support is available + if (!extension_loaded ('gettext')) + return; + + class Translate_GetText_Native { + // Our default domain + private $Domain = null; + + // Merged domains + private $pOthers = array (); + private $sOthers = array (); + + // Some Dummy-Function just to be API-compatible + function add_entry ($entry) { return false; } + function add_entry_or_merge ($entry) { return false; } + function set_header ($header, $value) { return false; } + function set_headers (&$headers) { return false; } + function get_header ($header) { return false; } + function translate_entry (&$entry) { return false; } + + // {{{ select_plural_form + /** + * Given the number of items, returns the 0-based index of the plural form to use + * + * Here, in the base Translations class, the common logic for English is implemented: + * 0 if there is one element, 1 otherwise + * + * This function should be overrided by the sub-classes. For example MO/PO can derive the logic + * from their headers. + * + * @param integer $count number of items + **/ + function select_plural_form ($count) { + return (1 == $count? 0 : 1); + } + // }}} + + function get_plural_forms_count () { return 2; } + + // {{{ merge_with + /** + * Merge this translation with another one, the other one takes precedence + * + * @param object $other + * + * @access public + * @return void + **/ + function merge_with (&$other) { + $this->pOthers [] = $other; + } + // }}} + + // {{{ merge_originals_with + /** + * Merge this translation with another one, this one takes precedence + * + * @param object $other + * + * @access public + * @return void + **/ + function merge_originals_with (&$other) { + $this->sOthers [] = $Other; + } + // }}} + + // {{{ translate + /** + * Try to translate a given string + * + * @param string $singular + * @param string $context (optional) + * + * @access public + * @return string + **/ + function translate ($singular, $context = null) { + // Check for an empty string + if (strlen ($singular) == 0) + return $singular; + + // Check other domains that take precedence + foreach ($this->pOthers as $o) + if (($t = $o->translate ($singular, $context)) != $singular) + return $t; + + // Make sure we have a domain assigned + if ($this->Domain === null) + return $singular; + + // Translate without a context + if ($context === null) { + if (($t = dgettext ($this->Domain, $singular)) != $singular) + return $t; + + // Translate with a given context + } else { + $T = $context . "\x04" . $singular; + $t = dgettext ($this->Domain, $T); + + if ($T != $t) + return $t; + } + + // Check for other domains + foreach ($this->sOthers as $o) + if (($t = $o->translate ($singular, $context)) != $singular) + return $t; + + return $singular; + } + // }}} + + // {{{ translate_plural + /** + * Try to translate a plural string + * + * @param string $singular Singular version + * @param string $plural Plural version + * @param int $count Number of "items" + * @param string $context (optional) + * + * @access public + * @return string + **/ + function translate_plural ($singular, $plural, $count, $context = null) { + // Check for an empty string + if (strlen ($singular) == 0) + return $singular; + + // Get the "default" return-value + $default = ($count == 1 ? $singular : $plural); + + // Check other domains that take precedence + foreach ($this->pOthers as $o) + if (($t = $o->translate_plural ($singular, $plural, $count, $context)) != $default) + return $t; + + // Make sure we have a domain assigned + if ($this->Domain === null) + return $default; + + // Translate without context + if ($context === null) { + $t = dngettext ($this->Domain, $singular, $plural, $count); + + if (($t != $singular) && ($t != $plural)) + return $t; + + // Translate using a given context + } else { + $T = $context . "\x04" . $singular; + $t = dngettext ($this->Domain, $T, $plural, $count); + + if (($T != $t) && ($t != $plural)) + return $t; + } + + // Check other domains + foreach ($this->sOthers as $o) + if (($t = $o->translate_plural ($singular, $plural, $count, $context)) != $default) + return $t; + + return $default; + } + // }}} + + // {{{ import_from_file + /** + * Fills up with the entries from MO file $filename + * + * @param string $filename MO file to load + **/ + function import_from_file ($filename) { + // Make sure that the locale is set correctly in environment + global $locale; + + putenv ('LC_ALL=' . $locale); + setlocale (LC_ALL, $locale); + + // Retrive MD5-hash of the file + # DIRTY! But there is no other way at the moment to make this work + if (!($Domain = md5_file ($filename))) + return false; + + // Make sure that the language-directory exists + $Path = './wp-lang/' . $locale . '/LC_MESSAGES'; + + if (!wp_mkdir_p ($Path)) + return false; + + // Make sure that the MO-File is existant at the destination + $fn = $Path . '/' . $Domain . '.mo'; + + if (!is_file ($fn) && !@copy ($filename, $fn)) + return false; + + // Setup the "domain" for gettext + bindtextdomain ($Domain, './wp-lang/'); + bind_textdomain_codeset ($Domain, 'UTF-8'); + + // Do the final stuff and return success + $this->Domain = $Domain; + + return true; + } + // }}} + } + + if (function_exists ('class_alias')) + class_alias ('Translate_GetText_Native', 'MO'); + else { + class MO extends Translate_GetText_Native { } + } + +?> \ No newline at end of file --- wordpress-3.3.org/wp-settings.php +++ wordpress-3.3.mod/wp-settings.php @@ -83,6 +83,8 @@ // Load early WordPress files. require( ABSPATH . WPINC . '/default-filters.php' ); + +require( ABSPATH . WPINC . '/pomo/native.php'); require( ABSPATH . WPINC . '/pomo/mo.php' ); // Initialize multisite if enabled.