From 2f2ef3417712bbf2c0ce46c58c901ee84796655f Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Mon, 11 Oct 2010 15:23:20 +0200 Subject: [PATCH] Add n(). --- .../Translation/lib/Horde/Translation/Gettext.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/framework/Translation/lib/Horde/Translation/Gettext.php b/framework/Translation/lib/Horde/Translation/Gettext.php index 04637b513..355de1180 100644 --- a/framework/Translation/lib/Horde/Translation/Gettext.php +++ b/framework/Translation/lib/Horde/Translation/Gettext.php @@ -50,7 +50,7 @@ class Horde_Translation_Gettext implements Horde_Translation /** * Returns the translation of a message. * - * @var string $message The string to translate. + * @param string $message The string to translate. * * @return string The string translation, or the original string if no * translation exists. @@ -59,4 +59,21 @@ class Horde_Translation_Gettext implements Horde_Translation { return $this->_gettext ? dgettext($this->_domain, $message) : $message; } + + /** + * Returns the plural translation of a message. + * + * @param string $singular The singular version to translate. + * @param string $plural The plural version to translate. + * @param integer $number The number that determines singular vs. plural. + * + * @return string The string translation, or the original string if no + * translation exists. + */ + public function n($singular, $plural, $number) + { + return $this->_gettext + ? dngettext($this->_domain, $singular, $plural, $number) + : ($number == 1 ? $singular : $plural); + } } -- 2.11.0