X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fngettext.php;h=1397b5be80d579d8e9d2f0ed15ce2fd916738e84;hp=c6368c83505b15eb31c7c0f9a4900870eb876156;hb=c4faef335b2362c81b8ebf026d4066c12d70536c;hpb=845247962fd8b36263beec60e92541968f2cb434 diff --git a/functions/ngettext.php b/functions/ngettext.php index c6368c83..1397b5be 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); + } +}