Add n().
authorJan Schneider <jan@horde.org>
Mon, 11 Oct 2010 13:23:20 +0000 (15:23 +0200)
committerJan Schneider <jan@horde.org>
Wed, 13 Oct 2010 00:30:03 +0000 (02:30 +0200)
framework/Translation/lib/Horde/Translation/Gettext.php

index 04637b5..355de11 100644 (file)
@@ -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);
+    }
 }