I believe this code worked by chance, redefining it from string to array and
[squirrelmail.git] / functions / ngettext.php
1 <?php
2
3 /**
4 * SquirrelMail internal ngettext functions
5 *
6 * Uses php-gettext classes
7 *
8 * @link http://www.php.net/gettext Original php gettext manual
9 * @link http://savannah.nongnu.org/projects/php-gettext php-gettext classes
10 * @copyright 2004-2012 The SquirrelMail Project Team
11 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * @version $Id$
13 * @package squirrelmail
14 * @subpackage i18n
15 * @since 1.5.1
16 */
17
18 /**
19 * internal ngettext wrapper.
20 *
21 * provides ngettext support
22 * @since 1.5.1
23 * @link http://www.php.net/function.ngettext
24 * @param string $single English string, singular form
25 * @param string $plural English string, plural form
26 * @param integer $number number that shows used quantity
27 * @return string translated string
28 */
29 function ngettext($single, $plural, $number) {
30 global $l10n, $gettext_domain;
31 if (! isset($l10n[$gettext_domain]) ||
32 ! is_object($l10n[$gettext_domain]) ||
33 $l10n[$gettext_domain]->error==1)
34 return ($number==1 ? $single : $plural);
35 return $l10n[$gettext_domain]->ngettext($single, $plural, $number);
36 }
37
38 /**
39 * safety check.
40 * freaky setup where ngettext is not available and dngettext is available.
41 */
42 if (! function_exists('dngettext')) {
43 /**
44 * internal dngettext wrapper.
45 *
46 * provides dngettext support
47 * @since 1.5.1
48 * @link http://www.php.net/function.dngettext
49 * @param string $domain Gettext domain
50 * @param string $single English string, singular form
51 * @param string $plural English string, plural form
52 * @param integer $number number that shows used quantity
53 * @return string translated string
54 */
55 function dngettext($domain, $single, $plural, $number) {
56 global $l10n;
57 // Make sure that $number is integer
58 $number = (int) $number;
59
60 // Make sure that domain is initialized
61 if (! isset($l10n[$domain]) ||
62 ! is_object($l10n[$domain]) ||
63 $l10n[$domain]->error==1)
64 return ($number==1 ? $single : $plural);
65
66 // use ngettext class function
67 return $l10n[$domain]->ngettext($single, $plural, $number);
68 }
69 }