From 0641eef16ac8445726be37526cfe927ed03633ac Mon Sep 17 00:00:00 2001 From: Carsten Schmitz Date: Thu, 8 Mar 2012 02:23:41 +0100 Subject: [PATCH] Dev Updated PHPGettext library to v1.0.11 --- classes/php-gettext/ChangeLog | 144 -------------------------------- classes/php-gettext/gettext.inc | 78 ++++++++--------- classes/php-gettext/gettext.php | 17 +++- 3 files changed, 54 insertions(+), 185 deletions(-) delete mode 100644 classes/php-gettext/ChangeLog diff --git a/classes/php-gettext/ChangeLog b/classes/php-gettext/ChangeLog deleted file mode 100644 index 5e0949dfd75..00000000000 --- a/classes/php-gettext/ChangeLog +++ /dev/null @@ -1,144 +0,0 @@ -2006-02-07 Danilo Šegan - - * examples/pigs_dropin.php: comment-out bind_textdomain_codeset - - * gettext.inc (T_bind_textdomain_codeset): bind_textdomain_codeset - is available only in PHP 4.2.0+ (thanks to Jens A. Tkotz). - - * Makefile: Include gettext.inc in DIST_FILES, VERSION up to - 1.0.7. - -2006-02-03 Danilo Šegan - - Added setlocale() emulation as well. - - * examples/pigs_dropin.php: Use T_setlocale() and locale_emulation(). - * examples/pigs_fallback.php: Use T_setlocale() and locale_emulation(). - - * gettext.inc: Added globals $EMULATEGETTEXT and $CURRENTLOCALE. - (locale_emulation): Whether emulation is active. - (_check_locale): Rewrite. - (_setlocale): Added emulated setlocale function. - (T_setlocale): Wrapper around _setlocale. - (_get_reader): Use variables and _setlocale. - -2006-02-02 Danilo Šegan - - Fix bug #12192. - - * examples/locale/sr_CS/LC_MESSAGES/messages.po: Correct grammar. - * examples/locale/sr_CS/LC_MESSAGES/messages.mo: Rebuild. - -2006-02-02 Danilo Šegan - - Fix bug #15419. - - * streams.php: Support for PHP 5.1.1 fread() which reads most 8kb. - (Fix by Piotr Szotkowski ) - -2006-02-02 Danilo Šegan - - Merge Steven Armstrong's changes, supporting standard gettext - interfaces: - - * examples/*: Restructured examples. - * gettext.inc: Added. - * AUTHORS: Added Steven. - * Makefile (VERSION): Up to 1.0.6. - -2006-01-28 Nico Kaiser - - * gettext.php (select_string): Fix "true" <-> 1 difference of PHP - -2005-07-29 Danilo Šegan - - * Makefile (VERSION): Up to 1.0.5. - -2005-07-29 Danilo Šegan - - Fixes bug #13850. - - * gettext.php (gettext_reader): check $Reader->error as well. - -2005-07-29 Danilo Šegan - - * Makefile (VERSION): Up to 1.0.4. - -2005-07-29 Danilo Šegan - - Fixes bug #13771. - - * gettext.php (gettext_reader->get_plural_forms): Plural forms - header extraction regex change. Reported by Edgar Gonzales. - -2005-02-28 Danilo Šegan - - * AUTHORS: Added Nico to the list. - - * Makefile (VERSION): Up to 1.0.3. - - * README: Updated. - -2005-02-28 Danilo Šegan - - * gettext.php: Added pre-loading, code documentation, and many - code clean-ups by Nico Kaiser . - -2005-02-28 Danilo Šegan - - * streams.php (FileReader.read): Handle read($bytes = 0). - - * examples/pigs.php: Prefix gettext function names with T or T_. - - * examples/update: Use the same keywords T_ and T_ngettext. - - * streams.php: Added CachedFileReader. - -2003-11-11 Danilo Šegan - - * gettext.php: Added hashing to find_string. - -2003-11-01 Danilo Šegan - - * Makefile (DIST_FILES): Replaced LICENSE with COPYING. - (VERSION): Up to 1.0.2. - - * AUTHORS: Minor edits. - - * README: Minor edits. - - * COPYING: Removed LICENSE, added this file. - - * gettext.php: Added copyright notice and disclaimer. - * streams.php: Same. - * examples/pigs.php: Same. - -2003-10-23 Danilo Šegan - - * Makefile: Upped version to 1.0.1. - - * gettext.php (gettext_reader): Remove a call to set_total_plurals. - (set_total_plurals): Removed unused function for some better days. - -2003-10-23 Danilo Šegan - - * Makefile: Added, version 1.0.0. - - * examples/*: Added an example of usage. - - * README: Described all the crap. - -2003-10-22 Danilo Šegan - - * gettext.php: Plural forms implemented too. - - * streams.php: Added FileReader for direct access to files (no - need to keep file in memory). - - * gettext.php: It works, except for plural forms. - - * streams.php: Created abstract class StreamReader. - Added StringReader class. - - * gettext.php: Started writing gettext_reader. - diff --git a/classes/php-gettext/gettext.inc b/classes/php-gettext/gettext.inc index 399a0f24b42..00b966692cc 100644 --- a/classes/php-gettext/gettext.inc +++ b/classes/php-gettext/gettext.inc @@ -32,7 +32,6 @@ LC_MESSAGES 5 LC_ALL 6 */ - // LC_MESSAGES is not available if php-gettext is not loaded // while the other constants are already available from session extension. if (!defined('LC_MESSAGES')) { @@ -229,7 +228,9 @@ function _setlocale($category, $locale) { } // Allow locale to be changed on the go for one translation domain. global $text_domains, $default_domain; - unset($text_domains[$default_domain]->l10n); + if (array_key_exists($default_domain, $text_domains)) { + unset($text_domains[$default_domain]->l10n); + } return $CURRENTLOCALE; } } @@ -288,9 +289,9 @@ function __($msgid) { /** * Plural version of gettext. */ -function _ngettext($single, $plural, $number) { +function _ngettext($singular, $plural, $number) { $l10n = _get_reader(); - return _encode($l10n->ngettext($single, $plural, $number)); + return _encode($l10n->ngettext($singular, $plural, $number)); } /** @@ -304,9 +305,9 @@ function _dgettext($domain, $msgid) { /** * Plural version of dgettext. */ -function _dngettext($domain, $single, $plural, $number) { +function _dngettext($domain, $singular, $plural, $number) { $l10n = _get_reader($domain); - return _encode($l10n->ngettext($single, $plural, $number)); + return _encode($l10n->ngettext($singular, $plural, $number)); } /** @@ -319,9 +320,9 @@ function _dcgettext($domain, $msgid, $category) { /** * Plural version of dcgettext. */ -function _dcngettext($domain, $single, $plural, $number, $category) { +function _dcngettext($domain, $singular, $plural, $number, $category) { $l10n = _get_reader($domain, $category); - return _encode($l10n->ngettext($single, $plural, $number)); + return _encode($l10n->ngettext($singular, $plural, $number)); } /** @@ -405,29 +406,29 @@ function T_($msgid) { if (_check_locale_and_function()) return _($msgid); return __($msgid); } -function T_ngettext($single, $plural, $number) { +function T_ngettext($singular, $plural, $number) { if (_check_locale_and_function()) - return ngettext($single, $plural, $number); - else return _ngettext($single, $plural, $number); + return ngettext($singular, $plural, $number); + else return _ngettext($singular, $plural, $number); } function T_dgettext($domain, $msgid) { if (_check_locale_and_function()) return dgettext($domain, $msgid); else return _dgettext($domain, $msgid); } -function T_dngettext($domain, $single, $plural, $number) { +function T_dngettext($domain, $singular, $plural, $number) { if (_check_locale_and_function()) - return dngettext($domain, $single, $plural, $number); - else return _dngettext($domain, $single, $plural, $number); + return dngettext($domain, $singular, $plural, $number); + else return _dngettext($domain, $singular, $plural, $number); } function T_dcgettext($domain, $msgid, $category) { if (_check_locale_and_function()) return dcgettext($domain, $msgid, $category); else return _dcgettext($domain, $msgid, $category); } -function T_dcngettext($domain, $single, $plural, $number, $category) { +function T_dcngettext($domain, $singular, $plural, $number, $category) { if (_check_locale_and_function()) - return dcngettext($domain, $single, $plural, $number, $category); - else return _dcngettext($domain, $single, $plural, $number, $category); + return dcngettext($domain, $singular, $plural, $number, $category); + else return _dcngettext($domain, $singular, $plural, $number, $category); } function T_pgettext($context, $msgid) { @@ -451,26 +452,27 @@ function T_dcpgettext($domain, $context, $msgid, $category) { return _dcpgettext($domain, $context, $msgid, $category); } -function T_npgettext($context, $singular, $plural) { +function T_npgettext($context, $singular, $plural, $number) { if (_check_locale_and_function('npgettext')) - return npgettext($context, $single, $plural, $number); + return npgettext($context, $singular, $plural, $number); else - return _npgettext($context, $single, $plural, $number); + return _npgettext($context, $singular, $plural, $number); } -function T_dnpgettext($domain, $context, $singular, $plural) { +function T_dnpgettext($domain, $context, $singular, $plural, $number) { if (_check_locale_and_function('dnpgettext')) - return dnpgettext($domain, $context, $single, $plural, $number); + return dnpgettext($domain, $context, $singular, $plural, $number); else - return _dnpgettext($domain, $context, $single, $plural, $number); + return _dnpgettext($domain, $context, $singular, $plural, $number); } -function T_dcnpgettext($domain, $context, $singular, $plural, $category) { +function T_dcnpgettext($domain, $context, $singular, $plural, + $number, $category) { if (_check_locale_and_function('dcnpgettext')) - return dcnpgettext($domain, $context, $single, + return dcnpgettext($domain, $context, $singular, $plural, $number, $category); else - return _dcnpgettext($domain, $context, $single, + return _dcnpgettext($domain, $context, $singular, $plural, $number, $category); } @@ -494,39 +496,39 @@ if (!function_exists('gettext')) { function _($msgid) { return __($msgid); } - function ngettext($single, $plural, $number) { - return _ngettext($single, $plural, $number); + function ngettext($singular, $plural, $number) { + return _ngettext($singular, $plural, $number); } function dgettext($domain, $msgid) { return _dgettext($domain, $msgid); } - function dngettext($domain, $single, $plural, $number) { - return _dngettext($domain, $single, $plural, $number); + function dngettext($domain, $singular, $plural, $number) { + return _dngettext($domain, $singular, $plural, $number); } function dcgettext($domain, $msgid, $category) { return _dcgettext($domain, $msgid, $category); } - function dcngettext($domain, $single, $plural, $number, $category) { - return _dcngettext($domain, $single, $plural, $number, $category); + function dcngettext($domain, $singular, $plural, $number, $category) { + return _dcngettext($domain, $singular, $plural, $number, $category); } function pgettext($context, $msgid) { return _pgettext($context, $msgid); } - function npgettext($context, $single, $plural, $number) { - return _npgettext($context, $single, $plural, $number); + function npgettext($context, $singular, $plural, $number) { + return _npgettext($context, $singular, $plural, $number); } function dpgettext($domain, $context, $msgid) { return _dpgettext($domain, $context, $msgid); } - function dnpgettext($domain, $context, $single, $plural, $number) { - return _dnpgettext($domain, $context, $single, $plural, $number); + function dnpgettext($domain, $context, $singular, $plural, $number) { + return _dnpgettext($domain, $context, $singular, $plural, $number); } function dcpgettext($domain, $context, $msgid, $category) { return _dcpgettext($domain, $context, $msgid, $category); } - function dcnpgettext($domain, $context, $single, $plural, + function dcnpgettext($domain, $context, $singular, $plural, $number, $category) { - return _dcnpgettext($domain, $context, $single, $plural, + return _dcnpgettext($domain, $context, $singular, $plural, $number, $category); } } diff --git a/classes/php-gettext/gettext.php b/classes/php-gettext/gettext.php index a121f9c7e7f..5064047cbd2 100644 --- a/classes/php-gettext/gettext.php +++ b/classes/php-gettext/gettext.php @@ -409,12 +409,23 @@ function ngettext($single, $plural, $number) { function pgettext($context, $msgid) { $key = $context . chr(4) . $msgid; - return $this->translate($key); + $ret = $this->translate($key); + if (strpos($ret, "\004") !== FALSE) { + return $msgid; + } else { + return $ret; + } } function npgettext($context, $singular, $plural, $number) { - $singular = $context . chr(4) . $singular; - return $this->ngettext($singular, $plural, $number); + $key = $context . chr(4) . $singular; + $ret = $this->ngettext($key, $plural, $number); + if (strpos($ret, "\004") !== FALSE) { + return $singular; + } else { + return $ret; + } + } }