Skip to content

Commit

Permalink
Dev Updated PHPGettext library to v1.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Mar 8, 2012
1 parent 95edc03 commit 0641eef
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 185 deletions.
144 changes: 0 additions & 144 deletions classes/php-gettext/ChangeLog

This file was deleted.

78 changes: 40 additions & 38 deletions classes/php-gettext/gettext.inc
Expand Up @@ -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')) {
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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));
}

/**
Expand All @@ -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));
}

/**
Expand All @@ -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));
}

/**
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}

Expand All @@ -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);
}
}
Expand Down
17 changes: 14 additions & 3 deletions classes/php-gettext/gettext.php
Expand Up @@ -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;
}

}
}

Expand Down

2 comments on commit 0641eef

@TMSWhite
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be ported to Yii?

@c-schmitz
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Please sign in to comment.