X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fngettext.php;h=8623b4d1336c01bcf68f70c64c626dcea3b618e0;hp=0c7279a0cd23d101be12f2b1f474564577c8a62e;hb=c88cef21db07eb9ab526ef3ab473a88ab4ef16a9;hpb=e50f5ac2682d655013d18d97f9a2aa30b7ed9485 diff --git a/functions/ngettext.php b/functions/ngettext.php index 0c7279a0..8623b4d1 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); } -?> \ No newline at end of file + +/** + * 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); + } +}