From c050148df4b81eca3c0e1110b94a649e9b56f9b0 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 1 Apr 2013 19:17:25 +0400 Subject: =?UTF-8?q?fix=20broken=20header=20of=20ru=5FRU=20translation=20th?= =?UTF-8?q?anks=20to=20Tom=C3=A1=C5=A1=20Chv=C3=A1tal;=20rebase=20translat?= =?UTF-8?q?ions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/gettext/gettext.inc | 78 +++++++++++++++++++++++++------------------------ lib/gettext/gettext.php | 17 +++++++++-- 2 files changed, 54 insertions(+), 41 deletions(-) (limited to 'lib/gettext') diff --git a/lib/gettext/gettext.inc b/lib/gettext/gettext.inc index 399a0f24b..00b966692 100644 --- a/lib/gettext/gettext.inc +++ b/lib/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/lib/gettext/gettext.php b/lib/gettext/gettext.php index a121f9c7e..5064047cb 100755 --- a/lib/gettext/gettext.php +++ b/lib/gettext/gettext.php @@ -409,12 +409,23 @@ class gettext_reader { 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; + } + } } -- cgit v1.2.3