X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fngettext.php;h=bacd5929734fde89ec43707c27c1445739d89d79;hp=16ee62a14447ee04e6983abaf74d09d702363a25;hb=3fa09710c8488fa92f9be6ff66282b35cdaa538f;hpb=6c84ba1ec45ab854c37b6f65c5b4d84ab1c7aad4 diff --git a/functions/ngettext.php b/functions/ngettext.php index 16ee62a1..bacd5929 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); + } +}