X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fngettext.php;h=4b2bf320d6afcb4949b4ea18e469469a9e40bba5;hb=10bf80c009d938fc0cf85a70d0a6b3834365b146;hp=c6368c83505b15eb31c7c0f9a4900870eb876156;hpb=845247962fd8b36263beec60e92541968f2cb434;p=squirrelmail.git diff --git a/functions/ngettext.php b/functions/ngettext.php index c6368c83..4b2bf320 100644 --- a/functions/ngettext.php +++ b/functions/ngettext.php @@ -1,16 +1,14 @@ error==1) return $single; + if (! isset($l10n[$gettext_domain]) || + ! is_object($l10n[$gettext_domain]) || + $l10n[$gettext_domain]->error==1) + return ($number==1 ? $single : $plural); return $l10n[$gettext_domain]->ngettext($single, $plural, $number); } + +/** + * safety check. + * freaky setup where ngettext is not available and dngettext is available. + */ +if (! function_exists('dngettext')) { + /** + * internal dngettext wrapper. + * + * provides dngettext support + * @since 1.5.1 + * @link http://www.php.net/function.dngettext + * @param string $domain Gettext domain + * @param string $single English string, singular form + * @param string $plural English string, plural form + * @param integer $number number that shows used quantity + * @return string translated string + */ + function dngettext($domain, $single, $plural, $number) { + global $l10n; + // Make sure that $number is integer + $number = (int) $number; + + // Make sure that domain is initialized + if (! isset($l10n[$domain]) || + ! is_object($l10n[$domain]) || + $l10n[$domain]->error==1) + return ($number==1 ? $single : $plural); + + // use ngettext class function + return $l10n[$domain]->ngettext($single, $plural, $number); + } +} ?> \ No newline at end of file