Use Horde_Translation to provide translations for framework packages.
authorJan Schneider <jan@horde.org>
Tue, 12 Oct 2010 17:00:07 +0000 (19:00 +0200)
committerJan Schneider <jan@horde.org>
Wed, 13 Oct 2010 00:34:40 +0000 (02:34 +0200)
167 files changed:
framework/Alarm/lib/Horde/Alarm/Handler.php
framework/Alarm/lib/Horde/Alarm/Handler/Desktop.php
framework/Alarm/lib/Horde/Alarm/Handler/Mail.php
framework/Alarm/lib/Horde/Alarm/Handler/Notify.php
framework/Argv/lib/Horde/Argv/AmbiguousOptionException.php
framework/Argv/lib/Horde/Argv/BadOptionException.php
framework/Argv/lib/Horde/Argv/HelpFormatter.php
framework/Argv/lib/Horde/Argv/IndentedHelpFormatter.php
framework/Argv/lib/Horde/Argv/Option.php
framework/Argv/lib/Horde/Argv/OptionException.php
framework/Argv/lib/Horde/Argv/Parser.php
framework/Argv/lib/Horde/Argv/TitledHelpFormatter.php
framework/Block/lib/Horde/Block.php
framework/Block/lib/Horde/Block/Collection.php
framework/Block/lib/Horde/Block/Layout.php
framework/Block/lib/Horde/Block/Layout/Manager.php
framework/Block/lib/Horde/Block/Layout/View.php
framework/Block/lib/Horde/Block/Ui.php
framework/Browser/lib/Horde/Browser.php
framework/Cli/lib/Horde/Cli.php
framework/Compress/lib/Horde/Compress.php
framework/Compress/lib/Horde/Compress/Dbx.php
framework/Compress/lib/Horde/Compress/Gzip.php
framework/Compress/lib/Horde/Compress/Rar.php
framework/Compress/lib/Horde/Compress/Tar.php
framework/Compress/lib/Horde/Compress/Zip.php
framework/Core/lib/Horde.php
framework/Core/lib/Horde/Core/Ajax/Application.php
framework/Core/lib/Horde/Core/Auth/Application.php
framework/Core/lib/Horde/Core/Auth/Signup/Base.php
framework/Core/lib/Horde/Core/Auth/Signup/Form.php
framework/Core/lib/Horde/Core/Auth/Signup/Sql.php
framework/Core/lib/Horde/Core/Factory/History.php
framework/Core/lib/Horde/Core/Factory/Prefs.php
framework/Core/lib/Horde/Core/Factory/Share.php
framework/Core/lib/Horde/Core/Factory/Twitter.php
framework/Core/lib/Horde/Core/Factory/Vfs.php
framework/Core/lib/Horde/Core/Mime/Viewer/Vcard.php
framework/Core/lib/Horde/Core/Notification/Status.php
framework/Core/lib/Horde/Core/Perms/Ui.php
framework/Core/lib/Horde/Core/Prefs/Identity.php
framework/Core/lib/Horde/Core/Prefs/Ui.php
framework/Core/lib/Horde/Core/Prefs/Ui/Widgets.php
framework/Core/lib/Horde/Core/Sidebar.php
framework/Core/lib/Horde/Core/Text/Filter/Highlightquotes.php
framework/Core/lib/Horde/Core/Ui/JsCalendar.php
framework/Core/lib/Horde/Core/Ui/Pager.php
framework/Core/lib/Horde/Core/Ui/VarRenderer/Html.php
framework/Core/lib/Horde/Core/Ui/VarRenderer/TablesetHtml.php
framework/Core/lib/Horde/Help.php
framework/Core/lib/Horde/Menu.php
framework/Core/lib/Horde/Registry.php
framework/Core/lib/Horde/Script/Files.php
framework/Crypt/lib/Horde/Crypt.php
framework/Crypt/lib/Horde/Crypt/Pgp.php
framework/Crypt/lib/Horde/Crypt/Smime.php
framework/Data/lib/Horde/Data/Base.php
framework/Data/lib/Horde/Data/Tsv.php
framework/DataTree/DataTree.php
framework/DataTree/DataTree/sql.php
framework/Date/lib/Horde/Date/Recurrence.php
framework/Date/lib/Horde/Date/Utils.php
framework/Exception/lib/Horde/Exception/NotFound.php
framework/Exception/lib/Horde/Exception/PermissionDenied.php
framework/File_Csv/lib/Horde/File/Csv.php
framework/Form/Form.php
framework/Form/Form/Renderer.php
framework/Form/Form/Type.php
framework/Form/Form/Type/tableset.php
framework/Form/Form/Variable.php
framework/Icalendar/lib/Horde/Icalendar/Vevent.php
framework/Image/lib/Horde/Image/Exif.php
framework/Image/lib/Horde/Image/Exif/Base.php
framework/Image/lib/Horde/Image/Exif/Bundled.php
framework/Image/lib/Horde/Image/Exif/Parser/Base.php
framework/Image/lib/Horde/Image/Exif/Parser/Canon.php
framework/Image/lib/Horde/Image/Exif/Parser/Fujifilm.php
framework/Image/lib/Horde/Image/Exif/Parser/Nikon.php
framework/Image/lib/Horde/Image/Exif/Parser/Olympus.php
framework/Image/lib/Horde/Image/Exif/Parser/Panasonic.php
framework/Image/lib/Horde/Image/Exif/Parser/Sanyo.php
framework/Itip/lib/Horde/Itip/Event/Vevent.php
framework/Itip/lib/Horde/Itip/Response/Type/Accept.php
framework/Itip/lib/Horde/Itip/Response/Type/Base.php
framework/Itip/lib/Horde/Itip/Response/Type/Decline.php
framework/Itip/lib/Horde/Itip/Response/Type/Tentative.php
framework/Kolab/Kolab.php
framework/Kolab_Filter/lib/Horde/Kolab/Filter/Content.php
framework/Kolab_Format/lib/Horde/Kolab/Format.php
framework/Kolab_Format/lib/Horde/Kolab/Format/Xml.php
framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Driver/Base.php
framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Driver/Freebusy/Base.php
framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Driver/Freebusy/Kolab.php
framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Imap.php
framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/Report.php
framework/Kolab_FreeBusy/lib/Horde/Kolab/FreeBusy/View.php
framework/Kolab_Resource/lib/Horde/Kolab/Resource.php
framework/Kolab_Storage/lib/Horde/Kolab/Storage/Data.php
framework/LoginTasks/lib/Horde/LoginTasks.php
framework/Mime/lib/Horde/Mime/Headers.php
framework/Mime/lib/Horde/Mime/Mail.php
framework/Mime/lib/Horde/Mime/Mdn.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Base.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Msword.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Rar.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Rfc822.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Rtf.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Tgz.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Wordperfect.php
framework/Mime_Viewer/lib/Horde/Mime/Viewer/Zip.php
framework/Model/lib/Horde/Form.php
framework/Model/lib/Horde/Form/Renderer.php
framework/Model/lib/Horde/Form/Renderer/Xhtml.php
framework/Model/lib/Horde/Form/Type.php
framework/Model/lib/Horde/Form/Type/Color.php
framework/Model/lib/Horde/Form/Type/CreditCard.php
framework/Model/lib/Horde/Form/Type/Date.php
framework/Model/lib/Horde/Form/Type/Email.php
framework/Model/lib/Horde/Form/Type/Enum.php
framework/Model/lib/Horde/Form/Type/Int.php
framework/Model/lib/Horde/Form/Type/Number.php
framework/Model/lib/Horde/Form/Type/Octal.php
framework/Model/lib/Horde/Form/Type/Password.php
framework/Model/lib/Horde/Form/Type/Phone.php
framework/Model/lib/Horde/Form/Type/Set.php
framework/Model/lib/Horde/Form/Type/String.php
framework/Model/lib/Horde/Form/Type/Time.php
framework/Model/lib/Horde/Form/VarRenderer/Xhtml.php
framework/Net_IMSP/IMSP.php
framework/Net_IMSP/IMSP/Auth.php
framework/Net_IMSP/IMSP/Book.php
framework/Nls/lib/Horde/Nls/Countries.php
framework/Nls/lib/Horde/Nls/Geoip.php
framework/Nls/lib/Horde/Nls/Tld.php
framework/Perms/lib/Horde/Perms.php
framework/Prefs/lib/Horde/Prefs.php
framework/Prefs/lib/Horde/Prefs/CategoryManager.php
framework/Prefs/lib/Horde/Prefs/Identity.php
framework/Prefs/lib/Horde/Prefs/Ldap.php
framework/Rpc/lib/Horde/Rpc.php
framework/Rpc/lib/Horde/Rpc/Phpgw.php
framework/Rpc/lib/Horde/Rpc/Soap.php
framework/Rpc/lib/Horde/Rpc/Webdav.php
framework/Service_Facebook/lib/Horde/Service/Facebook/Request.php
framework/Service_Facebook/lib/Horde/Service/Facebook/UploadRequest.php
framework/Service_Scribd/lib/Horde/Block/Scribd.php
framework/Share/lib/Horde/Share.php
framework/Share/lib/Horde/Share/Kolab.php
framework/Share/lib/Horde/Share/Object/Kolab.php
framework/Share/lib/Horde/Share/Sql.php
framework/Share/lib/Horde/Share/Sql/Hierarchical.php
framework/SyncML/SyncML/Backend.php
framework/SyncML/SyncML/Device/Sync4j.php
framework/Template/lib/Horde/Template.php
framework/Text_Filter/lib/Horde/Text/Filter/Base.php
framework/Text_Filter/lib/Horde/Text/Filter/Html2text.php
framework/VFS/lib/VFS.php
framework/VFS/lib/VFS/smb.php
framework/VFS/lib/VFS/sql_file.php
framework/VFS_ISOWriter/ISOWriter.php
framework/VFS_ISOWriter/ISOWriter/RealInputStrategy.php
framework/VFS_ISOWriter/ISOWriter/RealInputStrategy/copy.php
framework/VFS_ISOWriter/ISOWriter/RealOutputStrategy.php
framework/VFS_ISOWriter/ISOWriter/RealOutputStrategy/copy.php
framework/VFS_ISOWriter/ISOWriter/RealOutputStrategy/direct.php
framework/VFS_ISOWriter/ISOWriter/mkisofs.php
framework/admintools/horde-remove-pref.php

index 7e7a5ca..8dafdca 100644 (file)
@@ -25,11 +25,25 @@ abstract class Horde_Alarm_Handler
     public $alarm;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor.
      *
      * @param array $params  Any parameters that the handler might need.
      */
-    abstract public function __construct(array $params = null);
+    public function __construct(array $params = null)
+    {
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Alarm', dirname(__FILE__) . '/../../../locale');
+        }
+    }
 
     /**
      * Notifies about an alarm.
index b8c12b9..8198ab4 100644 (file)
@@ -43,6 +43,7 @@ class Horde_Alarm_Handler_Desktop extends Horde_Alarm_Handler
      */
     public function __construct(array $params = null)
     {
+        parent::__construct($params);
         /*
         if (!isset($params['js_notify'])) {
             throw new InvalidArgumentException('Parameter \'js_notify\' missing.');
@@ -82,6 +83,6 @@ class Horde_Alarm_Handler_Desktop extends Horde_Alarm_Handler
      */
     public function getDescription()
     {
-        return _("Desktop notification (with certain browsers)");
+        return $this->_dict->t("Desktop notification (with certain browsers)");
     }
 }
index dc5da33..c35ee65 100644 (file)
@@ -42,6 +42,8 @@ class Horde_Alarm_Handler_Mail extends Horde_Alarm_Handler
      */
     public function __construct(array $params = null)
     {
+        parent::__construct($params);
+
         foreach (array('identity', 'mail') as $param) {
             if (!isset($params[$param])) {
                 throw new Horde_Alarm_Exception('Parameter \'' . $param . '\' missing.');
@@ -113,7 +115,7 @@ class Horde_Alarm_Handler_Mail extends Horde_Alarm_Handler
      */
     public function getDescription()
     {
-        return _("Email");
+        return $this->_dict->t("Email");
     }
 
     /**
@@ -133,7 +135,7 @@ class Horde_Alarm_Handler_Mail extends Horde_Alarm_Handler
         return array(
             'email' => array(
                 'type' => 'text',
-                'desc' => _("Email address (optional)"),
+                'desc' => $this->_dict->t("Email address (optional)"),
                 'required' => false));
     }
 }
index f3ac2c7..90cd4ba 100644 (file)
@@ -41,6 +41,8 @@ class Horde_Alarm_Handler_Notify extends Horde_Alarm_Handler
      */
     public function __construct(array $params = null)
     {
+        parent::__construct($params);
+
         /*
         if (!isset($params['notification'])) {
             throw new Horde_Alarm_Exception('Parameter \'notification\' missing.');
@@ -76,7 +78,7 @@ class Horde_Alarm_Handler_Notify extends Horde_Alarm_Handler
      */
     public function getDescription()
     {
-        return _("Inline");
+        return $this->_dict->t("Inline");
     }
 
     /**
@@ -96,7 +98,7 @@ class Horde_Alarm_Handler_Notify extends Horde_Alarm_Handler
         return array(
             'sound' => array(
                 'type' => 'sound',
-                'desc' => _("Play a sound?"),
+                'desc' => $this->_dict->t("Play a sound?"),
                 'required' => false));
     }
 }
index ccfbd64..465b7a8 100644 (file)
@@ -18,7 +18,7 @@ class Horde_Argv_AmbiguousOptionException extends Horde_Argv_BadOptionException
     public function __construct($opt_str, $possibilities)
     {
         // Have to skip the BadOptionException constructor or the string gets double-prefixed.
-        Horde_Argv_OptionException::__construct(sprintf(_("ambiguous option: %s (%s?)"), $opt_str, implode(', ', $possibilities)));
+        Horde_Argv_OptionException::__construct(sprintf('ambiguous option: %s (%s?)', $opt_str, implode(', ', $possibilities)));
     }
 
 }
index 56783f4..319ad37 100644 (file)
@@ -17,7 +17,7 @@ class Horde_Argv_BadOptionException extends Horde_Argv_OptionException
 {
     public function __construct($opt_str)
     {
-        parent::__construct(sprintf(_("no such option: %s"), $opt_str));
+        parent::__construct(sprintf('no such option: %s', $opt_str));
     }
 
 }
index 1c55468..772d9a7 100644 (file)
@@ -61,8 +61,23 @@ abstract class Horde_Argv_HelpFormatter
 
     public $parser = null;
 
-    public function __construct($indent_increment, $max_help_position, $width = null, $short_first = false)
+    /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    public function __construct($indent_increment, $max_help_position,
+                                $width = null, $short_first = false,
+                                $dict = null)
     {
+        if ($dict) {
+            $this->_dict = $dict;
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Argv', dirname(__FILE__) . '/../../../locale');
+        }
+
         $this->indent_increment = $indent_increment;
         $this->help_position = $this->max_help_position = $max_help_position;
         if (is_null($width)) {
index 42f09b5..bff6815 100644 (file)
@@ -26,7 +26,7 @@ class Horde_Argv_IndentedHelpFormatter extends Horde_Argv_HelpFormatter
 
     public function formatUsage($usage)
     {
-        return sprintf(_("Usage:") . " %s\n", $usage);
+        return sprintf($this->_dict->t("Usage:") . " %s\n", $usage);
     }
 
     public function formatHeading($heading)
index 1e6e709..85dc9ed 100644 (file)
@@ -40,6 +40,13 @@ class Horde_Argv_Option
      */
     public static $NO_DEFAULT = array('NO', 'DEFAULT');
 
+    /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
     public static function parseNumber($value)
     {
         if (!strlen($value)) {
@@ -91,8 +98,8 @@ class Horde_Argv_Option
             $number = self::parseNumber($value);
             if ($number === false) {
                 $message = $this->type == 'int'
-                    ? _("option %s: invalid integer value: '%s'")
-                    : _("option %s: invalid long integer value: '%s'");
+                    ? $this->_dict->t("option %s: invalid integer value: '%s'")
+                    : $this->_dict->t("option %s: invalid long integer value: '%s'");
                 throw new Horde_Argv_OptionValueException(
                     sprintf($message, $opt, $value));
             }
@@ -101,7 +108,7 @@ class Horde_Argv_Option
         case 'float':
             if (!is_numeric($value)) {
                 throw new Horde_Argv_OptionValueException(
-                    sprintf(_("option %s: invalid floating-point value: '%s'"),
+                    sprintf($this->_dict->t("option %s: invalid floating-point value: '%s'"),
                             $opt, $value));
             }
             return floatval($value);
@@ -119,7 +126,7 @@ class Horde_Argv_Option
             }
             $choices = "'" . implode("', '", $choices) . "'";
             throw new Horde_Argv_OptionValueException(sprintf(
-                _("option %s: invalid choice: '%s' (choose from %s)"),
+                $this->_dict->t("option %s: invalid choice: '%s' (choose from %s)"),
                 $opt, $value, $choices));
         }
     }
@@ -247,8 +254,13 @@ class Horde_Argv_Option
     public $dest;
     public $default;
 
+    /**
+     * Constructor.
+     */
     public function __construct()
     {
+        $this->_dict = new Horde_Translation_Gettext('Horde_Argv', dirname(__FILE__) . '/../../../locale');
+
         // The last argument to this function is an $attrs hash, if it
         // is present and an array. All other arguments are $opts.
         $opts = func_get_args();
@@ -279,6 +291,17 @@ class Horde_Argv_Option
         }
     }
 
+    /**
+     * Passes a translation handler.
+     *
+     * @param Horde_Translation $dict  A translation handler implementing
+     *                                 Horde_Translation.
+     */
+    public function setDictionary($dict)
+    {
+        $this->_dict = $dict;
+    }
+
     protected function _checkOptStrings($opts)
     {
         // Filter out None because early versions of Optik had exactly
index 4d1516c..1e77c4c 100644 (file)
@@ -20,7 +20,7 @@ class Horde_Argv_OptionException extends Horde_Argv_Exception
     {
         $this->optionId = (string)$option;
         if ($this->optionId) {
-            parent::__construct(sprintf(_("option %s: %s"), $this->optionId, $msg));
+            parent::__construct(sprintf('option %s: %s', $this->optionId, $msg));
         } else {
             parent::__construct($msg);
         }
index f4dfffe..149a45c 100644 (file)
@@ -77,8 +77,21 @@ class Horde_Argv_Parser extends Horde_Argv_OptionContainer
     protected $_usage;
     public $optionGroups = array();
 
+    /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
     public function __construct($args = array())
     {
+        if (isset($args['translation'])) {
+            $this->_dict = $args['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Argv', dirname(__FILE__) . '/../../../locale');
+        }
+
         $args = array_merge(array(
             'usage' => null,
             'optionList' => null,
@@ -149,13 +162,13 @@ class Horde_Argv_Parser extends Horde_Argv_OptionContainer
     protected function _addHelpOption()
     {
         $this->addOption('-h', '--help', array('action' => 'help',
-                                               'help' => _("show this help message and exit")));
+                                               'help' => $this->_dict->t("show this help message and exit")));
     }
 
     protected function _addVersionOption()
     {
         $this->addOption('--version', array('action' => 'version',
-                                            'help' => _("show program's version number and exit")));
+                                            'help' => $this->_dict->t("show program's version number and exit")));
     }
 
     protected function _populateOptionList($optionList, $add_help = true)
@@ -183,7 +196,7 @@ class Horde_Argv_Parser extends Horde_Argv_OptionContainer
     public function setUsage($usage)
     {
         if (is_null($usage))
-            $this->_usage = '%prog ' . _("[options]");
+            $this->_usage = '%prog ' . $this->_dict->t("[options]");
         elseif ($usage == Horde_Argv_Option::SUPPRESS_USAGE)
             $this->_usage = null;
         else
@@ -479,9 +492,9 @@ class Horde_Argv_Parser extends Horde_Argv_OptionContainer
             if (count($rargs) < $nargs) {
                 if (!$option->hasDefault()) {
                     if ($nargs == 1) {
-                        $this->parserError(sprintf(_("%s option requires an argument"), $opt));
+                        $this->parserError(sprintf($this->_dict->t("%s option requires an argument"), $opt));
                     } else {
-                        $this->parserError(sprintf(_("%s option requires %d arguments"), $opt, $nargs));
+                        $this->parserError(sprintf($this->_dict->t("%s option requires %d arguments"), $opt, $nargs));
                     }
                 }
             } elseif ($nargs == 1) {
@@ -491,7 +504,7 @@ class Horde_Argv_Parser extends Horde_Argv_OptionContainer
             }
 
         } elseif ($had_explicit_value) {
-            $this->parserError(sprintf(_("%s option does not take a value"), $opt));
+            $this->parserError(sprintf($this->_dict->t("%s option does not take a value"), $opt));
 
         } else {
             $value = null;
@@ -531,9 +544,9 @@ class Horde_Argv_Parser extends Horde_Argv_OptionContainer
                 if (count($rargs) < $nargs) {
                     if (!$option->hasDefault()) {
                         if ($nargs == 1) {
-                            $this->parserError(sprintf(_("%s option requires an argument"), $opt));
+                            $this->parserError(sprintf($this->_dict->t("%s option requires an argument"), $opt));
                         } else {
-                            $this->parserError(sprintf(_("%s option requires %d arguments"), $opt, $nargs));
+                            $this->parserError(sprintf($this->_dict->t("%s option requires %d arguments"), $opt, $nargs));
                         }
                     }
                 } elseif ($nargs == 1) {
@@ -656,7 +669,7 @@ class Horde_Argv_Parser extends Horde_Argv_OptionContainer
             $formatter = $this->formatter;
         $formatter->storeOptionStrings($this);
         $result = array();
-        $result[] = $formatter->formatHeading(_("Options"));
+        $result[] = $formatter->formatHeading($this->_dict->t("Options"));
         $formatter->indent();
         if ($this->optionList) {
             $result[] = parent::formatOptionHelp($formatter);
index 6fcf72a..800fafb 100644 (file)
@@ -26,7 +26,7 @@ class Horde_Argv_TitledHelpFormatter extends Horde_Argv_HelpFormatter
 
     public function formatUsage($usage)
     {
-        return sprintf("%s  %s\n", $this->formatHeading(_("Usage")), $usage);
+        return sprintf("%s  %s\n", $this->formatHeading($this->_dict->t("Usage")), $usage);
     }
 
     public function formatHeading($heading)
index fcaf444..006002f 100644 (file)
@@ -51,15 +51,31 @@ class Horde_Block
     protected $_app;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor.
      *
      * @param array|boolean $params  Any parameters the block needs. If false,
      *                               the default parameter will be used.
      * @param integer $row           The block row.
      * @param integer $col           The block column.
+     * @param Horde_Translation $dict  A translation handler implementing
+     *                                 Horde_Translation.
      */
-    public function __construct($params = array(), $row = null, $col = null)
+    public function __construct($params = array(), $row = null, $col = null,
+                                $dict = null)
     {
+        if ($dict) {
+            $this->_dict = $dict;
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Block', dirname(__FILE__) . '/../../locale');
+        }
+
         // @todo: we can't simply merge the default values and stored values
         // because empty parameter values are not stored at all, so they would
         // always be overwritten by the defaults.
index 9e6b1f4..d958e3f 100644 (file)
@@ -38,6 +38,13 @@ class Horde_Block_Collection
     protected $_blocks = array();
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Returns a single instance of the Horde_Blocks class.
      *
      * @param array $apps  The applications whose blocks to list.
@@ -59,12 +66,20 @@ class Horde_Block_Collection
     /**
      * Constructor.
      *
-     * @param array $apps  The applications whose blocks to list.
+     * @param array $apps              The applications whose blocks to list.
+     * @param Horde_Translation $dict  A translation handler implementing
+     *                                 Horde_Translation.
      */
-    public function __construct($apps = array())
+    public function __construct($apps = array(), $dict = null)
     {
         global $session;
 
+        if ($dict) {
+            $this->_dict = $dict;
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Block', dirname(__FILE__) . '/../../../locale');
+        }
+
         $signature = serialize($apps);
         if ($this->_blocks = $session['horde:blocks/' . $signature]) {
             return;
@@ -393,7 +408,7 @@ class Horde_Block_Collection
     {
         return isset($this->_blocks[$app][$block])
             ? $this->_blocks[$app][$block]['name']
-            : sprintf(_("Block \"%s\" of application \"%s\" not found."), $block, $app);
+            : sprintf($this->_dict->t("Block \"%s\" of application \"%s\" not found."), $block, $app);
     }
 
     /**
index 963d8e7..2303a66 100644 (file)
@@ -31,6 +31,29 @@ class Horde_Block_Layout
     protected $_viewUrl;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
+     * Constructor.
+     *
+     * @param array $params  Hash with configuration data. Possible values:
+     *                       - 'translation': A translation handler
+     *                                        implementing Horde_Translation.
+     */
+    public function __construct($params = array())
+    {
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Block', dirname(__FILE__) . '/../../../locale');
+        }
+    }
+
+    /**
      * Returns whether the specified block may be removed.
      *
      * @param integer $row  A layout row.
@@ -104,17 +127,17 @@ class Horde_Block_Layout
         $icons = '';
         if ($edit) {
             $icons .= Horde::link($this->getActionUrl('edit', $row, $col),
-                                  _("Edit"))
-                . Horde::img('edit.png', _("Edit"))
+                                  $this->_dict->t("Edit"))
+                . Horde::img('edit.png', $this->_dict->t("Edit"))
                 . '</a>';
         }
         if ($this->isRemovable($row, $col)) {
             $icons .= Horde::link(
-                $this->getActionUrl('removeBlock', $row, $col), _("Remove"),
+                $this->getActionUrl('removeBlock', $row, $col), $this->_dict->t("Remove"),
                 '', '',
                 'return window.confirm(\''
-                . addslashes(_("Really delete this block?")) . '\')')
-                . Horde::img('delete.png', _("Remove"))
+                . addslashes($this->_dict->t("Really delete this block?")) . '\')')
+                . Horde::img('delete.png', $this->_dict->t("Remove"))
                 . '</a>';
         }
         return $icons;
index fc97da6..2b16825 100644 (file)
@@ -118,7 +118,7 @@ class Horde_Block_Layout_Manager extends Horde_Block_Layout
             }
             for ($col = 0; $col < $cols; $col++) {
                 if (!isset($this->_layout[$row][$col])) {
-                    $this->_blocks[$row][$col] = PEAR::raiseError(_("No block exists at the requested position"), 'horde.error');
+                    $this->_blocks[$row][$col] = PEAR::raiseError($this->_dict->t("No block exists at the requested position"), 'horde.error');
                 } elseif (is_array($this->_layout[$row][$col])) {
                     $field = $this->_layout[$row][$col];
 
@@ -242,7 +242,7 @@ class Horde_Block_Layout_Manager extends Horde_Block_Layout
                     try {
                         $message = Horde::callHook('perms_denied', array('horde:max_blocks'));
                     } catch (Horde_Exception_HookNotSet $e) {
-                        $message = htmlspecialchars(sprintf(ngettext("You are not allowed to create more than %d block.", "You are not allowed to create more than %d blocks.", $max_blocks), $max_blocks));
+                        $message = htmlspecialchars(sprintf($this->_dict->n("You are not allowed to create more than %d block.", "You are not allowed to create more than %d blocks.", $max_blocks), $max_blocks));
                     }
                     $GLOBALS['notification']->push($message, 'horde.error', array('content.raw'));
                     break;
@@ -573,12 +573,12 @@ class Horde_Block_Layout_Manager extends Horde_Block_Layout
 
         switch ($type[0]) {
         case 'expand':
-            $title = _("Expand");
+            $title = $this->_dict->t("Expand");
             $img = 'large_' . $type[1];
             break;
 
         case 'shrink':
-            $title = _("Shrink");
+            $title = $this->_dict->t("Shrink");
             $img = 'large_';
 
             switch ($type[1]) {
@@ -603,19 +603,19 @@ class Horde_Block_Layout_Manager extends Horde_Block_Layout
         case 'move':
             switch ($type[1]) {
             case 'up':
-                $title = _("Move Up");
+                $title = $this->_dict->t("Move Up");
                 break;
 
             case 'down':
-                $title = _("Move Down");
+                $title = $this->_dict->t("Move Down");
                 break;
 
             case 'left':
-                $title = _("Move Left");
+                $title = $this->_dict->t("Move Left");
                 break;
 
             case 'right':
-                $title = _("Move Right");
+                $title = $this->_dict->t("Move Right");
                 break;
             }
 
index ef9f834..3dc51b9 100644 (file)
@@ -95,7 +95,7 @@ class Horde_Block_Layout_View extends Horde_Block_Layout
                             $html .= '<td width="' . ($width * $colspan) . '%">&nbsp;</td>';
                         }
                     } catch (Horde_Exception $e) {
-                        $header = _("Error");
+                        $header = $this->_dict->t("Error");
                         $content = $e->getMessage();
                         ob_start();
                         include $tplDir . '/portal/block.inc';
index c6caf14..6f9e0e8 100644 (file)
@@ -35,10 +35,26 @@ class Horde_Block_UI
     protected $_vars = null;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor.
+     *
+     * @param array $params  Hash with configuration data. Possible values:
+     *                       - 'translation': A translation handler
+     *                                        implementing Horde_Translation.
      */
-    public function __construct()
+    public function __construct($params = array())
     {
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Block', dirname(__FILE__) . '/../../../locale');
+        }
         $this->_blocks = Horde_Block_Collection::singleton();
     }
 
@@ -70,7 +86,7 @@ class Horde_Block_UI
 
         if (!($this->_form instanceof Horde_Form)) {
             /* No existing valid form object set so set up a new one. */
-            $this->setForm(new Horde_Form($this->_vars, _("Edit Block")));
+            $this->setForm(new Horde_Form($this->_vars, $this->_dict->t("Edit Block")));
         }
 
         /* Get the current value of the block selection. */
@@ -78,7 +94,7 @@ class Horde_Block_UI
 
         /* Field to select apps. */
         $apps = $this->_blocks->getBlocksList();
-        $v = $this->_form->addVariable(_("Application"), $field . '[app]', 'enum', true, false, null, array($apps));
+        $v = $this->_form->addVariable($this->_dict->t("Application"), $field . '[app]', 'enum', true, false, null, array($apps));
         $v->setOption('trackchange', true);
 
         if (empty($value['app'])) {
index d5f6520..e25094e 100644 (file)
@@ -1005,7 +1005,7 @@ class Horde_Browser
     public function wasFileUploaded($field, $name = null)
     {
         if (is_null($name)) {
-            $name = _("file");
+            $name = 'file';
         }
 
         if (!($uploadSize = self::allowFileUploads())) {
index 978f7f6..219b089 100644 (file)
@@ -119,13 +119,29 @@ class Horde_Cli
     );
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Detect the current environment (web server or console) and sets
      * internal values accordingly.
      *
      * The constructor must not be called after init().
+     *
+     * @param Horde_Translation $dict  A translation handler implementing
+     *                                 Horde_Translation.
      */
-    public function __construct()
+    public function __construct($dict = null)
     {
+        if ($dict) {
+            $this->_dict = $dict;
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Cli', dirname(__FILE__) . '/../../locale');
+        }
+
         $this->_console = $this->runningFromCLI();
 
         if ($this->_console) {
@@ -319,7 +335,7 @@ class Horde_Cli
         }
         $this->writeln($this->red('===================='));
         $this->writeln();
-        $this->writeln($this->red(_("Fatal Error:")));
+        $this->writeln($this->red($this->_dict->t("Fatal Error:")));
         $this->writeln($this->red($error));
         $this->writeln();
         $this->writeln((string)$backtrace);
@@ -353,7 +369,7 @@ class Horde_Cli
                 foreach ($choices as $key => $choice) {
                     $this->writeln($this->indent('(' . $this->bold($key) . ') ' . $choice));
                 }
-                $this->writeln(_("Type your choice: "), true);
+                $this->writeln($this->_dict->t("Type your choice: "), true);
                 @ob_flush();
 
                 // Get the user choice.
@@ -364,7 +380,7 @@ class Horde_Cli
                 if (isset($choices[$response])) {
                     return $response;
                 } else {
-                    $this->writeln($this->red(sprintf(_("\"%s\" is not a valid choice."), $response)));
+                    $this->writeln($this->red(sprintf($this->_dict->t("\"%s\" is not a valid choice."), $response)));
                 }
             } else {
                 @ob_flush();
index c76ab87..eb97457 100644 (file)
 class Horde_Compress
 {
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Attempts to return a concrete instance based on $driver.
      *
      * @param mixed $driver  The type of concrete subclass to
@@ -45,6 +52,21 @@ class Horde_Compress
     }
 
     /**
+     * Constructor.
+     *
+     * @param Horde_Translation $dict  A translation handler implementing
+     *                                 Horde_Translation.
+     */
+    public function __construct($dict = null)
+    {
+        if ($dict) {
+            $this->_dict = $dict;
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Compress', dirname(__FILE__) . '/../../locale');
+        }
+    }
+
+    /**
      * Compress the data.
      *
      * @param string $data   The data to compress.
index e583878..04fd0be 100644 (file)
@@ -125,7 +125,7 @@ class Horde_Compress_Dbx extends Horde_Compress
                     }
                     $msg_item = unpack('LFilePos/LUnknown/LItemSize/LNextItem/a512Content', $s);
                     if ($msg_item['FilePos'] != $position) {
-                        throw new Horde_Exception(_("Invalid file format"));
+                        throw new Horde_Exception($this->_dict->t("Invalid file format"));
                     }
                     $position += 528;
                     $msg .= substr($msg_item['Content'], 0, $msg_item['ItemSize']);
@@ -154,7 +154,7 @@ class Horde_Compress_Dbx extends Horde_Compress
         $message_info = array();
         $msg_header = unpack('Lposition/LDataLength/SHeaderLength/SFlagCount', substr($data, $position, 12));
         if ($msg_header['position'] != $position) {
-            throw new Horde_Exception(_("Invalid file format"));
+            throw new Horde_Exception($this->_dict->t("Invalid file format"));
         }
         $position += 12;
         $message_info['HeaderPosition'] = $msg_header['position'];
@@ -235,7 +235,7 @@ class Horde_Compress_Dbx extends Horde_Compress
     {
         $index_header = unpack('LFilePos/LUnknown1/LPrevIndex/LNextIndex/LCount/LUnknown', substr($data, $position, 24));
         if ($index_header['FilePos'] != $position) {
-            throw new Horde_Exception(_("Invalid file format"));
+            throw new Horde_Exception($this->_dict->t("Invalid file format"));
         }
 
         // Push it into list of processed items.
index c3f4d7f..1a1ff65 100644 (file)
@@ -39,14 +39,14 @@ class Horde_Compress_Gzip extends Horde_Compress
     {
         /* If gzip is not compiled into PHP, return now. */
         if (!Horde_Util::extensionExists('zlib')) {
-            throw new Horde_Exception(_("This server can't uncompress gzip files."));
+            throw new Horde_Exception($this->_dict->t("This server can't uncompress gzip files."));
         }
 
         /* Gzipped File - decompress it first. */
         $position = 0;
         $info = @unpack('CCM/CFLG/VTime/CXFL/COS', substr($data, $position + 2));
         if (!$info) {
-            throw new Horde_Exception(_("Unable to decompress data."));
+            throw new Horde_Exception($this->_dict->t("Unable to decompress data."));
         }
         $position += 10;
 
@@ -76,7 +76,7 @@ class Horde_Compress_Gzip extends Horde_Compress
 
         $result = @gzinflate(substr($data, $position, strlen($data) - $position));
         if (empty($result)) {
-            throw new Horde_Exception(_("Unable to decompress data."));
+            throw new Horde_Exception($this->_dict->t("Unable to decompress data."));
         }
 
         return $result;
index 977d3e1..80611b8 100644 (file)
@@ -51,7 +51,7 @@ class Horde_Compress_Rar extends Horde_Compress
     {
         $blockStart = strpos($data, "\x52\x61\x72\x21\x1a\x07\x00");
         if ($blockStart === false) {
-            throw new Horde_Exception(_("Invalid RAR data."));
+            throw new Horde_Exception($this->_dict->t("Invalid RAR data."));
         }
 
         $data_len = strlen($data);
index 1bb866d..edb1306 100644 (file)
@@ -71,7 +71,7 @@ class Horde_Compress_Tar extends Horde_Compress
         while ($position < $data_len) {
             $info = @unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/Ctypeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor", substr($data, $position));
             if (!$info) {
-                throw new Horde_Exception(_("Unable to decompress data."));
+                throw new Horde_Exception($this->_dict->t("Unable to decompress data."));
             }
 
             $position += 512;
index 9391acc..18c4b28 100644 (file)
@@ -90,7 +90,7 @@ class Horde_Compress_Zip extends Horde_Compress
     public function compress($data, $params = array())
     {
         if (!Horde_Util::extensionExists('zlib')) {
-            throw new Horde_Exception(_("This server can't compress zip files."));
+            throw new Horde_Exception($this->_dict->t("This server can't compress zip files."));
         }
 
         $this->_ctrldir = array();
@@ -194,7 +194,7 @@ class Horde_Compress_Zip extends Horde_Compress
 
         do {
             if (strlen($data) < $fhStart + 31) {
-                throw new Horde_Exception(_("Invalid ZIP data"));
+                throw new Horde_Exception($this->_dict->t("Invalid ZIP data"));
             }
             $info = unpack('vMethod/VTime/VCRC32/VCompressed/VUncompressed/vLength', substr($data, $fhStart + 10, 20));
             $name = substr($data, $fhStart + 46, $info['Length']);
@@ -221,7 +221,7 @@ class Horde_Compress_Zip extends Horde_Compress
                        ((($info['Time'] >> 25) & 0x7f) + 1980));
 
             if (strlen($data) < $fhStart + 43) {
-                throw new Horde_Exception(_("Invalid ZIP data"));
+                throw new Horde_Exception($this->_dict->t("Invalid ZIP data"));
             }
             $info = unpack('vInternal/VExternal', substr($data, $fhStart + 36, 6));
 
@@ -241,7 +241,7 @@ class Horde_Compress_Zip extends Horde_Compress
 
         do {
             if ($data_len < $fhStart + 34) {
-                throw new Horde_Exception(_("Invalid ZIP data"));
+                throw new Horde_Exception($this->_dict->t("Invalid ZIP data"));
             }
             $info = unpack('vMethod/VTime/VCRC32/VCompressed/VUncompressed/vLength/vExtraLength', substr($data, $fhStart + 8, 25));
             $name = substr($data, $fhStart + 30, $info['Length']);
index 6b31896..ab5cbc9 100644 (file)
@@ -104,8 +104,9 @@ class Horde
     {
         $admin = $GLOBALS['registry']->isAdmin();
         $cli = Horde_Cli::runningFromCLI();
+        $dict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../locale');
 
-        $errortext = '<h1>' . _("A fatal error has occurred") . '</h1>';
+        $errortext = '<h1>' . $dict->t("A fatal error has occurred") . '</h1>';
 
         if (($error instanceof PEAR_Error) ||
             (is_object($error) && method_exists($error, 'getMessage'))) {
@@ -123,12 +124,12 @@ class Horde
             $backtrace = new Horde_Support_Backtrace($trace);
             $errortext .= '<div id="backtrace"><pre>' . (string)$backtrace . '</pre></div>';
             if (is_object($error)) {
-                $errortext .= '<h3>' . _("Details") . '</h3>';
-                $errortext .= '<h4>' . _("The full error message is logged in Horde's log file, and is shown below only to administrators. Non-administrative users will not see error details.") . '</h4>';
+                $errortext .= '<h3>' . $dict->t("Details") . '</h3>';
+                $errortext .= '<h4>' . $dict->t("The full error message is logged in Horde's log file, and is shown below only to administrators. Non-administrative users will not see error details.") . '</h4>';
                 $errortext .= '<div id="details"><pre>' . htmlspecialchars(print_r($error, true)) . '</pre></div>';
             }
         } elseif ($log) {
-            $errortext .= '<h3>' . _("Details have been logged for the administrator.") . '</h3>';
+            $errortext .= '<h3>' . $dict->t("Details have been logged for the administrator.") . '</h3>';
         }
 
         // Log the error via logMessage() if requested.
@@ -374,11 +375,13 @@ HTML;
         global $conf, $session;
 
         if (!isset($session['horde:form_secrets/' . $token])) {
-            throw new Horde_Exception(_("We cannot verify that this request was really sent by you. It could be a malicious request. If you intended to perform this action, you can retry it now."));
+            $dict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../locale');
+            throw new Horde_Exception($dict->t("We cannot verify that this request was really sent by you. It could be a malicious request. If you intended to perform this action, you can retry it now."));
         }
 
         if (($session['horde:form_secrets/' . $token] + $GLOBALS['conf']['urls']['token_lifetime'] * 60) < time()) {
-            throw new Horde_Exception(sprintf(_("This request cannot be completed because the link you followed or the form you submitted was only valid for %s minutes. Please try again now."), $GLOBALS['conf']['urls']['token_lifetime']));
+            $dict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../locale');
+            throw new Horde_Exception(sprintf($dict->t("This request cannot be completed because the link you followed or the form you submitted was only valid for %s minutes. Please try again now."), $GLOBALS['conf']['urls']['token_lifetime']));
         }
     }
 
@@ -671,7 +674,8 @@ HTML;
     static public function requireSecureConnection()
     {
         if (!self::isConnectionSecure()) {
-            throw new Horde_Exception(_("The encryption features require a secure web connection."));
+            $dict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../locale');
+            throw new Horde_Exception($dict->t("The encryption features require a secure web connection."));
         }
     }
 
@@ -862,18 +866,20 @@ HTML;
         $fileroot = isset($registry) ? $registry->get('fileroot') : '';
 
         if (!is_array($params) || !count($params)) {
+            $dict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../locale');
             throw new Horde_Exception(
-                sprintf(_("No configuration information specified for %s."), $name) . "\n\n" .
-                sprintf(_("The file %s should contain some %s settings."),
+                sprintf($dict->t("No configuration information specified for %s."), $name) . "\n\n" .
+                sprintf($dict->t("The file %s should contain some %s settings."),
                     $fileroot . '/config/' . $file,
                     sprintf("%s['%s']['params']", $variable, $driver)));
         }
 
         foreach ($fields as $field) {
             if (!isset($params[$field])) {
+                $dict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../locale');
                 throw new Horde_Exception(
-                    sprintf(_("Required \"%s\" not specified in %s configuration."), $field, $name) . "\n\n" .
-                    sprintf(_("The file %s should contain a %s setting."),
+                    sprintf($dict->t("Required \"%s\" not specified in %s configuration."), $field, $name) . "\n\n" .
+                    sprintf($dict->t("The file %s should contain a %s setting."),
                         $fileroot . '/config/' . $file,
                         sprintf("%s['%s']['params']['%s']", $variable, $driver, $field)));
             }
@@ -1608,8 +1614,9 @@ HTML;
         $ak = self::getAccessKey($label, $nocheck);
         $attributes = 'title="' . self::stripAccessKey($label);
         if (!empty($ak)) {
-            $attributes .= sprintf(_(" (Accesskey %s)"), strtoupper($ak));
-            $attributes .= '" accesskey="' . $ak;
+            $dict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../locale');
+            $attributes .= sprintf($dict->t(" (Accesskey %s)"), strtoupper($ak))
+              . '" accesskey="' . $ak;
         }
 
         return $attributes . '"';
@@ -2077,7 +2084,8 @@ HTML;
         $menu = new Horde_Menu(isset($opts['mask']) ? $opts['mask'] : Horde_Menu::MASK_ALL);
 
         if (!in_array($registry->get('status', 'horde'), array('notoolbar', 'hidden', 'inactive'))) {
-            $menu->add(Horde::url('services/portal/', false, array('app' => 'horde')), _("_Home"), 'horde.png');
+            $dict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../locale');
+            $menu->add(Horde::url('services/portal/', false, array('app' => 'horde')), $dict->t("_Home"), 'horde.png');
         }
 
         $registry->callAppMethod($opts['app'], 'menu', array(
index 64dcb40..b41425c 100644 (file)
@@ -181,7 +181,8 @@ abstract class Horde_Core_Ajax_Application
         }
         $res = $rfc822->parseAddressList($this->_vars->email, $params);
         if (!count($res)) {
-            throw new Horde_Exception(_("No valid email address found"));
+            $dict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../locale');
+            throw new Horde_Exception($dict->t("No valid email address found"));
         }
 
         return (object)array(
index c9428c3..2d4e0ec 100644 (file)
@@ -67,6 +67,13 @@ class Horde_Core_Auth_Application extends Horde_Auth_Base
     );
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_coreDict;
+
+    /**
      * Constructor.
      *
      * @param array $params  Required parameters:
@@ -95,6 +102,8 @@ class Horde_Core_Auth_Application extends Horde_Auth_Base
             unset($params['base']);
         }
 
+        $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../locale');
+
         parent::__construct($params);
     }
 
@@ -571,7 +580,7 @@ class Horde_Core_Auth_Application extends Horde_Auth_Base
             isset($GLOBALS['notification']) &&
             ($expire = $this->_base->getCredential('expire'))) {
             $toexpire = ($expire - time()) / 86400;
-            $GLOBALS['notification']->push(sprintf(ngettext("%d day until your password expires.", "%d days until your password expires.", $toexpire), $toexpire), 'horde.warning');
+            $GLOBALS['notification']->push(sprintf($this->_coreDict->n("%d day until your password expires.", "%d days until your password expires.", $toexpire), $toexpire), 'horde.warning');
         }
 
         if ($this->hasCapability('authenticatecallback')) {
index 6bfd76b..3315d70 100644 (file)
 abstract class Horde_Core_Auth_Signup_Base
 {
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_coreDict;
+
+    /**
+     * Constructor.
+     */
+    public function __construct()
+    {
+        $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../../locale');
+    }
+
+    /**
      * Adds a new user to the system and handles any extra fields that may have
      * been compiled, relying on the hooks.php file.
      *
@@ -78,14 +93,14 @@ abstract class Horde_Core_Auth_Signup_Base
                 'u' => $signup->name,
                 'h' => hash_hmac('sha1', $signup->name, $conf['secret_key'])
             ));
-            $message = sprintf(_("A new account for the user \"%s\" has been requested through the signup form."), $signup->name)
+            $message = sprintf($this->_coreDict->t("A new account for the user \"%s\" has been requested through the signup form."), $signup->name)
                 . "\n\n"
-                . _("Approve the account:")
+                . $this->_coreDict->t("Approve the account:")
                 . "\n" . $link->copy()->add('a', 'approve') . "\n"
-                . _("Deny the account:")
+                . $this->_coreDict->t("Deny the account:")
                 . "\n" . $link->copy()->add('a', 'deny');
             $mail = new Horde_Mime_Mail(array(
-                'subject' => sprintf(_("Account signup request for \"%s\""), $signup->name),
+                'subject' => sprintf($this->_coreDict->t("Account signup request for \"%s\""), $signup->name),
                 'body' => $message,
                 'to' => $conf['signup']['email'],
                 'from' => $conf['signup']['email'],
@@ -111,7 +126,7 @@ abstract class Horde_Core_Auth_Signup_Base
         // the signup queue.
         if ($GLOBALS['auth']->exists($info['user_name']) ||
             $this->exists($info['user_name'])) {
-            throw new Horde_Exception(sprintf(_("Username \"%s\" already exists."), $info['user_name']));
+            throw new Horde_Exception(sprintf($this->_coreDict->t("Username \"%s\" already exists."), $info['user_name']));
         }
     }
 
index 7b5ce9d..2d2cd88 100644 (file)
@@ -20,15 +20,23 @@ class Horde_Core_Auth_Signup_Form extends Horde_Form
     protected $_useFormToken = true;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_coreDict;
+
+    /**
      * Constructor
      *
      * @var params Horde_Variables  TODO
      */
     public function __construct(&$vars)
     {
-        parent::__construct($vars, sprintf(_("%s Sign Up"), $GLOBALS['registry']->get('name')));
+        $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../../locale');
+        parent::__construct($vars, sprintf($this->_coreDict->t("%s Sign Up"), $GLOBALS['registry']->get('name')));
 
-        $this->setButtons(_("Sign up"), true);
+        $this->setButtons($this->_coreDict->t("Sign up"), true);
 
         $this->addHidden('', 'url', 'text', false);
 
@@ -39,10 +47,10 @@ class Horde_Core_Auth_Signup_Form extends Horde_Form
 
         if (!empty($extra)) {
             if (!isset($extra['user_name'])) {
-                $this->addVariable(_("Choose a username"), 'user_name', 'text', true);
+                $this->addVariable($this->_coreDict->t("Choose a username"), 'user_name', 'text', true);
             }
             if (!isset($extra['password'])) {
-                $this->addVariable(_("Choose a password"), 'password', 'passwordconfirm', true, false, _("type the password twice to confirm"));
+                $this->addVariable($this->_coreDict->t("Choose a password"), 'password', 'passwordconfirm', true, false, $this->_coreDict->t("type the password twice to confirm"));
             }
             foreach ($extra as $field_name => $field) {
                 $readonly = isset($field['readonly']) ? $field['readonly'] : null;
@@ -55,8 +63,8 @@ class Horde_Core_Auth_Signup_Form extends Horde_Form
                                    $desc, $field_params);
             }
         } else {
-            $this->addVariable(_("Choose a username"), 'user_name', 'text', true);
-            $this->addVariable(_("Choose a password"), 'password', 'passwordconfirm', true, false, _("type the password twice to confirm"));
+            $this->addVariable($this->_coreDict->t("Choose a username"), 'user_name', 'text', true);
+            $this->addVariable($this->_coreDict->t("Choose a password"), 'password', 'passwordconfirm', true, false, $this->_coreDict->t("type the password twice to confirm"));
         }
     }
 
index ac5fd0b..6c8b9c6 100644 (file)
@@ -26,6 +26,7 @@ class Horde_Core_Auth_Signup_Sql extends Horde_Core_Auth_Signup_Base
      */
     public function __construct()
     {
+        parent::__construct();
         $this->_params = array_merge(
             $this->_params,
             array('table' => 'horde_signups'),
@@ -92,7 +93,7 @@ class Horde_Core_Auth_Signup_Sql extends Horde_Core_Auth_Signup_Base
 
         $result = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Db')->create('horde', 'signup')->selectOne($query, $values);
         if (empty($result)) {
-            throw new Horde_Exception(sprintf(_("User \"%s\" does not exist."), $username));
+            throw new Horde_Exception(sprintf($this->_coreDict->t("User \"%s\" does not exist."), $username));
         }
         $object = new Horde_Core_Auth_Signup_SqlObject($data['user_name']);
         $object->setData($data);
index d8ea503..4d235c8 100644 (file)
@@ -9,7 +9,8 @@ class Horde_Core_Factory_History
     {
         if (empty($GLOBALS['conf']['sql']['phptype']) ||
             ($GLOBALS['conf']['sql']['phptype'] == 'none')) {
-            throw new Horde_Exception(_("The History system is disabled."));
+            $dict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../locale');
+            throw new Horde_Exception($dict->t("The History system is disabled."));
         }
 
         $ob = Horde_History::factory('Sql', $GLOBALS['conf']['sql']);
index 6668e84..153c71e 100644 (file)
@@ -42,6 +42,13 @@ class Horde_Core_Factory_Prefs
     private $_injector;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_coreDict;
+
+    /**
      * Constructor.
      *
      * @param Horde_Injector $injector  The injector to use.
@@ -49,6 +56,7 @@ class Horde_Core_Factory_Prefs
     public function __construct(Horde_Injector $injector)
     {
         $this->_injector = $injector;
+        $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../locale');
     }
 
     /**
@@ -114,7 +122,7 @@ class Horde_Core_Factory_Prefs
                 if (!$GLOBALS['session']['horde:no_prefs']) {
                     $GLOBALS['session']['horde:no_prefs'] = true;
                     if (isset($GLOBALS['notification'])) {
-                        $GLOBALS['notification']->push(_("The preferences backend is currently unavailable and your preferences have not been loaded. You may continue to use the system with default preferences."));
+                        $GLOBALS['notification']->push($this->_coreDict("The preferences backend is currently unavailable and your preferences have not been loaded. You may continue to use the system with default preferences."));
                     }
                 }
                 $this->_instances[$sig] = Horde_Prefs::factory('Session', $scope);
@@ -146,7 +154,7 @@ class Horde_Core_Factory_Prefs
             return false;
         }
 
-        $GLOBALS['notification']->push(sprintf(_("The preference \"%s\" could not be saved because its data exceeds the maximum allowable size"), $pref), 'horde.error');
+        $GLOBALS['notification']->push(sprintf($this->_coreDict("The preference \"%s\" could not be saved because its data exceeds the maximum allowable size"), $pref), 'horde.error');
         return true;
     }
 
index 6d56b9a..da09354 100644 (file)
@@ -79,7 +79,8 @@ class Horde_Core_Factory_Share
         if (empty($ob)) {
             $class = 'Horde_Share_' . ucfirst(basename($driver));
             if (!class_exists($class)) {
-                throw new Horde_Exception(sprintf(_("\"%s\" share driver not found."), $driver));
+                $dict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../locale');
+                throw new Horde_Exception(sprintf($dict->t("\"%s\" share driver not found."), $driver));
             }
 
             $ob = new $class($app, $this->_injector->getInstance('Horde_Perms'));
index bb3af49..ad62274 100644 (file)
@@ -39,7 +39,8 @@ class Horde_Core_Factory_Twitter
 
             return $twitter;
         } else {
-            throw new Horde_Service_Twitter_Exception(_("No OAuth Key or Secret found for the Twitter API"));
+            $dict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../locale');
+            throw new Horde_Service_Twitter_Exception($dict->t("No OAuth Key or Secret found for the Twitter API"));
         }
     }
 }
index bd701d1..0206326 100644 (file)
@@ -78,7 +78,8 @@ class Horde_Core_Factory_Vfs
         global $conf;
 
         if (($name !== 'horde') && !isset($conf[$name]['type'])) {
-            throw new Horde_Exception(_("You must configure a VFS backend."));
+            $dict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../locale');
+            throw new Horde_Exception($dict->t("You must configure a VFS backend."));
         }
 
         $vfs = ($name == 'horde' || $conf[$name]['type'] == 'horde')
index 1d922a3..c16b05a 100644 (file)
@@ -34,6 +34,13 @@ class Horde_Core_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base
     protected $_imageUrl;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_coreDict;
+
+    /**
      * Constructor.
      *
      * @param Horde_Mime_Part $mime_part  The object with the data to be
@@ -50,6 +57,8 @@ class Horde_Core_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base
      */
     public function __construct(Horde_Mime_Part $part, array $conf = array())
     {
+        $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../../locale');
+
         $this->_required = array_merge($this->_required, array(
             'browser',
             'notification',
@@ -99,11 +108,11 @@ class Horde_Core_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base
         $data = $this->_mimepart->getContents();
         $html = '';
         $import_msg = null;
-        $title = _("vCard");
+        $title = $this->_coreDict->t("vCard");
 
         $iCal = new Horde_Icalendar();
         if (!$iCal->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) {
-            $notification->push(_("There was an error reading the contact data."), 'horde.error');
+            $notification->push($this->_coreDict->t("There was an error reading the contact data."), 'horde.error');
         }
 
         if (Horde_Util::getFormData('import') &&
@@ -117,11 +126,11 @@ class Horde_Core_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base
                         $contacts = $registry->call('contacts/import', array($c, null, $source));
                         ++$count;
                     } catch (Horde_Exception $e) {
-                        $notification->push(_("There was an error importing the contact data:") . ' ' . $e->getMessage(), 'horde.error');
+                        $notification->push($this->_coreDict->t("There was an error importing the contact data:") . ' ' . $e->getMessage(), 'horde.error');
                     }
                 }
             }
-            $notification->push(sprintf(ngettext(
+            $notification->push(sprintf($this->_coreDict->n(
                 "%d contact was successfully added to your address book.",
                 "%d contacts were successfully added to your address book.",
                 $count),
@@ -145,18 +154,18 @@ class Horde_Core_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base
 
             $n = $vc->printableName();
             if (!empty($n)) {
-                $html .= $this->_row(_("Name"), $n);
+                $html .= $this->_row($this->_coreDict->t("Name"), $n);
             }
 
             try {
-                $html .= $this->_row(_("Alias"), implode("\n", $vc->getAttributeValues('ALIAS')));
+                $html .= $this->_row($this->_coreDict->t("Alias"), implode("\n", $vc->getAttributeValues('ALIAS')));
             } catch (Horde_Icalendar_Exception $e) {}
 
             try {
                 $birthdays = $vc->getAttributeValues('BDAY');
                 $birthday = new Horde_Date($birthdays[0]);
                 $html .= $this->_row(
-                    _("Birthday"),
+                    $this->_coreDict->t("Birthday"),
                     $birthday->strftime($prefs->getValue('date_format')));
             } catch (Horde_Icalendar_Exception $e) {}
 
@@ -164,7 +173,7 @@ class Horde_Core_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base
             foreach ($photos as $p => $photo) {
                 if (isset($photo['params']['VALUE']) &&
                     Horde_String::upper($photo['params']['VALUE']) == 'URI') {
-                    $html .= $this->_row(_("Photo"),
+                    $html .= $this->_row($this->_coreDict->t("Photo"),
                                          '<img src="' . htmlspecialchars($photo['value']) . '" />',
                                          false);
                 } elseif (isset($photo['params']['ENCODING']) &&
@@ -172,11 +181,11 @@ class Horde_Core_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base
                           isset($photo['params']['TYPE'])) {
                     if ($browser->hasFeature('datauri') === true ||
                         $browser->hasFeature('datauri') >= strlen($photo['value'])) {
-                        $html .= $this->_row(_("Photo"),
+                        $html .= $this->_row($this->_coreDict->t("Photo"),
                                              '<img src="data:' . htmlspecialchars($photo['params']['TYPE'] . ';base64,' . $photo['value']) . '" />',
                                              false);
                     } elseif ($this->_imageUrl) {
-                        $html .= $this->_row(_("Photo"),
+                        $html .= $this->_row($this->_coreDict->t("Photo"),
                                              '<img src="' . htmlspecialchars($this->_imageUrl->add(array('c' => $i, 'p' => $p))) . '" />',
                                              false);
                     }
@@ -196,36 +205,36 @@ class Horde_Core_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base
                 foreach ($label['params']['TYPE'] as $type) {
                     switch(Horde_String::upper($type)) {
                     case 'HOME':
-                        $types[] = _("Home Address");
+                        $types[] = $this->_coreDict->t("Home Address");
                         break;
 
                     case 'WORK':
-                        $types[] = _("Work Address");
+                        $types[] = $this->_coreDict->t("Work Address");
                         break;
 
                     case 'DOM':
-                        $types[] = _("Domestic Address");
+                        $types[] = $this->_coreDict->t("Domestic Address");
                         break;
 
                     case 'INTL':
-                        $types[] = _("International Address");
+                        $types[] = $this->_coreDict->t("International Address");
                         break;
 
                     case 'POSTAL':
-                        $types[] = _("Postal Address");
+                        $types[] = $this->_coreDict->t("Postal Address");
                         break;
 
                     case 'PARCEL':
-                        $types[] = _("Parcel Address");
+                        $types[] = $this->_coreDict->t("Parcel Address");
                         break;
 
                     case 'PREF':
-                        $types[] = _("Preferred Address");
+                        $types[] = $this->_coreDict->t("Preferred Address");
                         break;
                     }
                 }
                 if (!count($types)) {
-                    $types = array(_("Address"));
+                    $types = array($this->_coreDict->t("Address"));
                 }
                 $html .= $this->_row(implode('/', $types), $label['value']);
             }
@@ -260,36 +269,36 @@ class Horde_Core_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base
                 foreach ($item['params']['TYPE'] as $type) {
                     switch(Horde_String::upper($type)) {
                     case 'HOME':
-                        $types[] = _("Home Address");
+                        $types[] = $this->_coreDict->t("Home Address");
                         break;
 
                     case 'WORK':
-                        $types[] = _("Work Address");
+                        $types[] = $this->_coreDict->t("Work Address");
                         break;
 
                     case 'DOM':
-                        $types[] = _("Domestic Address");
+                        $types[] = $this->_coreDict->t("Domestic Address");
                         break;
 
                     case 'INTL':
-                        $types[] = _("International Address");
+                        $types[] = $this->_coreDict->t("International Address");
                         break;
 
                     case 'POSTAL':
-                        $types[] = _("Postal Address");
+                        $types[] = $this->_coreDict->t("Postal Address");
                         break;
 
                     case 'PARCEL':
-                        $types[] = _("Parcel Address");
+                        $types[] = $this->_coreDict->t("Parcel Address");
                         break;
 
                     case 'PREF':
-                        $types[] = _("Preferred Address");
+                        $types[] = $this->_coreDict->t("Preferred Address");
                         break;
                     }
                 }
                 if (!count($types)) {
-                    $types = array(_("Address"));
+                    $types = array($this->_coreDict->t("Address"));
                 }
                 $html .= $this->_row(implode('/', $types), implode("\n", $a));
             }
@@ -306,19 +315,19 @@ class Horde_Core_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base
                     }
                 }
                 if (isset($number['params']['FAX'])) {
-                    $html .= $this->_row(_("Fax"), $number['value']);
+                    $html .= $this->_row($this->_coreDict->t("Fax"), $number['value']);
                 } else {
                     if (isset($number['params']['HOME'])) {
-                        $html .= $this->_row(_("Home Phone"),
+                        $html .= $this->_row($this->_coreDict->t("Home Phone"),
                                              $number['value']);
                     } elseif (isset($number['params']['WORK'])) {
-                        $html .= $this->_row(_("Work Phone"),
+                        $html .= $this->_row($this->_coreDict->t("Work Phone"),
                                              $number['value']);
                     } elseif (isset($number['params']['CELL'])) {
-                        $html .= $this->_row(_("Cell Phone"),
+                        $html .= $this->_row($this->_coreDict->t("Cell Phone"),
                                              $number['value']);
                     } else {
-                        $html .= $this->_row(_("Phone"),
+                        $html .= $this->_row($this->_coreDict->t("Phone"),
                                              $number['value']);
                     }
                 }
@@ -352,36 +361,36 @@ class Horde_Core_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base
             }
 
             if (count($emails)) {
-                $html .= $this->_row(_("Email"), implode("\n", $emails), false);
+                $html .= $this->_row($this->_coreDict->t("Email"), implode("\n", $emails), false);
             }
 
             try {
                 $title = $vc->getAttributeValues('TITLE');
-                $html .= $this->_row(_("Title"), $title[0]);
+                $html .= $this->_row($this->_coreDict->t("Title"), $title[0]);
             } catch (Horde_Icalendar_Exception $e) {}
 
             try {
                 $role = $vc->getAttributeValues('ROLE');
-                $html .= $this->_row(_("Role"), $role[0]);
+                $html .= $this->_row($this->_coreDict->t("Role"), $role[0]);
             } catch (Horde_Icalendar_Exception $e) {}
 
             try {
                 $org = $vc->getAttributeValues('ORG');
-                $html .= $this->_row(_("Company"), $org[0]);
+                $html .= $this->_row($this->_coreDict->t("Company"), $org[0]);
                 if (isset($org[1])) {
-                    $html .= $this->_row(_("Department"), $org[1]);
+                    $html .= $this->_row($this->_coreDict->t("Department"), $org[1]);
                 }
             } catch (Horde_Icalendar_Exception $e) {}
 
             try {
                 $notes = $vc->getAttributeValues('NOTE');
-                $html .= $this->_row(_("Notes"), $notes[0]);
+                $html .= $this->_row($this->_coreDict->t("Notes"), $notes[0]);
             } catch (Horde_Icalendar_Exception $e) {}
 
             try {
                 $url = $vc->getAttributeValues('URL');
                 $html .= $this->_row(
-                    _("URL"),
+                    $this->_coreDict->t("URL"),
                     '<a href="' . htmlspecialchars($url[0])
                         . '" target="_blank">' . htmlspecialchars($url[0])
                         . '</a>',
@@ -403,9 +412,9 @@ class Horde_Core_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base
             if (count($sources) > 1) {
                 $html .=
                     '<input type="submit" class="button" name="import" value="'
-                    . _("Add to address book:") . '" />'
+                    . $this->_coreDict->t("Add to address book:") . '" />'
                     . '<label for="add_source" class="hidden">'
-                    . _("Address Book") . '</label>'
+                    . $this->_coreDict->t("Address Book") . '</label>'
                     . '<select id="add_source" name="source">';
                 foreach ($sources as $key => $label) {
                     $selected = ($key == $prefs->getValue('add_source'))
@@ -418,7 +427,7 @@ class Horde_Core_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base
                 reset($sources);
                 $html .=
                     '<input type="submit" class="button" name="import" value="'
-                    . _("Add to my address book") . '" />'
+                    . $this->_coreDict->t("Add to my address book") . '" />'
                     . '<input type="hidden" name="source" value="'
                     . htmlspecialchars(key($sources)) . '" />';
             }
index 55ce913..acba9f8 100644 (file)
 class Horde_Core_Notification_Status extends Horde_Notification_Event_Status
 {
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_coreDict;
+
+    /**
      * Constructor.
      *
      * @param mixed $data   Message: either a string or an Exception or
@@ -23,6 +30,8 @@ class Horde_Core_Notification_Status extends Horde_Notification_Event_Status
      */
     public function __construct($data, $type = null, array $flags = array())
     {
+        $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../locale');
+
         if (empty($type)) {
             $type = ($data instanceof PEAR_Error || $data instanceof Exception)
                 ? 'horde.error'
@@ -65,15 +74,15 @@ class Horde_Core_Notification_Status extends Horde_Notification_Event_Status
                     return $e->getMessage();
                 }
                 $opts = array(
-                    '-1' => _("Dismiss"),
-                    '5' => _("5 minutes"),
-                    '15' => _("15 minutes"),
-                    '60' => _("1 hour"),
-                    '360' => _("6 hours"),
-                    '1440' => _("1 day")
+                    '-1' => $this->_coreDict->t("Dismiss"),
+                    '5' => $this->_coreDict->t("5 minutes"),
+                    '15' => $this->_coreDict->t("15 minutes"),
+                    '60' => $this->_coreDict->t("1 hour"),
+                    '360' => $this->_coreDict->t("6 hours"),
+                    '1440' => $this->_coreDict->t("1 day")
                 );
                 $id = 'snooze_' . md5($alarm['id']);
-                $text .= ' <small onmouseover="if(typeof ' . $id . '_t!=\'undefined\')clearTimeout(' . $id . '_t);Element.show(\'' . $id . '\')" onmouseout="' . $id . '_t=setTimeout(function(){Element.hide(\'' . $id . '\')},500)">[' . _("Snooze...") . '<span id="' . $id . '" style="display:none"> ';
+                $text .= ' <small onmouseover="if(typeof ' . $id . '_t!=\'undefined\')clearTimeout(' . $id . '_t);Element.show(\'' . $id . '\')" onmouseout="' . $id . '_t=setTimeout(function(){Element.hide(\'' . $id . '\')},500)">[' . $this->_coreDict->t("Snooze...") . '<span id="' . $id . '" style="display:none"> ';
                 $first = true;
                 foreach ($opts as $minutes => $desc) {
                     if (!$first) {
@@ -86,30 +95,30 @@ class Horde_Core_Notification_Status extends Horde_Notification_Event_Status
             }
 
             $img = 'alerts/alarm.png';
-            $label = _("Alarm");
+            $label = $this->_coreDict->t("Alarm");
             break;
 
         case 'horde.error':
             $img = 'alerts/error.png';
-            $label = _("Error");
+            $label = $this->_coreDict->t("Error");
             $text = parent::__toString();
             break;
 
         case 'horde.message':
             $img = 'alerts/message.png';
-            $label = _("Message");
+            $label = $this->_coreDict->t("Message");
             $text = parent::__toString();
             break;
 
         case 'horde.success':
             $img = 'alerts/success.png';
-            $label = _("Success");
+            $label = $this->_coreDict->t("Success");
             $text = parent::__toString();
             break;
 
         case 'horde.warning':
             $img = 'alerts/warning.png';
-            $label = _("Warning");
+            $label = $this->_coreDict->t("Warning");
             $text = parent::__toString();
             break;
 
index ee638fe..8c506a6 100644 (file)
@@ -43,6 +43,13 @@ class Horde_Core_Perms_Ui
     protected $_type = 'matrix';
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_coreDict;
+
+    /**
      * Constructor.
      *
      * @param Horde_Perms $perms  The object to display UI stuff for.
@@ -50,6 +57,7 @@ class Horde_Core_Perms_Ui
     public function __construct($perms)
     {
         $this->_perms = $perms;
+        $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../locale');
     }
 
     /**
@@ -67,11 +75,11 @@ class Horde_Core_Perms_Ui
 
         $perms_node = array('icon' => Horde_Themes::img('perms.png'));
         $add = Horde::url('admin/perms/addchild.php');
-        $add_img = Horde::img('add_perm.png', _("Add Permission"));
+        $add_img = Horde::img('add_perm.png', $this->_coreDict->t("Add Permission"));
         $edit = Horde::url('admin/perms/edit.php');
         $delete = Horde::url('admin/perms/delete.php');
-        $edit_img = Horde::img('edit.png', _("Edit Permission"));
-        $delete_img = Horde::img('delete.png', _("Delete Permission"));
+        $edit_img = Horde::img('edit.png', $this->_coreDict->t("Edit Permission"));
+        $delete_img = Horde::img('delete.png', $this->_coreDict->t("Delete Permission"));
         $blank_img = Horde::img('blank.gif', '', array('width' => 16, 'height' => 16));
 
         /* Set up the tree. */
@@ -90,10 +98,10 @@ class Horde_Core_Perms_Ui
                 ? array('class' => 'selected')
                 : array();
             if ($perm_id == Horde_Perms::ROOT) {
-                $add_link = $add->add('perm_id', $perm_id)->link(array('title' => _("Add New Permission"))) . $add_img . '</a>';
+                $add_link = $add->add('perm_id', $perm_id)->link(array('title' => $this->_coreDict->t("Add New Permission"))) . $add_img . '</a>';
                 $base_node_params = array('icon' => Horde_Themes::img('administration.png'));
 
-                $tree->addNode($perm_id, null, _("All Permissions"), 0, true,
+                $tree->addNode($perm_id, null, $this->_coreDict->t("All Permissions"), 0, true,
                                $base_node_params + $node_class,
                                array($add_link));
             } else {
@@ -119,15 +127,15 @@ class Horde_Core_Perms_Ui
 
                 if (isset($app_perms['tree']) &&
                     is_array(Horde_Array::getElement($app_perms['tree'], $parents))) {
-                    $add_link = $add->add('perm_id', $perm_id)->link(array('title' => _("Add Child Permission"))) . $add_img . '</a>';
+                    $add_link = $add->add('perm_id', $perm_id)->link(array('title' => $this->_coreDict->t("Add Child Permission"))) . $add_img . '</a>';
                     $perms_extra[] = $add_link;
                 } else {
                     $perms_extra[] = $blank_img;
                 }
 
-                $edit_link = $edit->add('perm_id', $perm_id)->link(array('title' => _("Edit Permission"))) . $edit_img . '</a>';
+                $edit_link = $edit->add('perm_id', $perm_id)->link(array('title' => $this->_coreDict->t("Edit Permission"))) . $edit_img . '</a>';
                 $perms_extra[] = $edit_link;
-                $delete_link = $delete->add('perm_id', $perm_id)->link(array('title' => _("Delete Permission"))) . $delete_img . '</a>';
+                $delete_link = $delete->add('perm_id', $perm_id)->link(array('title' => $this->_coreDict->t("Delete Permission"))) . $delete_img . '</a>';
                 $perms_extra[] = $delete_link;
                 $name = $this->_perms->getTitle($node);
 
@@ -180,8 +188,8 @@ class Horde_Core_Perms_Ui
         /* Initialise form if required. */
         $this->_formInit();
 
-        $this->_form->setTitle(sprintf(_("Add a child permission to \"%s\""), $this->_perms->getTitle($permission->getName())));
-        $this->_form->setButtons(_("Add"));
+        $this->_form->setTitle(sprintf($this->_coreDict->t("Add a child permission to \"%s\""), $this->_perms->getTitle($permission->getName())));
+        $this->_form->setButtons($this->_coreDict->t("Add"));
         $this->_vars->set('perm_id', $this->_perms->getPermissionId($permission));
         $this->_form->addHidden('', 'perm_id', 'text', false);
 
@@ -189,15 +197,15 @@ class Horde_Core_Perms_Ui
         $child_perms = $this->_perms->getAvailable($permission->getName());
         if ($child_perms === false) {
             /* False, so no childs are to be added below this level. */
-            $this->_form->addVariable(_("Permission"), 'child', 'invalid', true, false, null, array(_("No children can be added to this permission.")));
+            $this->_form->addVariable($this->_coreDict->t("Permission"), 'child', 'invalid', true, false, null, array($this->_coreDict->t("No children can be added to this permission.")));
         } elseif (is_array($child_perms)) {
             if (!empty($force_choice)) {
                 /* Choice array available, but choice being forced. */
                 $this->_vars->set('child', $force_choice);
-                $this->_form->addVariable(_("Permissions"), 'child', 'enum', true, true, null, array($child_perms));
+                $this->_form->addVariable($this->_coreDict->t("Permissions"), 'child', 'enum', true, true, null, array($child_perms));
             } else {
                 /* Choice array available, so set up enum field. */
-                $this->_form->addVariable(_("Permissions"), 'child', 'enum', true, false, null, array($child_perms));
+                $this->_form->addVariable($this->_coreDict->t("Permissions"), 'child', 'enum', true, false, null, array($child_perms));
             }
         }
     }
@@ -232,7 +240,7 @@ class Horde_Core_Perms_Ui
         /* Initialise form if required. */
         $this->_formInit();
 
-        $this->_form->setButtons(_("Update"), true);
+        $this->_form->setButtons($this->_coreDict->t("Update"), true);
         $perm_id = $this->_perms->getPermissionId($permission);
         $this->_form->addHidden('', 'perm_id', 'text', false);
 
@@ -242,7 +250,7 @@ class Horde_Core_Perms_Ui
 
         /* Default permissions. */
         $perm_val = $permission->getDefaultPermissions();
-        $this->_form->setSection('default', _("All Authenticated Users"), Horde::img('perms.png'), false);
+        $this->_form->setSection('default', $this->_coreDict->t("All Authenticated Users"), Horde::img('perms.png'), false);
 
         /* We MUST use 'deflt' for the variable name because 'default' is a
          * reserved word in JavaScript. */
@@ -260,7 +268,7 @@ class Horde_Core_Perms_Ui
 
         /* Guest permissions. */
         $perm_val = $permission->getGuestPermissions();
-        $this->_form->setSection('guest', _("Guest Permissions"), '', false);
+        $this->_form->setSection('guest', $this->_coreDict->t("Guest Permissions"), '', false);
 
         if ($this->_type == 'matrix') {
             /* Define a single matrix row for guest perms. */
@@ -273,7 +281,7 @@ class Horde_Core_Perms_Ui
 
         /* Object creator permissions. */
         $perm_val = $permission->getCreatorPermissions();
-        $this->_form->setSection('creator', _("Creator Permissions"), Horde::img('user.png'), false);
+        $this->_form->setSection('creator', $this->_coreDict->t("Creator Permissions"), Horde::img('user.png'), false);
 
         if ($this->_type == 'matrix') {
             /* Define a single matrix row for creator perms. */
@@ -286,7 +294,7 @@ class Horde_Core_Perms_Ui
 
         /* Users permissions. */
         $perm_val = $permission->getUserPermissions();
-        $this->_form->setSection('users', _("Individual Users"), Horde::img('user.png'), false);
+        $this->_form->setSection('users', $this->_coreDict->t("Individual Users"), Horde::img('user.png'), false);
         $auth = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Auth')->create();
         if ($auth->hasCapability('list')) {
             /* The auth driver has list capabilities so set up an array which
@@ -327,7 +335,7 @@ class Horde_Core_Perms_Ui
                 if (is_array($new_users)) {
                     $u_n = Horde_Util::getFormData('u_n');
                     $u_n = empty($u_n['u']) ? null : $u_n['u'];
-                    $user_html = '<select name="u_n[u]"><option value="">' . _("-- select --") . '</option>';
+                    $user_html = '<select name="u_n[u]"><option value="">' . $this->_coreDict->t("-- select --") . '</option>';
                     foreach ($new_users as $new_user) {
                         $user_html .= '<option value="' . $new_user . '"';
                         $user_html .= $u_n == $new_user ? ' selected="selected"' : '';
@@ -347,7 +355,7 @@ class Horde_Core_Perms_Ui
 
         /* Groups permissions. */
         $perm_val = $permission->getGroupPermissions();
-        $this->_form->setSection('groups', _("Groups"), Horde::img('group.png'), false);
+        $this->_form->setSection('groups', $this->_coreDict->t("Groups"), Horde::img('group.png'), false);
         try {
             $groups = $GLOBALS['injector']->getInstance('Horde_Group');
             $group_list = $groups->listGroups();
@@ -386,7 +394,7 @@ class Horde_Core_Perms_Ui
                 if (is_array($new_groups)) {
                     $g_n = Horde_Util::getFormData('g_n');
                     $g_n = empty($g_n['g']) ? null : $g_n['g'];
-                    $group_html = '<select name="g_n[g]"><option value="">' . _("-- select --") . '</option>';
+                    $group_html = '<select name="g_n[g]"><option value="">' . $this->_coreDict->t("-- select --") . '</option>';
                     foreach ($new_groups as $groupId => $group) {
                         $group_html .= '<option value="' . $groupId . '"';
                         $group_html .= $g_n == $groupId ? ' selected="selected"' : '';
@@ -405,7 +413,7 @@ class Horde_Core_Perms_Ui
         }
 
         /* Set form title. */
-        $this->_form->setTitle(sprintf(_("Edit permissions for \"%s\""), $this->_perms->getTitle($permission->getName())));
+        $this->_form->setTitle(sprintf($this->_coreDict->t("Edit permissions for \"%s\""), $this->_perms->getTitle($permission->getName())));
     }
 
     /**
@@ -471,10 +479,10 @@ class Horde_Core_Perms_Ui
         /* Initialise form if required. */
         $this->_formInit();
 
-        $this->_form->setTitle(sprintf(_("Delete permissions for \"%s\""), $this->_perms->getTitle($permission->getName())));
-        $this->_form->setButtons(array(_("Delete"), _("Do not delete")));
+        $this->_form->setTitle(sprintf($this->_coreDict->t("Delete permissions for \"%s\""), $this->_perms->getTitle($permission->getName())));
+        $this->_form->setButtons(array($this->_coreDict->t("Delete"), $this->_coreDict->t("Do not delete")));
         $this->_form->addHidden('', 'perm_id', 'text', false);
-        $this->_form->addVariable(sprintf(_("Delete permissions for \"%s\" and any sub-permissions?"), $this->_perms->getTitle($permission->getName())), 'prompt', 'description', false);
+        $this->_form->addVariable(sprintf($this->_coreDict->t("Delete permissions for \"%s\" and any sub-permissions?"), $this->_perms->getTitle($permission->getName())), 'prompt', 'description', false);
     }
 
     /**
@@ -490,7 +498,7 @@ class Horde_Core_Perms_Ui
     {
         $form_submit = $this->_vars->get('submitbutton');
 
-        if ($form_submit == _("Delete")) {
+        if ($form_submit == $this->_coreDict->t("Delete")) {
             if ($this->_form->validate($this->_vars)) {
                 $this->_form->getInfo($this->_vars, $info);
                 return true;
index 94d2c83..eb2bc03 100644 (file)
 class Horde_Core_Prefs_Identity extends Horde_Prefs_Identity
 {
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_coreDict;
+
+    /**
+     * Constructor.
+     */
+    public function __construct()
+    {
+        $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../locale');
+    }
+
+    /**
      * Sends a message to an email address supposed to be added to the
      * identity.
      * A message is send to this address containing a link to confirm that the
@@ -41,7 +56,7 @@ class Horde_Core_Prefs_Identity extends Horde_Prefs_Identity
 
         $new_addr = $this->getValue($this->_prefnames['from_addr'], $id);
         $confirm = Horde::getServiceLink('emailconfirm')->add('h', $hash)->setRaw(true);
-        $message = sprintf(_("You have requested to add the email address \"%s\" to the list of your personal email addresses.\n\nGo to the following link to confirm that this is really your address:\n%s\n\nIf you don't know what this message means, you can delete it."),
+        $message = sprintf($this->_coreDict->t("You have requested to add the email address \"%s\" to the list of your personal email addresses.\n\nGo to the following link to confirm that this is really your address:\n%s\n\nIf you don't know what this message means, you can delete it."),
                            $new_addr,
                            $confirm);
 
@@ -51,7 +66,7 @@ class Horde_Core_Prefs_Identity extends Horde_Prefs_Identity
         $msg_headers->addHeader('Date', date('r'));
         $msg_headers->addHeader('To', $new_addr);
         $msg_headers->addHeader('From', $old_addr);
-        $msg_headers->addHeader('Subject', _("Confirm new email address"));
+        $msg_headers->addHeader('Subject', $this->_coreDict->t("Confirm new email address"));
 
         $body = new Horde_Mime_Part();
         $body->setType('text/plain');
@@ -60,7 +75,7 @@ class Horde_Core_Prefs_Identity extends Horde_Prefs_Identity
 
         $body->send($new_addr, $msg_headers, $GLOBALS['injector']->getInstance('Horde_Mail'));
 
-        $GLOBALS['notification']->push(sprintf(_("A message has been sent to \"%s\" to verify that this is really your address. The new email address is activated as soon as you confirm this message."), $new_addr), 'horde.message');
+        $GLOBALS['notification']->push(sprintf($this->_coreDict->t("A message has been sent to \"%s\" to verify that this is really your address. The new email address is activated as soon as you confirm this message."), $new_addr), 'horde.message');
     }
 
     /**
@@ -75,16 +90,16 @@ class Horde_Core_Prefs_Identity extends Horde_Prefs_Identity
 
         $confirm = $this->_prefs->getValue('confirm_email');
         if (empty($confirm)) {
-            $notification->push(_("There are no email addresses to confirm."), 'horde.message');
+            $notification->push($this->_coreDict->t("There are no email addresses to confirm."), 'horde.message');
             return;
         }
 
         $confirm = @unserialize($confirm);
         if (empty($confirm)) {
-            $notification->push(_("There are no email addresses to confirm."), 'horde.message');
+            $notification->push($this->_coreDict->t("There are no email addresses to confirm."), 'horde.message');
             return;
         } elseif (!isset($confirm[$hash])) {
-            $notifcation->push(_("Email addresses to confirm not found."), 'horde.message');
+            $notifcation->push($this->_coreDict->t("Email addresses to confirm not found."), 'horde.message');
             return;
         }
 
@@ -109,7 +124,7 @@ class Horde_Core_Prefs_Identity extends Horde_Prefs_Identity
         unset($confirm[$hash]);
         $this->_prefs->setValue('confirm_email', serialize($confirm));
 
-        $notification->push(sprintf(_("The email address %s has been added to your identities. You can close this window now."), $verified[$this->_prefnames['from_addr']]), 'horde.success');
+        $notification->push(sprintf($this->_coreDict->t("The email address %s has been added to your identities. You can close this window now."), $verified[$this->_prefnames['from_addr']]), 'horde.success');
     }
 
     /**
index 50e90ef..3c86432 100644 (file)
@@ -91,12 +91,21 @@ class Horde_Core_Prefs_Ui
     public $nobuttons = false;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_coreDict;
+
+    /**
      * Constructor.
      *
      * @param Horde_Variables $vars  Form variables.
      */
     public function __construct($vars)
     {
+        $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../locale');
+
         $this->app = isset($vars->app)
             ? $vars->app
             : $this->getDefaultApp();
@@ -247,7 +256,7 @@ class Horde_Core_Prefs_Ui
                 if (isset($enum[$this->vars->$pref])) {
                     $updated |= $save->setValue($pref, $this->vars->$pref);
                 } else {
-                    $notification->push(_("An illegal value was specified."), 'horde.error');
+                    $notification->push($this->_coreDict->t("An illegal value was specified."), 'horde.error');
                 }
                 break;
 
@@ -263,7 +272,7 @@ class Horde_Core_Prefs_Ui
                         if (isset($enum[$val])) {
                             $set[] = $val;
                         } else {
-                            $notification->push(_("An illegal value was specified."), 'horde.error');
+                            $notification->push($this->_coreDict->t("An illegal value was specified."), 'horde.error');
                             break 2;
                         }
                     }
@@ -275,9 +284,9 @@ class Horde_Core_Prefs_Ui
             case 'number':
                 $num = $this->vars->$pref;
                 if ((string)(double)$num !== $num) {
-                    $notification->push(_("This value must be a number."), 'horde.error');
+                    $notification->push($this->_coreDict->t("This value must be a number."), 'horde.error');
                 } elseif (empty($num)) {
-                    $notification->push(_("This number must be non-zero."), 'horde.error');
+                    $notification->push($this->_coreDict->t("This number must be non-zero."), 'horde.error');
                 } else {
                     $updated |= $save->setValue($pref, $num);
                 }
@@ -311,9 +320,9 @@ class Horde_Core_Prefs_Ui
             }
 
             if ($prefs instanceof Horde_Prefs_Session) {
-                $notification->push(_("Your preferences have been updated for the duration of this session."), 'horde.success');
+                $notification->push($this->_coreDict->t("Your preferences have been updated for the duration of this session."), 'horde.success');
             } else {
-                $notification->push(_("Your preferences have been updated."), 'horde.success');
+                $notification->push($this->_coreDict->t("Your preferences have been updated."), 'horde.success');
             }
 
             $this->_loadPrefs($this->app);
@@ -386,7 +395,7 @@ class Horde_Core_Prefs_Ui
         }
 
         if (empty($columns) && empty($pref_list)) {
-            $notification->push(_("There are no preferences available for this application."), 'horde.message');
+            $notification->push($this->_coreDict->t("There are no preferences available for this application."), 'horde.message');
             $this->nobuttons = true;
         }
 
@@ -539,7 +548,7 @@ class Horde_Core_Prefs_Ui
 
         $content = Horde::endBuffer();
 
-        $title = _("User Preferences");
+        $title = $this->_coreDict->t("User Preferences");
 
         /* Get the menu output before we start to output the page.
          * Again, this will catch any javascript inserted into the page. */
@@ -585,7 +594,7 @@ class Horde_Core_Prefs_Ui
             );
         }
         $t->set('apps', $tmp);
-        $t->set('header', htmlspecialchars(($this->app == 'horde') ? _("Global Preferences") : sprintf(_("Preferences for %s"), $registry->get('name', $this->app))));
+        $t->set('header', htmlspecialchars(($this->app == 'horde') ? $this->_coreDict->t("Global Preferences") : sprintf($this->_coreDict->t("Preferences for %s"), $registry->get('name', $this->app))));
 
         if ($GLOBALS['session']['horde:prefs_advanced']) {
             $t->set('advanced', $this->selfUrl()->add('show_advanced', 1));
@@ -745,8 +754,8 @@ class Horde_Core_Prefs_Ui
             $t->set('default_identity', intval($default_identity));
             $identities = array($default_identity);
         } else {
-            $t->set('defaultid', _("Your default identity:"));
-            $t->set('label', Horde::label('identity', _("Select the identity you want to change:")));
+            $t->set('defaultid', $this->_coreDict->t("Your default identity:"));
+            $t->set('label', Horde::label('identity', $this->_coreDict->t("Select the identity you want to change:")));
             $identities = $identity->getAll('id');
         }
 
@@ -813,7 +822,7 @@ class Horde_Core_Prefs_Ui
             $id = intval($this->vars->id);
             $deleted_identity = $identity->delete($id);
             $this->_loadPrefs($this->app);
-            $notification->push(sprintf(_("The identity \"%s\" has been deleted."), $deleted_identity[0]['id']), 'horde.success');
+            $notification->push(sprintf($this->_coreDict->t("The identity \"%s\" has been deleted."), $deleted_identity[0]['id']), 'horde.success');
             return;
         }
 
@@ -827,7 +836,7 @@ class Horde_Core_Prefs_Ui
             if ($new_default != $old_default) {
                 $identity->setDefault($new_default);
                 $old_default = $new_default;
-                $notification->push(_("Your default identity has been changed."), 'horde.success');
+                $notification->push($this->_coreDict->t("Your default identity has been changed."), 'horde.success');
 
                 /* Need to immediately save, since we may short-circuit
                  * saving the identities below. */
@@ -859,7 +868,7 @@ class Horde_Core_Prefs_Ui
             try {
                 $identity->verifyIdentity($id, empty($current_from) ? $new_from : $current_from);
             } catch (Horde_Exception $e) {
-                $notification->push(_("The new from address can't be verified, try again later: ") . $e->getMessage(), 'horde.error');
+                $notification->push($this->_coreDict->t("The new from address can't be verified, try again later: ") . $e->getMessage(), 'horde.error');
                 Horde::logMessage($e, 'ERR');
             }
         } else {
index 3ce0cf9..4387f3f 100644 (file)
  */
 class Horde_Core_Prefs_Ui_Widgets
 {
+    /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_coreDict;
+
+    /**
+     * Constructor.
+     */
+    public function __construct()
+    {
+        $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../../locale');
+    }
+
     /* Source selection widget. */
 
     /**
@@ -89,12 +104,12 @@ class Horde_Core_Prefs_Ui_Widgets
             ));
         }
 
-        $t->set('addimg', Horde::img(isset($GLOBALS['registry']->nlsconfig['rtl'][$GLOBALS['language']]) ? 'lhand.png' : 'rhand.png', _("Add source")));
-        $t->set('removeimg', Horde::img(isset($GLOBALS['registry']->nlsconfig['rtl'][$GLOBALS['language']]) ? 'rhand.png' : 'lhand.png', _("Remove source")));
+        $t->set('addimg', Horde::img(isset($GLOBALS['registry']->nlsconfig['rtl'][$GLOBALS['language']]) ? 'lhand.png' : 'rhand.png', $this->_coreDict->t("Add source")));
+        $t->set('removeimg', Horde::img(isset($GLOBALS['registry']->nlsconfig['rtl'][$GLOBALS['language']]) ? 'rhand.png' : 'lhand.png', $this->_coreDict->t("Remove source")));
 
         if (empty($data['no_up'])) {
-            $t->set('upimg', Horde::img('nav/up.png', _("Move up")));
-            $t->set('downimg', Horde::img('nav/down.png', _("Move down")));
+            $t->set('upimg', Horde::img('nav/up.png', $this->_coreDict->t("Move up")));
+            $t->set('downimg', Horde::img('nav/down.png', $this->_coreDict->t("Move down")));
         }
 
         return $t->fetch(HORDE_TEMPLATES . '/prefs/source.html');
@@ -190,13 +205,13 @@ class Horde_Core_Prefs_Ui_Widgets
 
         if (!empty($selected) || !empty($unselected)) {
             $out = Horde_Core_Prefs_Ui_Widgets::source(array(
-                  'mainlabel' => _("Choose the order of address books to search when expanding addresses."),
-                  'selectlabel' => _("Selected address books:"),
+                  'mainlabel' => $this->_coreDict->t("Choose the order of address books to search when expanding addresses."),
+                  'selectlabel' => $this->_coreDict->t("Selected address books:"),
                   'sources' => array(array(
                       'selected' => $selected,
                       'unselected' => $unselected
                   )),
-                  'unselectlabel' => _("Available address books:")
+                  'unselectlabel' => $this->_coreDict->t("Available address books:")
              ));
 
             $t->set('selected', count($unselected) > 1);
@@ -228,7 +243,7 @@ class Horde_Core_Prefs_Ui_Widgets
 
             Horde::addInlineJsVars(array(
                 'HordeAddressbooksPrefs.fields' => $js,
-                'HordeAddressbooksPrefs.nonetext' => _("No address book selected.")
+                'HordeAddressbooksPrefs.nonetext' => $this->_coreDict->t("No address book selected.")
             ));
         }
 
@@ -393,7 +408,7 @@ class Horde_Core_Prefs_Ui_Widgets
                 foreach ($methods[$method]->getParameters() as $param => $info) {
                     $value[$method][$param] = $ui->vars->get($pref . '_' . $param, '');
                     if ($info['required'] && ($value[$method][$param] === '')) {
-                        $GLOBALS['notification']->push(sprintf(_("You must provide a setting for \"%s\"."), $methods[$method]->getDescription()), 'horde.error');
+                        $GLOBALS['notification']->push(sprintf($this->_coreDict->t("You must provide a setting for \"%s\"."), $methods[$method]->getDescription()), 'horde.error');
                         return null;
                     }
                 }
index 54f0b54..65c8a63 100644 (file)
@@ -23,6 +23,7 @@ class Horde_Core_Sidebar
     {
         global $injector, $registry;
 
+        $dict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../locale');
         $isAdmin = $registry->isAdmin();
         $menu = $parents = array();
 
@@ -54,7 +55,7 @@ class Horde_Core_Sidebar
         // Add the administration menu if the user is an admin.
         if ($isAdmin) {
             $menu['administration'] = array(
-                'name' => _("Administration"),
+                'name' => $dict->t("Administration"),
                 'icon' => Horde_Themes::img('administration.png'),
                 'status' => 'heading'
             );
@@ -76,7 +77,7 @@ class Horde_Core_Sidebar
             !($injector->getInstance('Horde_Core_Factory_Prefs')->create() instanceof Horde_Prefs_Session)) {
             $menu['prefs'] = array(
                 'icon' => Horde_Themes::img('prefs.png'),
-                'name' => _("Preferences"),
+                'name' => $dict->t("Preferences"),
                 'status' => 'active'
             );
 
@@ -87,7 +88,7 @@ class Horde_Core_Sidebar
                 $menu['prefs_' . 'horde'] = array(
                     'icon' => $registry->get('icon', 'horde'),
                     'menu_parent' => 'prefs',
-                    'name' => _("Global Preferences"),
+                    'name' => $dict->t("Global Preferences"),
                     'status' => 'active',
                     'url' => Horde::getServiceLink('prefs', 'horde')
                 );
@@ -109,14 +110,14 @@ class Horde_Core_Sidebar
         if ($registry->getAuth()) {
             $menu['logout'] = array(
                 'icon' => Horde_Themes::img('logout.png'),
-                'name' => _("Log out"),
+                'name' => $dict->t("Log out"),
                 'status' => 'active',
                 'url' => Horde::getServiceLink('logout', 'horde')
             );
         } else {
             $menu['login'] = array(
                 'icon' => Horde_Themes::img('login.png'),
-                'name' => _("Log in"),
+                'name' => $dict->t("Log in"),
                 'status' => 'active',
                 'url' => Horde::getServiceLink('login', 'horde')
             );
@@ -139,7 +140,7 @@ class Horde_Core_Sidebar
                 // Need to run the name through gettext since the user's
                 // locale may not have been loaded when registry.php was
                 // parsed.
-                $name = _($params['name']);
+                $name = $dict->t($params['name']);
 
                 // Headings have no webroot; they're just containers for other
                 // menu items.
index 5320ced..691dfb5 100644 (file)
  */
 class Horde_Core_Text_Filter_Highlightquotes extends Horde_Text_Filter_Highlightquotes
 {
+    /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_coreDict;
+
      /**
      * Constructor.
      *
@@ -39,6 +46,8 @@ class Horde_Core_Text_Filter_Highlightquotes extends Horde_Text_Filter_Highlight
 
         parent::__construct($params);
 
+        $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../../locale');
+
         if (!$this->_params['noJS'] && $this->_params['outputJS']) {
             Horde::addScriptFile('prototype.js', 'horde');
         }
@@ -61,9 +70,9 @@ class Horde_Core_Text_Filter_Highlightquotes extends Horde_Text_Filter_Highlight
         return (($this->_params['citeblock']) ? '<br />' : '') .
             '<div class="toggleQuoteParent">' .
             '<span ' . ($this->_params['outputJS'] ? 'onclick="[ this, this.next(), this.next(1) ].invoke(\'toggle\')" ' : '') .
-            'class="widget toggleQuoteShow"' . ($this->_params['hideBlocks'] ? '' : ' style="display:none"') . '>' . htmlspecialchars(sprintf(_("[Show Quoted Text - %d lines]"), $qcount)) . '</span>' .
+            'class="widget toggleQuoteShow"' . ($this->_params['hideBlocks'] ? '' : ' style="display:none"') . '>' . htmlspecialchars(sprintf($this->_coreDict->t("[Show Quoted Text - %d lines]"), $qcount)) . '</span>' .
             '<span ' . ($this->_params['outputJS'] ? 'onclick="[ this, this.previous(), this.next() ].invoke(\'toggle\')" ' : "") .
-            'class="widget toggleQuoteHide"' . ($this->_params['hideBlocks'] ? ' style="display:none"' : '') . '>' . htmlspecialchars(_("[Hide Quoted Text]")) . '</span>';
+            'class="widget toggleQuoteHide"' . ($this->_params['hideBlocks'] ? ' style="display:none"' : '') . '>' . htmlspecialchars($this->_coreDict->t("[Hide Quoted Text]")) . '</span>';
     }
 
     /**
index 3ff927b..fcf80db 100644 (file)
@@ -23,6 +23,13 @@ class Horde_Core_Ui_JsCalendar
     static protected $_initRun = false;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    static protected $_coreDict;
+
+    /**
      * Output the necessary javascript code to allow display of the calendar
      * widget.
      *
@@ -49,6 +56,8 @@ class Horde_Core_Ui_JsCalendar
         }
         self::$_initRun = true;
 
+        self::$_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../locale');
+
         $params = array_merge(array(
             'click_month' => false,
             'click_week' => false,
@@ -88,13 +97,13 @@ class Horde_Core_Ui_JsCalendar
     static public function weekdays()
     {
         return array(
-            _("Su"),
-            _("Mo"),
-            _("Tu"),
-            _("We"),
-            _("Th"),
-            _("Fr"),
-            _("Sa")
+            self::$_coreDict->t("Su"),
+            self::$_coreDict->t("Mo"),
+            self::$_coreDict->t("Tu"),
+            self::$_coreDict->t("We"),
+            self::$_coreDict->t("Th"),
+            self::$_coreDict->t("Fr"),
+            self::$_coreDict->t("Sa")
         );
     }
 
@@ -106,13 +115,13 @@ class Horde_Core_Ui_JsCalendar
     static public function fullWeekdays()
     {
         return array(
-            _("Sunday"),
-            _("Monday"),
-            _("Tuesday"),
-            _("Wednesday"),
-            _("Thursday"),
-            _("Friday"),
-            _("Saturday"),
+            self::$_coreDict->t("Sunday"),
+            self::$_coreDict->t("Monday"),
+            self::$_coreDict->t("Tuesday"),
+            self::$_coreDict->t("Wednesday"),
+            self::$_coreDict->t("Thursday"),
+            self::$_coreDict->t("Friday"),
+            self::$_coreDict->t("Saturday"),
         );
     }
 
@@ -124,18 +133,18 @@ class Horde_Core_Ui_JsCalendar
     static public function months()
     {
         return array(
-            _("January"),
-            _("February"),
-            _("March"),
-            _("April"),
-            _("May"),
-            _("June"),
-            _("July"),
-            _("August"),
-            _("September"),
-            _("October"),
-            _("November"),
-            _("December")
+            self::$_coreDict->t("January"),
+            self::$_coreDict->t("February"),
+            self::$_coreDict->t("March"),
+            self::$_coreDict->t("April"),
+            self::$_coreDict->t("May"),
+            self::$_coreDict->t("June"),
+            self::$_coreDict->t("July"),
+            self::$_coreDict->t("August"),
+            self::$_coreDict->t("September"),
+            self::$_coreDict->t("October"),
+            self::$_coreDict->t("November"),
+            self::$_coreDict->t("December")
         );
     }
 
index 786dbd6..433da33 100644 (file)
 class Horde_Core_Ui_Pager extends Horde_Core_Ui_Widget
 {
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_coreDict;
+
+    /**
      * Constructor.
      *
      * TODO
@@ -30,6 +37,8 @@ class Horde_Core_Ui_Pager extends Horde_Core_Ui_Widget
 
         parent::__construct($name, $vars, $config);
 
+        $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../locale');
+
         // @todo Make sure 'url' argument is a Horde_Url object.
         if (!($this->_config['url'] instanceof Horde_Url)) {
             $this->_config['url'] = new Horde_Url($this->_config['url']);
@@ -74,7 +83,7 @@ class Horde_Core_Ui_Pager extends Horde_Core_Ui_Widget
 
             $prev_text = isset($this->_config['previousHTML'])
                 ? $this->_config['previousHTML']
-                : htmlspecialchars(_("<Previous"));
+                : htmlspecialchars($this->_coreDict->t("<Previous"));
 
             $html .= Horde::link($link, '', 'prev') . $prev_text . '</a>';
         }
@@ -117,7 +126,7 @@ class Horde_Core_Ui_Pager extends Horde_Core_Ui_Widget
 
             $next_text = isset($this->_config['nextHTML'])
                 ? $this->_config['nextHTML']
-                : htmlspecialchars(_("Next>"));
+                : htmlspecialchars($this->_coreDict->t("Next>"));
 
             $html .= ' ' . Horde::link($link, '', 'next') . $next_text . '</a>';
         }
index e9eea05..724927a 100644 (file)
@@ -16,6 +16,25 @@ class Horde_Core_Ui_VarRenderer_Html extends Horde_Core_Ui_VarRenderer
 {
     protected $_onLoadJS = array();
 
+    /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_coreDict;
+
+    /**
+     * Constructs a new renderer.
+     *
+     * @param array $params  The name of the variable which will track this UI
+     *                       widget's state.
+     */
+    public function __construct($params = array())
+    {
+        parent::__construct($params);
+        $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../../locale');
+    }
+
     protected function _renderVarInputDefault($form, &$var, &$vars)
     {
         return '<strong>Warning:</strong> Unknown variable type ' .
@@ -199,7 +218,7 @@ class Horde_Core_Ui_VarRenderer_Html extends Horde_Core_Ui_VarRenderer
             $html .= sprintf('<input class="button" name="%s" id="%s" type="submit" value="%s" /> ',
                              '_do_' . $varname,
                              '_do_' . $varname,
-                             _("Upload"));
+                             $this->_coreDict->t("Upload"));
         }
 
         if (!empty($image['img'])) {
@@ -220,29 +239,29 @@ class Horde_Core_Ui_VarRenderer_Html extends Horde_Core_Ui_VarRenderer
             }
 
             /* Reset. */
-            $html .= Horde::link('#', _("Reset"), '', '', 'showImage(\'' . $img . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/refresh.png', _("Reset")) . '</a>';
+            $html .= Horde::link('#', $this->_coreDict->t("Reset"), '', '', 'showImage(\'' . $img . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/refresh.png', $this->_coreDict->t("Reset")) . '</a>';
 
             /* Rotate 270. */
-            $html .= Horde::link('#', _("Rotate Left"), '', '', 'showImage(\'' . $img->copy()->add(array('a' => 'rotate', 'v' => '270')) . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/rotate-270.png', _("Rotate Left")) . '</a>';
+            $html .= Horde::link('#', $this->_coreDict->t("Rotate Left"), '', '', 'showImage(\'' . $img->copy()->add(array('a' => 'rotate', 'v' => '270')) . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/rotate-270.png', $this->_coreDict->t("Rotate Left")) . '</a>';
 
             /* Rotate 180. */
-            $html .= Horde::link('#', _("Rotate 180"), '', '', 'showImage(\'' . $img->copy()->add(array('a' => 'rotate', 'v' => '180')) . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/rotate-180.png', _("Rotate 180")) . '</a>';
+            $html .= Horde::link('#', $this->_coreDict->t("Rotate 180"), '', '', 'showImage(\'' . $img->copy()->add(array('a' => 'rotate', 'v' => '180')) . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/rotate-180.png', $this->_coreDict->t("Rotate 180")) . '</a>';
 
             /* Rotate 90. */
-            $html .= Horde::link('#', _("Rotate Right"), '', '', 'showImage(\'' . $img->copy()->add(array('a' => 'rotate', 'v' => '90')) . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/rotate-90.png', _("Rotate Right")) . '</a>';
+            $html .= Horde::link('#', $this->_coreDict->t("Rotate Right"), '', '', 'showImage(\'' . $img->copy()->add(array('a' => 'rotate', 'v' => '90')) . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/rotate-90.png', $this->_coreDict->t("Rotate Right")) . '</a>';
 
             /* Flip image. */
-            $html .= Horde::link('#', _("Flip"), '', '', 'showImage(\'' . $img->copy()->add('a', 'flip') . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/flip.png', _("Flip")) . '</a>';
+            $html .= Horde::link('#', $this->_coreDict->t("Flip"), '', '', 'showImage(\'' . $img->copy()->add('a', 'flip') . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/flip.png', $this->_coreDict->t("Flip")) . '</a>';
 
             /* Mirror image. */
-            $html .= Horde::link('#', _("Mirror"), '', '', 'showImage(\'' . $img->copy()->add('a', 'mirror') . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/mirror.png', _("Mirror")) . '</a>';
+            $html .= Horde::link('#', $this->_coreDict->t("Mirror"), '', '', 'showImage(\'' . $img->copy()->add('a', 'mirror') . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/mirror.png', $this->_coreDict->t("Mirror")) . '</a>';
 
             /* Apply grayscale. */
-            $html .= Horde::link('#', _("Grayscale"), '', '', 'showImage(\'' . $img->copy()->add('a', 'grayscale') . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/grayscale.png', _("Grayscale")) . '</a>';
+            $html .= Horde::link('#', $this->_coreDict->t("Grayscale"), '', '', 'showImage(\'' . $img->copy()->add('a', 'grayscale') . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/grayscale.png', $this->_coreDict->t("Grayscale")) . '</a>';
 
             /* Resize width. */
             $html .= sprintf('%s<input type="text" size="4" onchange="src=getResizeSrc(\'%s\', \'%s\');showImage(src, \'_p_%s\', true);" %s />',
-                   _("w:"),
+                   $this->_coreDict->t("w:"),
                    $img->copy()->add('a', 'resize'),
                    $varname,
                    $varname,
@@ -250,14 +269,14 @@ class Horde_Core_Ui_VarRenderer_Html extends Horde_Core_Ui_VarRenderer
 
             /* Resize height. */
             $html .= sprintf('%s<input type="text" size="4" onchange="src=getResizeSrc(\'%s\', \'%s\');showImage(src, \'_p_%s\', true);" %s />',
-                   _("h:"),
+                   $this->_coreDict->t("h:"),
                    $img->copy()->add('a', 'resize'),
                    $varname,
                    $varname,
                    $this->_genID('_h_' . $varname));
 
             /* Apply fixed ratio resize. */
-            $html .= Horde::link('#', _("Fix ratio"), '', '', 'src=getResizeSrc(\'' . $img->copy()->add('a', 'resize') . '\', \'' . $varname . '\', \'1\');showImage(src, \'_p_' . $varname . '\', true);') . Horde::img('ratio.png', _("Fix ratio")) . '</a>';
+            $html .= Horde::link('#', $this->_coreDict->t("Fix ratio"), '', '', 'src=getResizeSrc(\'' . $img->copy()->add('a', 'resize') . '\', \'' . $varname . '\', \'1\');showImage(src, \'_p_' . $varname . '\', true);') . Horde::img('ratio.png', $this->_coreDict->t("Fix ratio")) . '</a>';
 
             /* Keep also original if it has been requested. */
             if ($var->type->getProperty('show_keeporig')) {
@@ -265,7 +284,7 @@ class Horde_Core_Ui_VarRenderer_Html extends Horde_Core_Ui_VarRenderer
                                  $varname . '[keep_orig]',
                                  $varname . '[keep_orig]',
                                  !empty($image['keep_orig']) ? ' checked="checked"' : '',
-                                 _("Keep original?"));
+                                 $this->_coreDict->t("Keep original?"));
             }
 
             /* The preview image element. */
@@ -317,7 +336,7 @@ class Horde_Core_Ui_VarRenderer_Html extends Horde_Core_Ui_VarRenderer
                     'Horde_Html_Helper.iconlist' => $icon_list
                 ));
 
-                $html .= Horde::link('#', _("Emoticons"), '', '', 'Horde_Html_Helper.open(\'emoticons\', \'' . $var->getVarName() . '\'); return false;') . Horde::img('emoticons/smile.png', _("Emoticons"), 'id="' . $imgId . '"') . '</a>';
+                $html .= Horde::link('#', $this->_coreDict->t("Emoticons"), '', '', 'Horde_Html_Helper.open(\'emoticons\', \'' . $var->getVarName() . '\'); return false;') . Horde::img('emoticons/smile.png', $this->_coreDict->t("Emoticons"), 'id="' . $imgId . '"') . '</a>';
             }
             $html .= '</td></tr><tr><td><div ' . $this->_genID('htmlhelper_' . $var->getVarName()) . ' class="control"></div></td></tr></table>' . "\n";
         }
@@ -397,7 +416,7 @@ class Horde_Core_Ui_VarRenderer_Html extends Horde_Core_Ui_VarRenderer
         $time = $var->type->getTimeParts($var->getValue($vars));
 
         /* Output hours. */
-        $hours = array('' => _("hh"));
+        $hours = array('' => $this->_coreDict->t("hh"));
         for ($i = 0; $i <= 23; $i++) {
             $hours[$i] = $i;
         }
@@ -408,7 +427,7 @@ class Horde_Core_Ui_VarRenderer_Html extends Horde_Core_Ui_VarRenderer
                         $this->selectOptions($hours, ($time['hour'] === '') ? '' : $time['hour']));
 
         /* Output minutes. */
-        $minutes = array('' => _("mm"));
+        $minutes = array('' => $this->_coreDict->t("mm"));
         for ($i = 0; $i <= 59; $i++) {
             $m = sprintf('%02d', $i);
             $minutes[$m] = $m;
@@ -425,7 +444,7 @@ class Horde_Core_Ui_VarRenderer_Html extends Horde_Core_Ui_VarRenderer
         }
 
         /* Output seconds. */
-        $seconds = array('' => _("ss"));
+        $seconds = array('' => $this->_coreDict->t("ss"));
         for ($i = 0; $i <= 59; $i++) {
             $s = sprintf('%02d', $i);
             $seconds[$s] = $s;
@@ -440,20 +459,20 @@ class Horde_Core_Ui_VarRenderer_Html extends Horde_Core_Ui_VarRenderer
     protected function _renderVarInput_monthyear($form, &$var, &$vars)
     {
         $dates = array();
-        $dates['month'] = array('' => _("MM"),
-                                1 => _("January"),
-                                2 => _("February"),
-                                3 => _("March"),
-                                4 => _("April"),
-                                5 => _("May"),
-                                6 => _("June"),
-                                7 => _("July"),
-                                8 => _("August"),
-                                9 => _("September"),
-                                10 => _("October"),
-                                11 => _("November"),
-                                12 => _("December"));
-        $dates['year'] = array('' => _("YYYY"));
+        $dates['month'] = array('' => $this->_coreDict->t("MM"),
+                                1 => $this->_coreDict->t("January"),
+                                2 => $this->_coreDict->t("February"),
+                                3 => $this->_coreDict->t("March"),
+                                4 => $this->_coreDict->t("April"),
+                                5 => $this->_coreDict->t("May"),
+                                6 => $this->_coreDict->t("June"),
+                                7 => $this->_coreDict->t("July"),
+                                8 => $this->_coreDict->t("August"),
+                                9 => $this->_coreDict->t("September"),
+                                10 => $this->_coreDict->t("October"),
+                                11 => $this->_coreDict->t("November"),
+                                12 => $this->_coreDict->t("December"));
+        $dates['year'] = array('' => $this->_coreDict->t("YYYY"));
         if ($var->type->getProperty('start_year') > $var->type->getProperty('end_year')) {
             for ($i = $var->type->getProperty('start_year'); $i >= $var->type->getProperty('end_year'); $i--) {
                 $dates['year'][$i] = $i;
@@ -478,24 +497,24 @@ class Horde_Core_Ui_VarRenderer_Html extends Horde_Core_Ui_VarRenderer
     protected function _renderVarInput_monthdayyear($form, &$var, &$vars)
     {
         $dates = array();
-        $dates['month'] = array(''   => _("MM"),
-                                '1'  => _("January"),
-                                '2'  => _("February"),
-                                '3'  => _("March"),
-                                '4'  => _("April"),
-                                '5'  => _("May"),
-                                '6'  => _("June"),
-                                '7'  => _("July"),
-                                '8'  => _("August"),
-                                '9'  => _("September"),
-                                '10' => _("October"),
-                                '11' => _("November"),
-                                '12' => _("December"));
-        $dates['day'] = array('' => _("DD"));
+        $dates['month'] = array(''   => $this->_coreDict->t("MM"),
+                                '1'  => $this->_coreDict->t("January"),
+                                '2'  => $this->_coreDict->t("February"),
+                                '3'  => $this->_coreDict->t("March"),
+                                '4'  => $this->_coreDict->t("April"),
+                                '5'  => $this->_coreDict->t("May"),
+                                '6'  => $this->_coreDict->t("June"),
+                                '7'  => $this->_coreDict->t("July"),
+                                '8'  => $this->_coreDict->t("August"),
+                                '9'  => $this->_coreDict->t("September"),
+                                '10' => $this->_coreDict->t("October"),
+                                '11' => $this->_coreDict->t("November"),
+                                '12' => $this->_coreDict->t("December"));
+        $dates['day'] = array('' => $this->_coreDict->t("DD"));
         for ($i = 1; $i <= 31; $i++) {
             $dates['day'][$i] = $i;
         }
-        $dates['year'] = array('' => _("YYYY"));
+        $dates['year'] = array('' => $this->_coreDict->t("YYYY"));
         if ($var->type->getProperty('start_year') > $var->type->getProperty('end_year')) {
             for ($i = $var->type->getProperty('start_year'); $i >= $var->type->getProperty('end_year'); $i--) {
                 $dates['year'][$i] = $i;
@@ -524,7 +543,7 @@ class Horde_Core_Ui_VarRenderer_Html extends Horde_Core_Ui_VarRenderer
             $GLOBALS['browser']->hasFeature('javascript')) {
             Horde_Core_Ui_JsCalendar::init();
             $imgId = $this->_genID($var->getVarName(), false) . 'goto';
-            $html .= Horde::link('#', _("Select a date"), '', '', 'Horde_Calendar.open(\'' . $imgId . '\', null)') . Horde::img('calendar.png', _("Calendar"), 'id="' . $imgId . '"') . "</a>\n";
+            $html .= Horde::link('#', $this->_coreDict->t("Select a date"), '', '', 'Horde_Calendar.open(\'' . $imgId . '\', null)') . Horde::img('calendar.png', $this->_coreDict->t("Calendar"), 'id="' . $imgId . '"') . "</a>\n";
         }
 
         return $html;
@@ -550,7 +569,7 @@ class Horde_Core_Ui_VarRenderer_Html extends Horde_Core_Ui_VarRenderer
         $value = @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset);
         $html = '<ul class="sound-list">';
         if (!$var->isRequired()) {
-            $html .= '<li><label><input type="radio" id="' . $varname . '" name="' . $varname . '" value=""' . (!$value ? ' checked="checked"' : '') . ' /> ' . _("No Sound") . '</label></li>';
+            $html .= '<li><label><input type="radio" id="' . $varname . '" name="' . $varname . '" value=""' . (!$value ? ' checked="checked"' : '') . ' /> ' . $this->_coreDict->t("No Sound") . '</label></li>';
         }
         foreach ($var->type->getSounds() as $sound) {
             $sound = @htmlspecialchars($sound, ENT_QUOTES, $this->_charset);
@@ -580,9 +599,9 @@ class Horde_Core_Ui_VarRenderer_Html extends Horde_Core_Ui_VarRenderer
         if ($browser->hasFeature('javascript')) {
             Horde::addScriptFile('colorpicker.js', 'horde');
             $html .= '<td>'
-                . Horde::link('#', _("Color Picker"), '', '',
+                . Horde::link('#', $this->_coreDict->t("Color Picker"), '', '',
                               'new ColorPicker({ color: \'' . htmlspecialchars($color) . '\', offsetParent: Event.element(event), update: [[\'' . $varname . '\', \'value\'], [\'' . $varname . '\', \'background\']] }); return false;')
-                . Horde::img('colorpicker.png', _("Color Picker"), 'height="16"') . '</a></td>';
+                . Horde::img('colorpicker.png', $this->_coreDict->t("Color Picker"), 'height="16"') . '</a></td>';
         }
         return $html . '</tr></table>';
     }
@@ -603,8 +622,8 @@ class Horde_Core_Ui_VarRenderer_Html extends Horde_Core_Ui_VarRenderer
             '[list]" onchange="' . $instance . '.deselectHeader();" ' .
             $this->_genID($varname . '[list]') . '>' .
             $var->type->getOptions($var->getValue($vars)) . '</select><div class="leftFloat">' .
-            Horde::link('#', _("Move up"), '', '', $instance . '.moveColumnUp(); return false;') . Horde::img('nav/up.png', _("Move up")) . '</a><br />' .
-            Horde::link('#', _("Move up"), '', '', $instance . '.moveColumnDown(); return false;') . Horde::img('nav/down.png', _("Move down")) . '</a></div>' .
+            Horde::link('#', $this->_coreDict->t("Move up"), '', '', $instance . '.moveColumnUp(); return false;') . Horde::img('nav/up.png', $this->_coreDict->t("Move up")) . '</a><br />' .
+            Horde::link('#', $this->_coreDict->t("Move up"), '', '', $instance . '.moveColumnDown(); return false;') . Horde::img('nav/down.png', $this->_coreDict->t("Move down")) . '</a></div>' .
             '<script type="text/javascript">' . "\n" .
             sprintf('%1$s = new Horde_Form_Sorter(\'%1$s\', \'%2$s\', \'%3$s\');' . "\n",
                     $instance, $varname, $var->type->getHeader()) .
@@ -632,10 +651,10 @@ class Horde_Core_Ui_VarRenderer_Html extends Horde_Core_Ui_VarRenderer
             $var->type->getOptions(0, $form->getName(), $var->getVarName()) .
             '</select></td><td>' .
             '<a href="#" onclick="Horde_Form_Assign.move(\'' . $form->getName() . '\', \'' . $var->getVarName() . '\', 0); return false;">' .
-            Horde::img('rhand.png', _("Add")) .
+            Horde::img('rhand.png', $this->_coreDict->t("Add")) .
             '</a><br /><a href="#" onclick="Horde_Form_Assign.move(\'' .
             $form->getName() . '\', \'' . $var->getVarName() . '\', 1); return false;">' .
-            Horde::img('lhand.png', _("Remove")) .
+            Horde::img('lhand.png', $this->_coreDict->t("Remove")) .
             '</a></td><td>' .
             sprintf('<select name="%s__right" multiple="multiple" size="%d" style="width:%s"%s>',
                     $name, $size, $width,
@@ -729,7 +748,7 @@ class Horde_Core_Ui_VarRenderer_Html extends Horde_Core_Ui_VarRenderer
                        @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset),
                        $this->_getActionScripts($form, $var),
                        $this->_multiSelectOptions($values, $selected)) .
-            "<br />\n" . _("To select multiple items, hold down the Control (PC) or Command (Mac) key while clicking.") . "\n";
+            "<br />\n" . $this->_coreDict->t("To select multiple items, hold down the Control (PC) or Command (Mac) key while clicking.") . "\n";
     }
 
     protected function _renderVarInput_keyval_multienum($form, &$var, &$vars)
@@ -756,9 +775,9 @@ class Horde_Core_Ui_VarRenderer_Html extends Horde_Core_Ui_VarRenderer
             $form_name = $form->getName();
             $var_name = $var->getVarName() . '[]';
             $function_name = 'select'  . $form_name . $var->getVarName();
-            $enable = _("Select all");
-            $disable = _("Select none");
-            $invert = _("Invert selection");
+            $enable = $this->_coreDict->t("Select all");
+            $disable = $this->_coreDict->t("Select none");
+            $invert = $this->_coreDict->t("Invert selection");
             $html .= <<<EOT
 <script type="text/javascript">
 function $function_name()
@@ -828,7 +847,7 @@ EOT;
                 $html .= sprintf('<select %s name="%s[n][r]"><option value="">%s</option>%s</select><br />',
                        $this->_genID($varname . '[n][r]'),
                        $varname,
-                       _("-- select --"),
+                       $this->_coreDict->t("-- select --"),
                        $this->selectOptions($new_input, $var_array['n']['r']));
             } elseif ($new_input == true) {
                 $html .= sprintf('<input %s type="text" name="%s[n][r]" value="%s" />',
@@ -950,7 +969,7 @@ EOT;
         }
 
         if ($GLOBALS['browser']->hasFeature('javascript')) {
-            $html .= Horde::link($GLOBALS['registry']->get('webroot', 'horde') . '/services/obrowser/', _("Select an object"), '', '_blank', 'obrowserWindow = ' . Horde::popupJs($GLOBALS['registry']->get('webroot', 'horde') . '/services/obrowser/', array('urlencode' => true)) . 'obrowserWindowName = obrowserWindow.name; return false;') . Horde::img('tree/leaf.png', _("Object")) . "</a>\n";
+            $html .= Horde::link($GLOBALS['registry']->get('webroot', 'horde') . '/services/obrowser/', $this->_coreDict->t("Select an object"), '', '_blank', 'obrowserWindow = ' . Horde::popupJs($GLOBALS['registry']->get('webroot', 'horde') . '/services/obrowser/', array('urlencode' => true)) . 'obrowserWindowName = obrowserWindow.name; return false;') . Horde::img('tree/leaf.png', $this->_coreDict->t("Object")) . "</a>\n";
         }
 
         return $html;
@@ -969,7 +988,7 @@ EOT;
                        $varname,
                        strlen($var->type->getText()),
                        @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset)) .
-            '<br />' . _("Enter the letters below:") . '<br />' .
+            '<br />' . $this->_coreDict->t("Enter the letters below:") . '<br />' .
             $this->_renderVarDisplay_figlet($form, $var, $vars);
     }
 
@@ -981,7 +1000,7 @@ EOT;
                        $varname,
                        strlen($var->type->getText()),
                        @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset)) .
-            '<br />' . _("Enter the letters below:") . '<br />' .
+            '<br />' . $this->_coreDict->t("Enter the letters below:") . '<br />' .
             $this->_renderVarDisplay_captcha($form, $var, $vars);
     }
 
@@ -1074,7 +1093,7 @@ EOT;
 
     protected function _renderVarDisplay_boolean($form, &$var, &$vars)
     {
-        return $var->getValue($vars) ? _("Yes") : _("No");
+        return $var->getValue($vars) ? $this->_coreDict->t("Yes") : $this->_coreDict->t("No");
     }
 
     protected function _renderVarDisplay_enum($form, &$var, &$vars)
@@ -1082,7 +1101,7 @@ EOT;
         $values = $var->getValues();
         $value = $var->getValue($vars);
         if (count($values) == 0) {
-            return _("No values");
+            return $this->_coreDict->t("No values");
         } elseif (isset($values[$value]) && $value != '') {
             return @htmlspecialchars($values[$value], ENT_QUOTES, $this->_charset);
         }
@@ -1092,7 +1111,7 @@ EOT;
     {
         $values = $var->getValues();
         if (count($values) == 0) {
-            return _("No values");
+            return $this->_coreDict->t("No values");
         } elseif (isset($values[$var->getValue($vars)])) {
             return @htmlspecialchars($values[$var->getValue($vars)], ENT_QUOTES, $this->_charset);
         }
@@ -1103,7 +1122,7 @@ EOT;
         $values = $var->getValues();
         $on = $var->getValue($vars);
         if (!count($values) || !count($on)) {
-            return _("No values");
+            return $this->_coreDict->t("No values");
         } else {
             $display = array();
             foreach ($values as $value => $name) {
@@ -1120,7 +1139,7 @@ EOT;
         $values = $var->getValues();
         $on = $var->getValue($vars);
         if (!count($values) || !count($on)) {
-            return _("No values");
+            return $this->_coreDict->t("No values");
         } else {
             $display = array();
             foreach ($values as $value => $name) {
@@ -1169,7 +1188,7 @@ EOT;
 
         if ($number && $registry->hasMethod('telephony/dial')) {
             $url = $registry->call('telephony/dial', array($number));
-            $label = sprintf(_("Dial %s"), $number);
+            $label = sprintf($this->_coreDict->t("Dial %s"), $number);
             $html .= ' ' . Horde::link($url, $label) . Horde::img('phone.png', $label) . '</a>';
         }
 
@@ -1185,7 +1204,7 @@ EOT;
         $number = $var->getValue($vars);
         if ($number && $registry->hasMethod('sms/compose')) {
             $url = $registry->link('sms/compose', array('to' => $number));
-            $html .= ' ' . Horde::link($url, _("Send SMS")) . Horde::img('mobile.png', _("Send SMS")) . '</a>';
+            $html .= ' ' . Horde::link($url, $this->_coreDict->t("Send SMS")) . Horde::img('mobile.png', $this->_coreDict->t("Send SMS")) . '</a>';
         }
 
         return $html;
@@ -1209,14 +1228,14 @@ EOT;
                 /* Multimap.co.uk generated map */
                 $mapurl = 'http://www.multimap.com/map/browse.cgi?pc='
                     . urlencode($info['zip']);
-                $desc = _("Multimap UK map");
+                $desc = $this->_coreDict->t("Multimap UK map");
                 $icon = 'map.png';
                 break;
 
             case 'au':
                 /* Whereis.com.au generated map */
                 $mapurl = 'http://www.whereis.com.au/whereis/mapping/geocodeAddress.do?';
-                $desc = _("Whereis Australia map");
+                $desc = $this->_coreDict->t("Whereis Australia map");
                 $icon = 'map.png';
                 /* See if it's the street number & name. */
                 if (isset($info['streetNumber']) &&
@@ -1240,7 +1259,7 @@ EOT;
                 /* American/Canadian address style. */
                 /* Mapquest generated map */
                 $mapurl = 'http://www.mapquest.com/maps/map.adp?size=big&zoom=7';
-                $desc = _("MapQuest map");
+                $desc = $this->_coreDict->t("MapQuest map");
                 $icon = 'map.png';
                 if (!empty($info['street'])) {
                     $mapurl .= '&address=' . urlencode($info['street']);
@@ -1260,7 +1279,7 @@ EOT;
 
                 /* Yahoo! generated map. */
                 $mapurl2 = 'http://us.rd.yahoo.com/maps/home/submit_a/*-http://maps.yahoo.com/maps?srchtype=a&getmap=Get+Map&';
-                $desc2 = _("Yahoo! map");
+                $desc2 = $this->_coreDict->t("Yahoo! map");
                 $icon2 = 'map.png';
                 if (!empty($info['street'])) {
                     $mapurl2 .= '&addr=' . urlencode($info['street']);
@@ -1289,7 +1308,7 @@ EOT;
                 $google_icon = 'map_eu.png';
                 /* Mapquest generated map. */
                 $mapurl2 = 'http://www.mapquest.com/maps/map.adp?country=' . Horde_String::upper($info['country']);
-                $desc2 = _("MapQuest map");
+                $desc2 = $this->_coreDict->t("MapQuest map");
                 $icon2 = 'map_eu.png';
                 if (!empty($info['street'])) {
                     $mapurl2 .= '&address=' . urlencode($info['street']);
@@ -1314,7 +1333,7 @@ EOT;
 
         /* Google generated map. */
         if ($address) {
-            $html .= '&nbsp;' . Horde::link(Horde::externalUrl('http://maps.google.com/maps?q=' . urlencode(preg_replace('/\r?\n/', ',', $address)) . '&hl=en'), _("Google Maps"), null, '_blank') . Horde::img($google_icon, _("Google Maps")) . '</a>';
+            $html .= '&nbsp;' . Horde::link(Horde::externalUrl('http://maps.google.com/maps?q=' . urlencode(preg_replace('/\r?\n/', ',', $address)) . '&hl=en'), $this->_coreDict->t("Google Maps"), null, '_blank') . Horde::img($google_icon, $this->_coreDict->t("Google Maps")) . '</a>';
         }
 
         return $html;
@@ -1508,7 +1527,7 @@ EOT;
                     if ($GLOBALS['registry']->hasMethod('files/getViewLink')) {
                         $filename = basename($filename);
                         $url = $GLOBALS['registry']->call('files/getViewLink', array($dir, $filename));
-                        $filename = Horde::link($url, _("Preview"), null, 'form_file_view') . @htmlspecialchars(Horde_Util::realPath($dir . '/' . $filename), ENT_QUOTES, $this->_charset) . '</a>';
+                        $filename = Horde::link($url, $this->_coreDict->t("Preview"), null, 'form_file_view') . @htmlspecialchars(Horde_Util::realPath($dir . '/' . $filename), ENT_QUOTES, $this->_charset) . '</a>';
                     } else {
                         if (!empty($dir) && ($dir != '.')) {
                             $filename = $dir . '/' . $filename;
index 7adc10d..c9852ac 100644 (file)
@@ -21,9 +21,9 @@ class Horde_Core_Ui_VarRenderer_TablesetHtml extends Horde_Core_Ui_VarRenderer_H
         $checkedValues = $var->getValue($vars);
         $actions = $this->_getActionScripts($form, $var);
         $function_name = 'select'  . $form_name . $var->getVarName();
-        $enable = _("Select all");
-        $disable = _("Select none");
-        $invert = _("Invert selection");
+        $enable = $this->_coreDict->t("Select all");
+        $disable = $this->_coreDict->t("Select none");
+        $invert = $this->_coreDict->t("Invert selection");
 
         Horde::addScriptFile('tables.js', 'horde');
 
index 7aa4ece..1f2160e 100644 (file)
@@ -213,9 +213,10 @@ class Horde_Help
             return '';
         }
 
+        $dict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../locale');
         $url = Horde::getServiceLink('help', $module)->add('topic', $topic);
-        return $url->link(array('title' => _("Help"), 'class' => 'helplink', 'target' => 'hordehelpwin', 'onclick' => Horde::popupJs($url, array('urlencode' => true)) . 'return false;'))
-            . Horde::img('help.png', _("Help")) . '</a>';
+        return $url->link(array('title' => $dict->t("Help"), 'class' => 'helplink', 'target' => 'hordehelpwin', 'onclick' => Horde::popupJs($url, array('urlencode' => true)) . 'return false;'))
+            . Horde::img('help.png', $dict->t("Help")) . '</a>';
     }
 
 
index 82ffb91..b2fe55d 100644 (file)
@@ -41,6 +41,13 @@ class Horde_Menu
     protected $_mask;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_coreDict;
+
+    /**
      * Constructor
      */
     public function __construct($mask = self::MASK_ALL)
@@ -50,6 +57,8 @@ class Horde_Menu
 
         /* Location of the menufile. */
         $this->_menufile = $GLOBALS['registry']->get('fileroot') . '/config/menu.php';
+
+        $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../locale');
     }
 
     /**
@@ -170,14 +179,14 @@ class Horde_Menu
         if (($this->_mask & self::MASK_PREFS) &&
             $this->showService('prefs') &&
             ($url = Horde::getServiceLink('prefs', $app))) {
-            $this->add($url, _("_Preferences"), 'prefs.png');
+            $this->add($url, $this->_coreDict->t("_Preferences"), 'prefs.png');
         }
 
         /* Add problem link. */
         if (($this->_mask & self::MASK_PROBLEM) &&
             $this->showService('problem') &&
             ($problem_link = Horde::getServiceLink('problem', $app))) {
-            $this->add($problem_link, _("Problem"), 'problem.png');
+            $this->add($problem_link, $this->_coreDict->t("Problem"), 'problem.png');
         }
 
         /* Add help link. */
@@ -185,7 +194,7 @@ class Horde_Menu
             $this->showService('help') &&
             ($help_link = Horde::getServiceLink('help', $app))) {
             Horde::
-            $this->add($help_link, _("Help"), 'help_index.png', null, 'help', Horde::popupJs($help_link, array('urlencode' => true)) . 'return false;', 'helplink');
+            $this->add($help_link, $this->_coreDict->t("Help"), 'help_index.png', null, 'help', Horde::popupJs($help_link, array('urlencode' => true)) . 'return false;', 'helplink');
         }
 
         /* Login/Logout. */
@@ -201,12 +210,12 @@ class Horde_Menu
             if ($registry->getAuth()) {
                 if ((!$prefs->getValue('show_sidebar') || $this->showService('logout')) &&
                     ($logout_link = Horde::getServiceLink('logout', $app))) {
-                    $this->add($logout_link, _("_Log out"), 'logout.png', null, $auth_target, null, '__noselection');
+                    $this->add($logout_link, $this->_coreDict->t("_Log out"), 'logout.png', null, $auth_target, null, '__noselection');
                 }
             } else {
                 if ($this->showService('login') &&
                     ($login_link = Horde::getServiceLink('login', $app))) {
-                    $this->add($login_link->add('url', Horde::selfUrl(true, true, true)), _("_Log in"), 'login.png', null, $auth_target, null, '__noselection');
+                    $this->add($login_link->add('url', Horde::selfUrl(true, true, true)), $this->_coreDict->t("_Log in"), 'login.png', null, $auth_target, null, '__noselection');
                 }
             }
         }
index 5f991e5..fd719e1 100644 (file)
@@ -64,6 +64,13 @@ class Horde_Registry
     protected $_apis = array();
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_coreDict;
+
+    /**
      * Hash storing information on each registry-aware application.
      *
      * @var array
@@ -386,13 +393,14 @@ class Horde_Registry
 
         /* Initialize the localization routines and variables. */
         $this->setLanguageEnvironment(null, 'horde');
+        $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../locale');
 
         $this->_regmtime = max(filemtime(HORDE_BASE . '/config/registry.php'),
                                filemtime(HORDE_BASE . '/config/registry.d'));
 
         /* Stop system if Horde is inactive. */
         if ($this->applications['horde']['status'] == 'inactive') {
-            throw new Horde_Exception(_("This system is currently deactivated."));
+            throw new Horde_Exception($this->_coreDict->t("This system is currently deactivated."));
         }
 
         /* Initialize notification object. Always attach status listener by
@@ -1040,7 +1048,7 @@ class Horde_Registry
         }
 
         if (!isset($this->applications[$app])) {
-            throw new Horde_Exception(sprintf(_("\"%s\" is not configured in the Horde Registry."), $app));
+            throw new Horde_Exception(sprintf($this->_coreDict->t("\"%s\" is not configured in the Horde Registry."), $app));
         }
 
         return str_replace('%application%', $this->applications[$app]['fileroot'], $path);
@@ -1138,7 +1146,7 @@ class Horde_Registry
                 }
 
                 Horde::logMessage(sprintf('%s does not have READ permission for %s', $this->getAuth() ? 'User ' . $this->getAuth() : 'Guest user', $app), 'DEBUG');
-                throw new Horde_Exception(sprintf(_('%s is not authorized for %s.'), $this->getAuth() ? 'User ' . $this->getAuth() : 'Guest user', $this->applications[$app]['name']), self::PERMISSION_DENIED);
+                throw new Horde_Exception(sprintf($this->_coreDict->t('%s is not authorized for %s.'), $this->getAuth() ? 'User ' . $this->getAuth() : 'Guest user', $this->applications[$app]['name']), self::PERMISSION_DENIED);
             }
         }
 
@@ -1373,7 +1381,7 @@ class Horde_Registry
         }
 
         return ($parameter == 'name')
-            ? _($pval)
+            ? $this->_coreDict->t($pval)
             : $pval;
     }
 
@@ -1492,7 +1500,7 @@ class Horde_Registry
             return $this->applications[$app]['webroot'] . '/' . (isset($this->applications[$app]['initial_page']) ? $this->applications[$app]['initial_page'] : '');
         }
 
-        throw new Horde_Exception(sprintf(_("\"%s\" is not configured in the Horde Registry."), $app));
+        throw new Horde_Exception(sprintf($this->_coreDict->t("\"%s\" is not configured in the Horde Registry."), $app));
     }
 
     /**
@@ -1706,7 +1714,7 @@ class Horde_Registry
     {
         if (Horde_Cli::runningFromCLI()) {
             $cli = new Horde_Cli();
-            $cli->fatal(_("You are not authenticated."));
+            $cli->fatal($this->_coreDict->t("You are not authenticated."));
         }
 
         if (is_null($e)) {
index d31cf24..58a20c3 100644 (file)
@@ -30,6 +30,21 @@ class Horde_Script_Files
     protected $_included = array();
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_coreDict;
+
+    /**
+     * Constructor.
+     */
+    public function __construct()
+    {
+        $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../locale');
+    }
+
+    /**
      * Adds the javascript code to the output (if output has already started)
      * or to the list of script files to include.
      *
@@ -110,7 +125,7 @@ class Horde_Script_Files
         // Add localized string for popup.js
         if (($file == 'popup.js') && ($app == 'horde')) {
             Horde::addInlineJsVars(array(
-                'Horde.popup_block_text' => _("A popup window could not be opened. Your browser may be blocking popups.")
+                'Horde.popup_block_text' => $this->_coreDict->t("A popup window could not be opened. Your browser may be blocking popups.")
             ), 'dom');
         }
 
index 09ba762..bd7f742 100644 (file)
@@ -30,6 +30,13 @@ class Horde_Crypt
     protected $_tempdir;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Attempts to return a concrete Horde_Crypt instance based on $driver.
      *
      * @param string $driver  Either a driver name, or the full class name to
@@ -66,16 +73,23 @@ class Horde_Crypt
      * Constructor.
      *
      * @param array $params  Configuration parameters:
-     * <pre>
-     * 'email_charset' - (string) The default email charset.
-     *                   DEFAULT: NONE
-     * 'temp' - (string) [REQUIRED] Location of temporary directory.
-     * </pre>
+     *                       - 'email_charset': (string) The default email
+     *                                          charset. DEFAULT: NONE
+     *                       - 'temp': (string) [REQUIRED] Location of
+     *                                          temporary directory.
+     *                       - 'translation': (object) A translation handler
+     *                                        implementing Horde_Translation.
      *
      * @throws InvalidArgumentException
      */
     public function __construct(array $params = array())
     {
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Crypt', dirname(__FILE__) . '/../../locale');
+        }
+
         if (empty($params['temp'])) {
             throw new InvalidArgumentException('A temporary directory must be provided.');
         }
index 59608d3..c2b29c3 100644 (file)
@@ -222,9 +222,9 @@ class Horde_Crypt_Pgp extends Horde_Crypt
 
         /* If either key is empty, something went wrong. */
         if (empty($public_key) || empty($secret_key)) {
-            $msg = _("Public/Private keypair not generated successfully.");
+            $msg = $this->_dict->t("Public/Private keypair not generated successfully.");
             if (!empty($result->stderr)) {
-                $msg .= ' ' . _("Returned error message:") . ' ' . $result->stderr;
+                $msg .= ' ' . $this->_dict->t("Returned error message:") . ' ' . $result->stderr;
             }
             throw new Horde_Crypt_Exception($msg);
         }
@@ -421,10 +421,10 @@ class Horde_Crypt_Pgp extends Horde_Crypt
         if (!empty($packet_info['signature'])) {
             /* Making the property names the same width for all
              * localizations .*/
-            $leftrow = array(_("Name"), _("Key Type"), _("Key Creation"),
-                             _("Expiration Date"), _("Key Length"),
-                             _("Comment"), _("E-Mail"), _("Hash-Algorithm"),
-                             _("Key ID"), _("Key Fingerprint"));
+            $leftrow = array($this->_dict->t("Name"), $this->_dict->t("Key Type"), $this->_dict->t("Key Creation"),
+                             $this->_dict->t("Expiration Date"), $this->_dict->t("Key Length"),
+                             $this->_dict->t("Comment"), $this->_dict->t("E-Mail"), $this->_dict->t("Hash-Algorithm"),
+                             $this->_dict->t("Key ID"), $this->_dict->t("Key Fingerprint"));
             $leftwidth = array_map('strlen', $leftrow);
             $maxwidth  = max($leftwidth) + 2;
             array_walk($leftrow, array($this, '_pgpPrettyKeyFormatter'), $maxwidth);
@@ -444,15 +444,15 @@ class Horde_Crypt_Pgp extends Horde_Crypt
                 $fingerprint = isset($fingerprints[$key_info['keyid']]) ? $fingerprints[$key_info['keyid']] : null;
 
                 $msg .= $leftrow[0] . (isset($key_info['name']) ? stripcslashes($key_info['name']) : '') . "\n"
-                    . $leftrow[1] . (($key_info['key_type'] == 'public_key') ? _("Public Key") : _("Private Key")) . "\n"
+                    . $leftrow[1] . (($key_info['key_type'] == 'public_key') ? $this->_dict->t("Public Key") : $this->_dict->t("Private Key")) . "\n"
                     . $leftrow[2] . strftime("%D", $key_info['key_created']) . "\n"
-                    . $leftrow[3] . (empty($key_info['key_expires']) ? '[' . _("Never") . ']' : strftime("%D", $key_info['key_expires'])) . "\n"
+                    . $leftrow[3] . (empty($key_info['key_expires']) ? '[' . $this->_dict->t("Never") . ']' : strftime("%D", $key_info['key_expires'])) . "\n"
                     . $leftrow[4] . $key_info['key_size'] . " Bytes\n"
-                    . $leftrow[5] . (empty($key_info['comment']) ? '[' . _("None") . ']' : $key_info['comment']) . "\n"
-                    . $leftrow[6] . (empty($key_info['email']) ? '[' . _("None") . ']' : $key_info['email']) . "\n"
-                    . $leftrow[7] . (empty($key_info['micalg']) ? '[' . _("Unknown") . ']' : $key_info['micalg']) . "\n"
-                    . $leftrow[8] . (empty($key_info['keyid']) ? '[' . _("Unknown") . ']' : $key_info['keyid']) . "\n"
-                    . $leftrow[9] . (empty($fingerprint) ? '[' . _("Unknown") . ']' : $fingerprint) . "\n\n";
+                    . $leftrow[5] . (empty($key_info['comment']) ? '[' . $this->_dict->t("None") . ']' : $key_info['comment']) . "\n"
+                    . $leftrow[6] . (empty($key_info['email']) ? '[' . $this->_dict->t("None") . ']' : $key_info['email']) . "\n"
+                    . $leftrow[7] . (empty($key_info['micalg']) ? '[' . $this->_dict->t("Unknown") . ']' : $key_info['micalg']) . "\n"
+                    . $leftrow[8] . (empty($key_info['keyid']) ? '[' . $this->_dict->t("Unknown") . ']' : $key_info['keyid']) . "\n"
+                    . $leftrow[9] . (empty($fingerprint) ? '[' . $this->_dict->t("Unknown") . ']' : $fingerprint) . "\n\n";
             }
         }
 
@@ -656,7 +656,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
         /* Get e-mail address of public key. */
         $key_info = $this->pgpPacketInformation($public_key);
         if (!isset($key_info['signature']['id1']['email'])) {
-            throw new Horde_Crypt_Exception(_("Could not determine the recipient's e-mail address."));
+            throw new Horde_Crypt_Exception($this->_dict->t("Could not determine the recipient's e-mail address."));
         }
 
         /* Encrypt a test message. */
@@ -756,7 +756,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
             return substr($start, 0, $length);
         }
 
-        throw new Horde_Crypt_Exception(_("Could not obtain public key from the keyserver."));
+        throw new Horde_Crypt_Exception($this->_dict->t("Could not obtain public key from the keyserver."));
     }
 
     /**
@@ -779,7 +779,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
         try {
             $this->getPublicKeyserver($info['keyid'], $server, $timeout);
         } catch (Horde_Crypt_Exception $e) {
-            throw new Horde_Crypt_Exception(_("Key already exists on the public keyserver."));
+            throw new Horde_Crypt_Exception($this->_dict->t("Key already exists on the public keyserver."));
         }
 
         /* Connect to the public keyserver. _connectKeyserver() */
@@ -845,7 +845,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
             }
         }
 
-        throw new Horde_Crypt_Exception(_("Could not obtain public key from the keyserver."));
+        throw new Horde_Crypt_Exception($this->_dict->t("Could not obtain public key from the keyserver."));
     }
 
     /**
@@ -936,7 +936,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
         } while (++$connRefuse < self::KEYSERVER_REFUSE);
 
         if ($errno == 0) {
-            throw new Horde_Crypt_Exception(_("Connection refused to the public keyserver."));
+            throw new Horde_Crypt_Exception($this->_dict->t("Connection refused to the public keyserver."));
         } else {
             $charset = 'UTF-8';
             $lang_charset = setlocale(LC_ALL, 0);
@@ -947,7 +947,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
                     $charset = $lang_charset[1];
                 }
             }
-            throw new Horde_Crypt_Exception(sprintf(_("Connection refused to the public keyserver. Reason: %s (%s)"), Horde_String::convertCharset($errstr, $charset, 'UTF-8'), $errno));
+            throw new Horde_Crypt_Exception(sprintf($this->_dict->t("Connection refused to the public keyserver. Reason: %s (%s)"), Horde_String::convertCharset($errstr, $charset, 'UTF-8'), $errno));
         }
     }
 
@@ -1129,7 +1129,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
         $result = $this->_callGpg($cmdline, 'w', empty($params['symmetric']) ? null : $params['passphrase'], true, true);
         if (empty($result->output)) {
             $error = preg_replace('/\n.*/', '', $result->stderr);
-            throw new Horde_Crypt_Exception(_("Could not PGP encrypt message: ") . $error);
+            throw new Horde_Crypt_Exception($this->_dict->t("Could not PGP encrypt message: ") . $error);
         }
 
         return $result->output;
@@ -1161,7 +1161,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
         if (!isset($params['pubkey']) ||
             !isset($params['privkey']) ||
             !isset($params['passphrase'])) {
-            throw new Horde_Crypt_Exception(_("A public PGP key, private PGP key, and passphrase are required to sign a message."));
+            throw new Horde_Crypt_Exception($this->_dict->t("A public PGP key, private PGP key, and passphrase are required to sign a message."));
         }
 
         /* Create temp files for input. */
@@ -1198,7 +1198,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
         $result = $this->_callGpg($cmdline, 'w', $params['passphrase'], true, true);
         if (empty($result->output)) {
             $error = preg_replace('/\n.*/', '', $result->stderr);
-            throw new Horde_Crypt_Exception(_("Could not PGP sign message: ") . $error);
+            throw new Horde_Crypt_Exception($this->_dict->t("Could not PGP sign message: ") . $error);
         }
 
         return $result->output;
@@ -1237,7 +1237,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
 
         /* Check for required parameters. */
         if (!isset($params['passphrase']) && empty($params['no_passphrase'])) {
-            throw new Horde_Crypt_Exception(_("A passphrase is required to decrypt a message."));
+            throw new Horde_Crypt_Exception($this->_dict->t("A passphrase is required to decrypt a message."));
         }
 
         /* Create temp files. */
@@ -1273,7 +1273,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
         }
         if (empty($result->output)) {
             $error = preg_replace('/\n.*/', '', $result->stderr);
-            throw new Horde_Crypt_Exception(_("Could not decrypt PGP data: ") . $error);
+            throw new Horde_Crypt_Exception($this->_dict->t("Could not decrypt PGP data: ") . $error);
         }
 
         /* Create the return object. */
@@ -1304,11 +1304,11 @@ class Horde_Crypt_Pgp extends Horde_Crypt
     {
         /* Check for required parameters. */
         if (!isset($params['pubkey'])) {
-            throw new Horde_Crypt_Exception(_("A public PGP key is required to verify a signed message."));
+            throw new Horde_Crypt_Exception($this->_dict->t("A public PGP key is required to verify a signed message."));
         }
         if (($params['type'] === 'detached-signature') &&
             !isset($params['signature'])) {
-            throw new Horde_Crypt_Exception(_("The detached PGP signature block is required to verify the signed message."));
+            throw new Horde_Crypt_Exception($this->_dict->t("The detached PGP signature block is required to verify the signed message."));
         }
 
         $good_sig_flag = 0;
@@ -1403,7 +1403,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
         $pgp_sign->setType('application/pgp-signature');
         $pgp_sign->setCharset($this->_params['email_charset']);
         $pgp_sign->setDisposition('inline');
-        $pgp_sign->setDescription(Horde_String::convertCharset(_("PGP Digital Signature"), 'UTF-8', $this->_params['email_charset']));
+        $pgp_sign->setDescription(Horde_String::convertCharset($this->_dict->t("PGP Digital Signature"), 'UTF-8', $this->_params['email_charset']));
         $pgp_sign->setContents($msg_sign, array('encoding' => '7bit'));
 
         /* Get the algorithim information from the signature. Since we are
@@ -1447,7 +1447,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
         $part->setType('multipart/encrypted');
         $part->setCharset($this->_params['email_charset']);
         $part->setContentTypeParameter('protocol', 'application/pgp-encrypted');
-        $part->setDescription(Horde_String::convertCharset(_("PGP Encrypted Data"), 'UTF-8', $this->_params['email_charset']));
+        $part->setDescription(Horde_String::convertCharset($this->_dict->t("PGP Encrypted Data"), 'UTF-8', $this->_params['email_charset']));
         $part->setContents("This message is in MIME format and has been PGP encrypted.\n");
 
         $part1 = new Horde_Mime_Part();
@@ -1490,7 +1490,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
         $part->setContents("This message is in MIME format and has been PGP signed and encrypted.\n");
 
         $part->setCharset($this->_params['email_charset']);
-        $part->setDescription(Horde_String::convertCharset(_("PGP Signed/Encrypted Data"), 'UTF-8', $this->_params['email_charset']));
+        $part->setDescription(Horde_String::convertCharset($this->_dict->t("PGP Signed/Encrypted Data"), 'UTF-8', $this->_params['email_charset']));
 
         return $part;
     }
@@ -1508,7 +1508,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
         $part = new Horde_Mime_Part();
         $part->setType('application/pgp-keys');
         $part->setCharset($this->_params['email_charset']);
-        $part->setDescription(Horde_String::convertCharset(_("PGP Public Key"), 'UTF-8', $this->_params['email_charset']));
+        $part->setDescription(Horde_String::convertCharset($this->_dict->t("PGP Public Key"), 'UTF-8', $this->_params['email_charset']));
         $part->setContents($key, array('encoding' => '7bit'));
 
         return $part;
@@ -1581,7 +1581,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
                     }
                 }
             } else {
-                throw new Horde_Crypt_Exception(_("Error while talking to pgp binary."));
+                throw new Horde_Crypt_Exception($this->_dict->t("Error while talking to pgp binary."));
             }
         } elseif ($mode == 'r') {
             if ($fp = popen($cmdline, 'r')) {
@@ -1589,7 +1589,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
                     $data->stdout .= fgets($fp, 1024);
                 }
             } else {
-                throw new Horde_Crypt_Exception(_("Error while talking to pgp binary."));
+                throw new Horde_Crypt_Exception($this->_dict->t("Error while talking to pgp binary."));
             }
         }
         pclose($fp);
@@ -1641,7 +1641,7 @@ class Horde_Crypt_Pgp extends Horde_Crypt
 
         /* If the key is empty, something went wrong. */
         if (empty($results->output)) {
-            throw new Horde_Crypt_Exception(_("Revocation key not generated successfully."));
+            throw new Horde_Crypt_Exception($this->_dict->t("Revocation key not generated successfully."));
         }
 
         return $results->output;
index a05217f..d5234f0 100644 (file)
@@ -186,11 +186,11 @@ class Horde_Crypt_Smime extends Horde_Crypt
         $result = openssl_pkcs7_verify($input, PKCS7_NOVERIFY, $output);
 
         if ($result === true) {
-            throw new Horde_Crypt_Exception(_("Message Verified Successfully but the signer's certificate could not be verified."));
+            throw new Horde_Crypt_Exception($this->_dict->t("Message Verified Successfully but the signer's certificate could not be verified."));
         } elseif ($result == -1) {
-            throw new Horde_Crypt_Exception(_("Verification failed - an unknown error has occurred."));
+            throw new Horde_Crypt_Exception($this->_dict->t("Verification failed - an unknown error has occurred."));
         } else {
-            throw new Horde_Crypt_Exception(_("Verification failed - this message may have been tampered with."));
+            throw new Horde_Crypt_Exception($this->_dict->t("Verification failed - this message may have been tampered with."));
         }
 
         $ob->cert = file_get_contents($output);
@@ -228,7 +228,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
             return $ret;
         }
 
-        throw new Horde_Crypt_Exception(_("OpenSSL error: Could not extract data from signed S/MIME part."));
+        throw new Horde_Crypt_Exception($this->_dict->t("OpenSSL error: Could not extract data from signed S/MIME part."));
     }
 
     /**
@@ -249,7 +249,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
         $mime_message = Horde_Mime_Part::parseMessage($message, array('forcemime' => true));
 
         $smime_sign = $mime_message->getPart('2');
-        $smime_sign->setDescription(_("S/MIME Cryptographic Signature"));
+        $smime_sign->setDescription($this->_dict->t("S/MIME Cryptographic Signature"));
         $smime_sign->setTransferEncoding('base64', array('send' => true));
 
         $smime_part = new Horde_Mime_Part();
@@ -280,7 +280,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
 
         $msg = new Horde_Mime_Part();
         $msg->setCharset($this->_params['email_charset']);
-        $msg->setDescription(Horde_String::convertCharset(_("S/MIME Encrypted Message"), 'UTF-8', $this->_params['email_charset']));
+        $msg->setDescription(Horde_String::convertCharset($this->_dict->t("S/MIME Encrypted Message"), 'UTF-8', $this->_params['email_charset']));
         $msg->setDisposition('inline');
         $msg->setType('application/pkcs7-mime');
         $msg->setContentTypeParameter('smime-type', 'enveloped-data');
@@ -308,7 +308,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
     {
         /* Check for required parameters. */
         if (!isset($params['pubkey'])) {
-            throw new Horde_Crypt_Exception(_("A public S/MIME key is required to encrypt a message."));
+            throw new Horde_Crypt_Exception($this->_dict->t("A public S/MIME key is required to encrypt a message."));
         }
 
         /* Create temp files for input/output. */
@@ -327,7 +327,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
             }
         }
 
-        throw new Horde_Crypt_Exception(_("Could not S/MIME encrypt message."));
+        throw new Horde_Crypt_Exception($this->_dict->t("Could not S/MIME encrypt message."));
     }
 
     /**
@@ -357,7 +357,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
         if (!isset($params['pubkey']) ||
             !isset($params['privkey']) ||
             !array_key_exists('passphrase', $params)) {
-            throw new Horde_Crypt_Exception(_("A public S/MIME key, private S/MIME key, and passphrase are required to sign a message."));
+            throw new Horde_Crypt_Exception($this->_dict->t("A public S/MIME key, private S/MIME key, and passphrase are required to sign a message."));
         }
 
         /* Create temp files for input/output/certificates. */
@@ -388,7 +388,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
         }
 
         if (!$res) {
-            throw new Horde_Crypt_Exception(_("Could not S/MIME sign message."));
+            throw new Horde_Crypt_Exception($this->_dict->t("Could not S/MIME sign message."));
         }
 
         $data = file_get_contents($output);
@@ -419,7 +419,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
         if (!isset($params['pubkey']) ||
             !isset($params['privkey']) ||
             !array_key_exists('passphrase', $params)) {
-            throw new Horde_Crypt_Exception(_("A public S/MIME key, private S/MIME key, and passphrase are required to decrypt a message."));
+            throw new Horde_Crypt_Exception($this->_dict->t("A public S/MIME key, private S/MIME key, and passphrase are required to decrypt a message."));
         }
 
         /* Create temp files for input/output. */
@@ -437,7 +437,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
             return file_get_contents($output);
         }
 
-        throw new Horde_Crypt_Exception(_("Could not decrypt S/MIME data."));
+        throw new Horde_Crypt_Exception($this->_dict->t("Could not decrypt S/MIME data."));
     }
 
     /**
@@ -471,45 +471,45 @@ class Horde_Crypt_Smime extends Horde_Crypt
     {
         /* Common Fields */
         $fieldnames = array(
-            'Email' => _("Email Address"),
-            'CommonName' => _("Common Name"),
-            'Organisation' => _("Organisation"),
-            'OrganisationalUnit' => _("Organisational Unit"),
-            'Country' => _("Country"),
-            'StateOrProvince' => _("State or Province"),
-            'Location' => _("Location"),
-            'StreetAddress' => _("Street Address"),
-            'TelephoneNumber' => _("Telephone Number"),
-            'Surname' => _("Surname"),
-            'GivenName' => _("Given Name")
+            'Email' => $this->_dict->t("Email Address"),
+            'CommonName' => $this->_dict->t("Common Name"),
+            'Organisation' => $this->_dict->t("Organisation"),
+            'OrganisationalUnit' => $this->_dict->t("Organisational Unit"),
+            'Country' => $this->_dict->t("Country"),
+            'StateOrProvince' => $this->_dict->t("State or Province"),
+            'Location' => $this->_dict->t("Location"),
+            'StreetAddress' => $this->_dict->t("Street Address"),
+            'TelephoneNumber' => $this->_dict->t("Telephone Number"),
+            'Surname' => $this->_dict->t("Surname"),
+            'GivenName' => $this->_dict->t("Given Name")
         );
 
         /* Netscape Extensions */
         $fieldnames += array(
-            'netscape-cert-type' => _("Netscape certificate type"),
-            'netscape-base-url' => _("Netscape Base URL"),
-            'netscape-revocation-url' => _("Netscape Revocation URL"),
-            'netscape-ca-revocation-url' => _("Netscape CA Revocation URL"),
-            'netscape-cert-renewal-url' => _("Netscape Renewal URL"),
-            'netscape-ca-policy-url' => _("Netscape CA policy URL"),
-            'netscape-ssl-server-name' => _("Netscape SSL server name"),
-            'netscape-comment' => _("Netscape certificate comment")
+            'netscape-cert-type' => $this->_dict->t("Netscape certificate type"),
+            'netscape-base-url' => $this->_dict->t("Netscape Base URL"),
+            'netscape-revocation-url' => $this->_dict->t("Netscape Revocation URL"),
+            'netscape-ca-revocation-url' => $this->_dict->t("Netscape CA Revocation URL"),
+            'netscape-cert-renewal-url' => $this->_dict->t("Netscape Renewal URL"),
+            'netscape-ca-policy-url' => $this->_dict->t("Netscape CA policy URL"),
+            'netscape-ssl-server-name' => $this->_dict->t("Netscape SSL server name"),
+            'netscape-comment' => $this->_dict->t("Netscape certificate comment")
         );
 
         /* X590v3 Extensions */
         $fieldnames += array(
-            'id-ce-extKeyUsage' => _("X509v3 Extended Key Usage"),
-            'id-ce-basicConstraints' => _("X509v3 Basic Constraints"),
-            'id-ce-subjectAltName' => _("X509v3 Subject Alternative Name"),
-            'id-ce-subjectKeyIdentifier' => _("X509v3 Subject Key Identifier"),
-            'id-ce-certificatePolicies' => _("Certificate Policies"),
-            'id-ce-CRLDistributionPoints' => _("CRL Distribution Points"),
-            'id-ce-keyUsage' => _("Key Usage")
+            'id-ce-extKeyUsage' => $this->_dict->t("X509v3 Extended Key Usage"),
+            'id-ce-basicConstraints' => $this->_dict->t("X509v3 Basic Constraints"),
+            'id-ce-subjectAltName' => $this->_dict->t("X509v3 Subject Alternative Name"),
+            'id-ce-subjectKeyIdentifier' => $this->_dict->t("X509v3 Subject Key Identifier"),
+            'id-ce-certificatePolicies' => $this->_dict->t("Certificate Policies"),
+            'id-ce-CRLDistributionPoints' => $this->_dict->t("CRL Distribution Points"),
+            'id-ce-keyUsage' => $this->_dict->t("Key Usage")
         );
 
         $cert_details = $this->parseCert($cert);
         if (!is_array($cert_details)) {
-            return '<pre class="fixed">' . _("Unable to extract certificate details") . '</pre>';
+            return '<pre class="fixed">' . $this->_dict->t("Unable to extract certificate details") . '</pre>';
         }
         $certificate = $cert_details['certificate'];
 
@@ -517,7 +517,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
 
         /* Subject (a/k/a Certificate Owner) */
         if (isset($certificate['subject'])) {
-            $text .= "<strong>" . _("Certificate Owner") . ":</strong>\n";
+            $text .= "<strong>" . $this->_dict->t("Certificate Owner") . ":</strong>\n";
 
             foreach ($certificate['subject'] as $key => $value) {
                 if (isset($fieldnames[$key])) {
@@ -531,7 +531,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
 
         /* Issuer */
         if (isset($certificate['issuer'])) {
-            $text .= "<strong>" . _("Issuer") . ":</strong>\n";
+            $text .= "<strong>" . $this->_dict->t("Issuer") . ":</strong>\n";
 
             foreach ($certificate['issuer'] as $key => $value) {
                 if (isset($fieldnames[$key])) {
@@ -544,14 +544,14 @@ class Horde_Crypt_Smime extends Horde_Crypt
         }
 
         /* Dates  */
-        $text .= "<strong>" . _("Validity") . ":</strong>\n";
-        $text .= sprintf("&nbsp;&nbsp;%s: %s\n", _("Not Before"), strftime("%x %X", $certificate['validity']['notbefore']));
-        $text .= sprintf("&nbsp;&nbsp;%s: %s\n", _("Not After"), strftime("%x %X", $certificate['validity']['notafter']));
+        $text .= "<strong>" . $this->_dict->t("Validity") . ":</strong>\n";
+        $text .= sprintf("&nbsp;&nbsp;%s: %s\n", $this->_dict->t("Not Before"), strftime("%x %X", $certificate['validity']['notbefore']));
+        $text .= sprintf("&nbsp;&nbsp;%s: %s\n", $this->_dict->t("Not After"), strftime("%x %X", $certificate['validity']['notafter']));
         $text .= "\n";
 
         /* Certificate Owner - Public Key Info */
-        $text .= "<strong>" . _("Public Key Info") . ":</strong>\n";
-        $text .= sprintf("&nbsp;&nbsp;%s: %s\n", _("Public Key Algorithm"), $certificate['subjectPublicKeyInfo']['algorithm']);
+        $text .= "<strong>" . $this->_dict->t("Public Key Info") . ":</strong>\n";
+        $text .= sprintf("&nbsp;&nbsp;%s: %s\n", $this->_dict->t("Public Key Algorithm"), $certificate['subjectPublicKeyInfo']['algorithm']);
         if ($certificate['subjectPublicKeyInfo']['algorithm'] == 'rsaEncryption') {
             if (Horde_Util::extensionExists('bcmath')) {
                 $modulus = $certificate['subjectPublicKeyInfo']['subjectPublicKey']['modulus'];
@@ -569,7 +569,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
                     str_pad($modulus_hex, 256, '0', STR_PAD_RIGHT);
                 }
 
-                $text .= "&nbsp;&nbsp;" . sprintf(_("RSA Public Key (%d bit)"), strlen($modulus_hex) * 4) . ":\n";
+                $text .= "&nbsp;&nbsp;" . sprintf($this->_dict->t("RSA Public Key (%d bit)"), strlen($modulus_hex) * 4) . ":\n";
 
                 $modulus_str = '';
 
@@ -580,20 +580,20 @@ class Horde_Crypt_Smime extends Horde_Crypt
                     $modulus_str .= substr($modulus_hex, $i, 2) . ':';
                 }
 
-                $text .= sprintf("&nbsp;&nbsp;&nbsp;&nbsp;%s: %s\n", _("Modulus"), $modulus_str);
+                $text .= sprintf("&nbsp;&nbsp;&nbsp;&nbsp;%s: %s\n", $this->_dict->t("Modulus"), $modulus_str);
             }
 
-            $text .= sprintf("&nbsp;&nbsp;&nbsp;&nbsp;%s: %s\n", _("Exponent"), $certificate['subjectPublicKeyInfo']['subjectPublicKey']['publicExponent']);
+            $text .= sprintf("&nbsp;&nbsp;&nbsp;&nbsp;%s: %s\n", $this->_dict->t("Exponent"), $certificate['subjectPublicKeyInfo']['subjectPublicKey']['publicExponent']);
         }
         $text .= "\n";
 
         /* X509v3 extensions */
         if (isset($certificate['extensions'])) {
-            $text .= "<strong>" . _("X509v3 extensions") . ":</strong>\n";
+            $text .= "<strong>" . $this->_dict->t("X509v3 extensions") . ":</strong>\n";
 
             foreach ($certificate['extensions'] as $key => $value) {
                 if (is_array($value)) {
-                    $value = _("Unsupported Extension");
+                    $value = $this->_dict->t("Unsupported Extension");
                 }
                 if (isset($fieldnames[$key])) {
                     $text .= sprintf("&nbsp;&nbsp;%s:\n&nbsp;&nbsp;&nbsp;&nbsp;%s\n", $fieldnames[$key], wordwrap($value, 40, "\n&nbsp;&nbsp;&nbsp;&nbsp;"));
@@ -606,20 +606,20 @@ class Horde_Crypt_Smime extends Horde_Crypt
         }
 
         /* Certificate Details */
-        $text .= "<strong>" . _("Certificate Details") . ":</strong>\n";
-        $text .= sprintf("&nbsp;&nbsp;%s: %d\n", _("Version"), $certificate['version']);
-        $text .= sprintf("&nbsp;&nbsp;%s: %d\n", _("Serial Number"), $certificate['serialNumber']);
+        $text .= "<strong>" . $this->_dict->t("Certificate Details") . ":</strong>\n";
+        $text .= sprintf("&nbsp;&nbsp;%s: %d\n", $this->_dict->t("Version"), $certificate['version']);
+        $text .= sprintf("&nbsp;&nbsp;%s: %d\n", $this->_dict->t("Serial Number"), $certificate['serialNumber']);
 
         foreach ($cert_details['fingerprints'] as $hash => $fingerprint) {
-            $label = sprintf(_("%s Fingerprint"), Horde_String::upper($hash));
+            $label = sprintf($this->_dict->t("%s Fingerprint"), Horde_String::upper($hash));
             $fingerprint_str = '';
             for ($i = 0, $f_len = strlen($fingerprint); $i < $f_len; $i += 2) {
                 $fingerprint_str .= substr($fingerprint, $i, 2) . ':';
             }
             $text .= sprintf("&nbsp;&nbsp;%s:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%s\n", $label, $fingerprint_str);
         }
-        $text .= sprintf("&nbsp;&nbsp;%s: %s\n", _("Signature Algorithm"), $cert_details['signatureAlgorithm']);
-        $text .= sprintf("&nbsp;&nbsp;%s:", _("Signature"));
+        $text .= sprintf("&nbsp;&nbsp;%s: %s\n", $this->_dict->t("Signature Algorithm"), $cert_details['signatureAlgorithm']);
+        $text .= sprintf("&nbsp;&nbsp;%s:", $this->_dict->t("Signature"));
 
         $sig_str = '';
         for ($i = 0, $s_len = strlen($cert_details['signature']); $i < $s_len; ++$i) {
@@ -841,13 +841,13 @@ class Horde_Crypt_Smime extends Horde_Crypt
                     }
                     $cert_details['certificate']['extensions'][$oid] = $newVal;
                 } else {
-                    $cert_details['certificate']['extensions'][$oid] = _("Unsupported Extension");
+                    $cert_details['certificate']['extensions'][$oid] = $this->_dict->t("Unsupported Extension");
                 }
                 break;
 
             case 'id-ce-basicConstraints':
             case 'default':
-                $cert_details['certificate']['extensions'][$oid] = _("Unsupported Extension");
+                $cert_details['certificate']['extensions'][$oid] = $this->_dict->t("Unsupported Extension");
                 break;
             }
         }
@@ -1132,7 +1132,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
      */
     protected function _decryptSignature($text, $params)
     {
-        throw new Horde_Crypt_Exception('_decryptSignature() ' . _("not yet implemented"));
+        throw new Horde_Crypt_Exception('_decryptSignature() ' . $this->_dict->t("not yet implemented"));
     }
 
     /**
@@ -1143,7 +1143,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
     public function checkForOpenSSL()
     {
         if (!Horde_Util::extensionExists('openssl')) {
-            throw new Horde_Crypt_Exception(_("The openssl module is required for the Horde_Crypt_Smime:: class."));
+            throw new Horde_Crypt_Exception($this->_dict->t("The openssl module is required for the Horde_Crypt_Smime:: class."));
         }
     }
 
@@ -1214,7 +1214,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
         $this->checkForOpenSSL();
 
         if (!isset($params['sslpath'])) {
-            throw new Horde_Crypt_Exception(_("No path to the OpenSSL binary provided. The OpenSSL binary is necessary to work with PKCS 12 data."));
+            throw new Horde_Crypt_Exception($this->_dict->t("No path to the OpenSSL binary provided. The OpenSSL binary is necessary to work with PKCS 12 data."));
         }
         $sslpath = escapeshellcmd($params['sslpath']);
 
@@ -1248,12 +1248,12 @@ class Horde_Crypt_Smime extends Horde_Crypt
             }
             pclose($fd);
         } else {
-            throw new Horde_Crypt_Exception(_("Error while talking to smime binary."));
+            throw new Horde_Crypt_Exception($this->_dict->t("Error while talking to smime binary."));
         }
 
         $ob->private = trim(file_get_contents($output));
         if (empty($ob->private)) {
-            throw new Horde_Crypt_Exception(_("Password incorrect"));
+            throw new Horde_Crypt_Exception($this->_dict->t("Password incorrect"));
         }
 
         /* Extract the client public key next. */
@@ -1266,7 +1266,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
             fwrite($fd, $params['password'] . "\n");
             pclose($fd);
         } else {
-            throw new Horde_Crypt_Exception(_("Error while talking to smime binary."));
+            throw new Horde_Crypt_Exception($this->_dict->t("Error while talking to smime binary."));
         }
 
         $ob->public = trim(file_get_contents($output));
@@ -1281,7 +1281,7 @@ class Horde_Crypt_Smime extends Horde_Crypt
             fwrite($fd, $params['password'] . "\n");
             pclose($fd);
         } else {
-            throw new Horde_Crypt_Exception(_("Error while talking to smime binary."));
+            throw new Horde_Crypt_Exception($this->_dict->t("Error while talking to smime binary."));
         }
 
         $ob->certs = trim(file_get_contents($output));
index de8146d..9580a69 100644 (file)
@@ -57,14 +57,22 @@ abstract class Horde_Data_Base
     protected $_warnings = array();
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor.
      *
      * @param array $params  Optional parameters:
-     * <pre>
-     * 'browser' - (Horde_Browser) A Horde_Browser object.
-     * 'cleanup' - (callback) A callback to call at cleanup time.
-     * 'vars' - (Horde_Variables) Form data.
-     * </pre>
+     *                       - 'browser' (Horde_Browser) A Horde_Browser object.
+     *                       - 'cleanup': (callback) A callback to call at
+     *                                    cleanup time.
+     *                       - 'vars': (Horde_Variables) Form data.
+     *                       - 'translation': (object) A translation handler
+     *                                        implementing Horde_Translation.
      *
      * @throws InvalidArgumentException
      */
@@ -83,6 +91,12 @@ abstract class Horde_Data_Base
         $this->_vars = isset($params['vars'])
             ? $params['vars']
             : Horde_Variables::getDefaultVariables();
+
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Data', dirname(__FILE__) . '/../../../locale');
+        }
     }
 
     /**
@@ -269,7 +283,7 @@ abstract class Horde_Data_Base
                 throw new Horde_Data_Exception($e);
             }
             if ($_FILES['import_file']['size'] <= 0) {
-                return PEAR::raiseError(_("The file contained no data."));
+                return PEAR::raiseError($this->_dict->t("The file contained no data."));
             }
             $_SESSION['import_data']['format'] = $this->_vars->import_format;
             break;
index 094221e..00521f6 100644 (file)
@@ -200,7 +200,7 @@ class Horde_Data_Tsv extends Horde_Data_Base
             /* Move uploaded file so that we can read it again in the next step
                after the user gave some format details. */
             try {
-                $this->_browser->wasFileUploaded('import_file', _("TSV file"));
+                $this->_browser->wasFileUploaded('import_file', $this->_dict->t("TSV file"));
             } catch (Horde_Browser_Exception $e) {
                 throw new Horde_Data_Exception($e);
             }
index 742c29a..473416d 100644 (file)
@@ -121,7 +121,7 @@ class DataTree {
         $children = $this->getNumberOfChildren($object);
         if ($children) {
             /* TODO: remove children if $force == true */
-            return PEAR::raiseError(sprintf(ngettext("Cannot remove, %d child exists.", "Cannot remove, %d children exist.", count($children)), count($children)));
+            return PEAR::raiseError(sprintf('Cannot remove, %d children exist.', count($children)));
         }
 
         $id = $this->getId($object);
index 669301a..000103c 100644 (file)
@@ -340,7 +340,7 @@ class DataTree_sql extends DataTree {
             return $parents;
         }
         if (empty($parents)) {
-            return PEAR::raiseError(_("Object not found."), null, null, null, 'DataTree ids ' . implode(', ', $ids) . ' not found.');
+            return PEAR::raiseError('Object not found.', null, null, null, 'DataTree ids ' . implode(', ', $ids) . ' not found.');
         }
 
         $ids = array();
@@ -588,7 +588,7 @@ class DataTree_sql extends DataTree {
         }
 
         if (parent::exists($fullname)) {
-            return PEAR::raiseError(sprintf(_("\"%s\" already exists"), $fullname));
+            return PEAR::raiseError(sprintf('"%s" already exists', $fullname));
         }
 
         $query = 'INSERT INTO ' . $this->_params['table'] .
@@ -692,7 +692,7 @@ class DataTree_sql extends DataTree {
             if (is_a($result, 'PEAR_Error')) {
                 return $result;
             } elseif (count($order) != $result) {
-                return PEAR::raiseError(_("Cannot reorder, number of entries supplied for reorder does not match number stored."));
+                return PEAR::raiseError('Cannot reorder, number of entries supplied for reorder does not match number stored.');
             }
 
             $o_key = 0;
@@ -767,7 +767,7 @@ class DataTree_sql extends DataTree {
                     }
                 }
             } else {
-                return PEAR::raiseError(sprintf(_("Cannot remove, %d children exist."), count($children)));
+                return PEAR::raiseError(sprintf('Cannot remove, %d children exist.', count($children)));
             }
         }
 
index 5bc2874..d5bca49 100644 (file)
@@ -205,17 +205,21 @@ class Horde_Date_Recurrence
      *
      * @return string  Human readable recurring type.
      */
-    public function getRecurName()
+    public function getRecurName($dict = null)
     {
+        if (!$dict) {
+            $dict = new Horde_Translation_Gettext('Horde_Date', dirname(__FILE__) . '/../../../locale');
+        }
+
         switch ($this->getRecurType()) {
-        case self::RECUR_NONE: return _("No recurrence");
-        case self::RECUR_DAILY: return _("Daily");
-        case self::RECUR_WEEKLY: return _("Weekly");
+        case self::RECUR_NONE: return $dict->t("No recurrence");
+        case self::RECUR_DAILY: return $dict->t("Daily");
+        case self::RECUR_WEEKLY: return $dict->t("Weekly");
         case self::RECUR_MONTHLY_DATE:
-        case self::RECUR_MONTHLY_WEEKDAY: return _("Monthly");
+        case self::RECUR_MONTHLY_WEEKDAY: return $dict->t("Monthly");
         case self::RECUR_YEARLY_DATE:
         case self::RECUR_YEARLY_DAY:
-        case self::RECUR_YEARLY_WEEKDAY: return _("Yearly");
+        case self::RECUR_YEARLY_WEEKDAY: return $dict->t("Yearly");
         }
     }
 
index e9cd071..49df5fe 100644 (file)
@@ -7,7 +7,6 @@
  * @package  Horde_Date
  */
 
-
 /**
  * @category Horde
  * @package  Horde_Date
@@ -66,43 +65,50 @@ class Horde_Date_Utils
      * Returns a relative, natural language representation of a timestamp
      * TODO: Wider range of values ... maybe future time as well?
      *
-     * @param integer $timestamp   The timestamp.
-     * @param string $date_format  Format to display date if timestamp is more
-     *                             then 1 day old.
-     * @param string $time_format  Format to display time if timestamp is 1 day
-     *                             old.
+     * @param integer $timestamp       The timestamp.
+     * @param string $date_format      Format to display date if timestamp is
+     *                                 more then 1 day old.
+     * @param string $time_format      Format to display time if timestamp is 1
+     *                                 day old.
+     * @param Horde_Translation $dict  A translation handler implementing
+     *                                 Horde_Translation.
      *
      * @return string  The relative time (i.e. 2 minutes ago)
      */
-    public static function relativeDateTime($timestamp, $date_format = '%x', $time_format = '%X')
+    public static function relativeDateTime($timestamp, $date_format = '%x',
+                                            $time_format = '%X', $dict = null)
     {
+        if (!$dict) {
+            $dict = new Horde_Translation_Gettext('Horde_Date', dirname(__FILE__) . '/../../../locale');
+        }
+
         $delta = time() - $timestamp;
         if ($delta < 60) {
-            return sprintf(ngettext("%d second ago", "%d seconds ago", $delta), $delta);
+            return sprintf($dict->n("%d second ago", "%d seconds ago", $delta), $delta);
         }
         $delta = round($delta / 60);
         if ($delta < 60) {
-            return sprintf(ngettext("%d minute ago", "%d minutes ago", $delta), $delta);
+            return sprintf($dict->n("%d minute ago", "%d minutes ago", $delta), $delta);
         }
 
         $delta = round($delta / 60);
         if ($delta < 24) {
-            return sprintf(ngettext("%d hour ago", "%d hours ago", $delta), $delta);
+            return sprintf($dict->n("%d hour ago", "%d hours ago", $delta), $delta);
         }
 
         if ($delta > 24 && $delta < 48) {
             $date = new Horde_Date($timestamp);
-            return sprintf(_("yesterday at %s"), $date->strftime($time_format));
+            return sprintf($dict->t("yesterday at %s"), $date->strftime($time_format));
         }
 
         $delta = round($delta / 24);
         if ($delta < 7) {
-            return sprintf(_("%d days ago"), $delta);
+            return sprintf($dict->t("%d days ago"), $delta);
         }
 
         if (round($delta / 7) < 5) {
             $delta = round($delta / 7);
-            return sprintf(ngettext("%d week ago", "%d weeks ago", $delta), $delta);
+            return sprintf($dict->n("%d week ago", "%d weeks ago", $delta), $delta);
         }
 
         // Default to the user specified date format.
index 9b7dfa3..6629ea0 100644 (file)
@@ -17,14 +17,19 @@ class Horde_Exception_NotFound extends Horde_Exception
      *
      * @see Horde_Exception::__construct()
      *
-     * @param mixed $message The exception message, a PEAR_Error
-     *                       object, or an Exception object.
-     * @param int   $code    A numeric error code.
+     * @param mixed $message           The exception message, a PEAR_Error
+     *                                 object, or an Exception object.
+     * @param integer $code            A numeric error code.
+     * @param Horde_Translation $dict  A translation handler implementing
+     *                                 Horde_Translation.
      */
-    public function __construct($message = null, $code = null)
+    public function __construct($message = null, $code = null, $dict = null)
     {
         if (is_null($message)) {
-            $message = _("Not Found");
+            if (!$dict) {
+                $dict = new Horde_Translation_Gettext('Horde_Exception', dirname(__FILE__) . '/../../../locale');
+            }
+            $message = $dict->t("Not Found");
         }
         parent::__construct($message, $code);
     }
index 31a53fa..a50795b 100644 (file)
@@ -17,14 +17,19 @@ class Horde_Exception_PermissionDenied extends Horde_Exception
      *
      * @see Horde_Exception::__construct()
      *
-     * @param mixed $message The exception message, a PEAR_Error
-     *                       object, or an Exception object.
-     * @param int   $code    A numeric error code.
+     * @param mixed $message           The exception message, a PEAR_Error
+     *                                 object, or an Exception object.
+     * @param integer $code            A numeric error code.
+     * @param Horde_Translation $dict  A translation handler implementing
+     *                                 Horde_Translation.
      */
-    public function __construct($message = null, $code = null)
+  public function __construct($message = null, $code = null, $dict = null)
     {
         if (is_null($message)) {
-            $message = _("Permission Denied");
+            if (!$dict) {
+                $dict = new Horde_Translation_Gettext('Horde_Exception', dirname(__FILE__) . '/../../../locale');
+            }
+            $message = $dict->t("Permission Denied");
         }
         parent::__construct($message, $code);
     }
index dce2760..7202861 100644 (file)
@@ -194,11 +194,12 @@ class Horde_File_Csv
             }
         }
 
+        $dict = new Horde_Translation_Gettext('Horde_File_Csv', dirname(__FILE__) . '/../../../locale');
         if (count($fields) < $conf['fields']) {
-            self::warning(sprintf(_("Wrong number of fields in line %d. Expected %d, found %d."), self::_line(), $conf['fields'], count($fields)));
+            self::warning(sprintf($dict->t("Wrong number of fields in line %d. Expected %d, found %d."), self::_line(), $conf['fields'], count($fields)));
             $fields = array_merge($fields, array_fill(0, $conf['fields'] - count($fields), ''));
         } elseif (count($fields) > $conf['fields']) {
-            self::warning(sprintf(_("More fields found in line %d than the expected %d."), self::_line(), $conf['fields']));
+            self::warning(sprintf($dict->t("More fields found in line %d than the expected %d."), self::_line(), $conf['fields']));
             array_splice($fields, $conf['fields']);
         }
 
index 0bfad0b..c8afb27 100644 (file)
@@ -39,7 +39,14 @@ class Horde_Form {
     protected $_enctype = null;
     public $_help = false;
 
-    function Horde_Form(&$vars, $title = '', $name = null)
+    /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    function Horde_Form(&$vars, $title = '', $name = null, $params = array())
     {
         if (empty($name)) {
             $name = Horde_String::lower(get_class($this));
@@ -48,6 +55,13 @@ class Horde_Form {
         $this->_vars = &$vars;
         $this->_title = $title;
         $this->_name = $name;
+
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Form', dirname(__FILE__) . '/../locale');
+        }
+
     }
 
     function __construct($vars, $title = '', $name = null)
@@ -347,14 +361,14 @@ class Horde_Form {
     {
         if ($submit === true || is_null($submit) || empty($submit)) {
             /* Default to 'Submit'. */
-            $submit = array(_("Submit"));
+            $submit = array($this->_dict->t("Submit"));
         } elseif (!is_array($submit)) {
             /* Default to array if not passed. */
             $submit = array($submit);
         }
         /* Only if $reset is strictly true insert default 'Reset'. */
         if ($reset === true) {
-            $reset = _("Reset");
+            $reset = $this->_dict->t("Reset");
         }
 
         $this->_submit = $submit;
@@ -615,10 +629,10 @@ class Horde_Form {
             $tokenSource = $GLOBALS['injector']->getInstance('Horde_Token');
             $passedToken = $vars->get($this->_name . '_formToken');
             if (!empty($passedToken) && !$tokenSource->verify($passedToken)) {
-                $this->_errors['_formToken'] = _("This form has already been processed.");
+                $this->_errors['_formToken'] = $this->_dict->t("This form has already been processed.");
             }
             if (!$GLOBALS['session']['horde:form_secrets/' . $passedToken]) {
-                $this->_errors['_formSecret'] = _("Required secret is invalid - potentially malicious request.");
+                $this->_errors['_formSecret'] = $this->_dict->t("Required secret is invalid - potentially malicious request.");
             }
         }
 
index 4b21289..c2cb7a4 100644 (file)
@@ -41,16 +41,31 @@ class Horde_Form_Renderer {
     var $_attrColumnWidth = '15%';
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Construct a new Horde_Form_Renderer::.
      *
      * @param array $params  This is a hash of renderer-specific parameters.
-     *                       Possible keys:<code>
-     *                       'varrenderer_driver': specifies the driver
-     *                           parameter to Horde_Core_Ui_VarRenderer::factory().
-     *                       'encode_title': @see $_encodeTitle</code>
+     *                       Possible keys:
+     *                       - 'varrenderer_driver': specifies the driver
+     *                         parameter to Horde_Core_Ui_VarRenderer::factory().
+     *                       - 'encode_title': @see $_encodeTitle
+     *                       - 'translation': A translation handler
+     *                                        implementing Horde_Translation.
      */
     function Horde_Form_Renderer($params = array())
     {
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Form', dirname(__FILE__) . '/../../locale');
+        }
+
         global $registry;
         if (isset($registry) && is_a($registry, 'Registry')) {
             /* Registry available, so use a pretty image. */
@@ -308,10 +323,10 @@ try {
     function submit($submit = null, $reset = false)
     {
         if (is_null($submit) || empty($submit)) {
-            $submit = _("Submit");
+            $submit = $this->_dict->t("Submit");
         }
         if ($reset === true) {
-            $reset = _("Reset");
+            $reset = $this->_dict->t("Reset");
         }
         $this->_renderSubmit($submit, $reset);
     }
@@ -326,7 +341,7 @@ try {
             $this->_sectionHeader($name, $extra);
         }
         if ($this->_requiredLegend) {
-            echo '<span class="form-error">' . $this->_requiredMarker . '</span> = ' . _("Required Field");
+            echo '<span class="form-error">' . $this->_requiredMarker . '</span> = ' . $this->_dict->t("Required Field");
         }
     }
 
index 5a4ef59..24a3a92 100644 (file)
@@ -5,10 +5,29 @@
  * @author  Robert E. Coyle <robertecoyle@hotmail.com>
  * @package Horde_Form
  */
-class Horde_Form_Type {
+class Horde_Form_Type
+{
+    /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
 
-    function Horde_Form_Type()
+    /**
+     * Constructor.
+     *
+     * @param array $params  Hash with configuration data. Possible values:
+     *                       - 'translation': A translation handler
+     *                                        implementing Horde_Translation.
+     */
+    public function __construct($params = array())
     {
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Form', dirname(__FILE__) . '/../../locale');
+        }
     }
 
     function getProperty($property)
@@ -76,7 +95,7 @@ class Horde_Form_Type_spacer extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Spacer"));
+        return array('name' => $this->_dict->t("Spacer"));
     }
 
 }
@@ -93,7 +112,7 @@ class Horde_Form_Type_header extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Header"));
+        return array('name' => $this->_dict->t("Header"));
     }
 
 }
@@ -110,7 +129,7 @@ class Horde_Form_Type_description extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Description"));
+        return array('name' => $this->_dict->t("Description"));
     }
 
 }
@@ -130,7 +149,7 @@ class Horde_Form_Type_html extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("HTML"));
+        return array('name' => $this->_dict->t("HTML"));
     }
 
 }
@@ -147,7 +166,7 @@ class Horde_Form_Type_number extends Horde_Form_Type {
     function isValid(&$var, &$vars, $value, &$message)
     {
         if ($var->isRequired() && empty($value) && ((string)(double)$value !== $value)) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         } elseif (empty($value)) {
             return true;
@@ -158,7 +177,7 @@ class Horde_Form_Type_number extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("This field must be a valid number.");
+        $message = $this->_dict->t("This field must be a valid number.");
         return false;
     }
 
@@ -214,7 +233,7 @@ class Horde_Form_Type_number extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Number"));
+        return array('name' => $this->_dict->t("Number"));
     }
 
 }
@@ -224,7 +243,7 @@ class Horde_Form_Type_int extends Horde_Form_Type {
     function isValid(&$var, &$vars, $value, &$message)
     {
         if ($var->isRequired() && empty($value) && ((string)(int)$value !== $value)) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -232,7 +251,7 @@ class Horde_Form_Type_int extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("This field may only contain integers.");
+        $message = $this->_dict->t("This field may only contain integers.");
         return false;
     }
 
@@ -241,7 +260,7 @@ class Horde_Form_Type_int extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Integer"));
+        return array('name' => $this->_dict->t("Integer"));
     }
 
 }
@@ -251,7 +270,7 @@ class Horde_Form_Type_octal extends Horde_Form_Type {
     function isValid(&$var, &$vars, $value, &$message)
     {
         if ($var->isRequired() && empty($value) && ((string)(int)$value !== $value)) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -259,7 +278,7 @@ class Horde_Form_Type_octal extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("This field may only contain octal values.");
+        $message = $this->_dict->t("This field may only contain octal values.");
         return false;
     }
 
@@ -268,7 +287,7 @@ class Horde_Form_Type_octal extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Octal"));
+        return array('name' => $this->_dict->t("Octal"));
     }
 
 }
@@ -278,7 +297,7 @@ class Horde_Form_Type_intlist extends Horde_Form_Type {
     function isValid(&$var, &$vars, $value, &$message)
     {
         if (empty($value) && $var->isRequired()) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -286,7 +305,7 @@ class Horde_Form_Type_intlist extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("This field must be a comma or space separated list of integers");
+        $message = $this->_dict->t("This field must be a comma or space separated list of integers");
         return false;
     }
 
@@ -295,7 +314,7 @@ class Horde_Form_Type_intlist extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Integer list"));
+        return array('name' => $this->_dict->t("Integer list"));
     }
 
 }
@@ -338,18 +357,18 @@ class Horde_Form_Type_text extends Horde_Form_Type {
 
         if (!empty($this->_maxlength) && Horde_String::length($value) > $this->_maxlength) {
             $valid = false;
-            $message = sprintf(_("Value is over the maximum length of %d."), $this->_maxlength);
+            $message = sprintf($this->_dict->t("Value is over the maximum length of %d."), $this->_maxlength);
         } elseif ($var->isRequired() && empty($this->_regex)) {
             $valid = strlen(trim($value)) > 0;
 
             if (!$valid) {
-                $message = _("This field is required.");
+                $message = $this->_dict->t("This field is required.");
             }
         } elseif (!empty($this->_regex)) {
             $valid = preg_match($this->_regex, $value);
 
             if (!$valid) {
-                $message = _("You must enter a valid value.");
+                $message = $this->_dict->t("You must enter a valid value.");
             }
         }
 
@@ -372,13 +391,13 @@ class Horde_Form_Type_text extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Text"),
+            'name' => $this->_dict->t("Text"),
             'params' => array(
-                'regex'     => array('label' => _("Regex"),
+                'regex'     => array('label' => $this->_dict->t("Regex"),
                                      'type'  => 'text'),
-                'size'      => array('label' => _("Size"),
+                'size'      => array('label' => $this->_dict->t("Size"),
                                      'type'  => 'int'),
-                'maxlength' => array('label' => _("Maximum length"),
+                'maxlength' => array('label' => $this->_dict->t("Maximum length"),
                                      'type'  => 'int')));
     }
 
@@ -392,13 +411,13 @@ class Horde_Form_Type_stringlist extends Horde_Form_Type_text {
     function about()
     {
         return array(
-            'name' => _("String list"),
+            'name' => $this->_dict->t("String list"),
             'params' => array(
-                'regex'     => array('label' => _("Regex"),
+                'regex'     => array('label' => $this->_dict->t("Regex"),
                                      'type'  => 'text'),
-                'size'      => array('label' => _("Size"),
+                'size'      => array('label' => $this->_dict->t("Size"),
                                      'type'  => 'int'),
-                'maxlength' => array('label' => _("Maximum length"),
+                'maxlength' => array('label' => $this->_dict->t("Maximum length"),
                                      'type'  => 'int')),
         );
     }
@@ -418,13 +437,13 @@ class Horde_Form_Type_stringarray extends Horde_Form_Type_stringlist {
     function about()
     {
         return array(
-            'name' => _("String list returning an array"),
+            'name' => $this->_dict->t("String list returning an array"),
             'params' => array(
-                'regex'     => array('label' => _("Regex"),
+                'regex'     => array('label' => $this->_dict->t("Regex"),
                                      'type'  => 'text'),
-                'size'      => array('label' => _("Size"),
+                'size'      => array('label' => $this->_dict->t("Size"),
                                      'type'  => 'int'),
-                'maxlength' => array('label' => _("Maximum length"),
+                'maxlength' => array('label' => $this->_dict->t("Maximum length"),
                                      'type'  => 'int')),
         );
     }
@@ -437,11 +456,11 @@ class Horde_Form_Type_phone extends Horde_Form_Type {
     {
         if (!strlen(trim($value))) {
             if ($var->isRequired()) {
-                $message = _("This field is required.");
+                $message = $this->_dict->t("This field is required.");
                 return false;
             }
         } elseif (!preg_match('/^\+?[\d()\-\/. ]*$/', $value)) {
-            $message = _("You must enter a valid phone number, digits only with an optional '+' for the international dialing prefix.");
+            $message = $this->_dict->t("You must enter a valid phone number, digits only with an optional '+' for the international dialing prefix.");
             return false;
         }
 
@@ -453,7 +472,7 @@ class Horde_Form_Type_phone extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Phone number"));
+        return array('name' => $this->_dict->t("Phone number"));
     }
 
 }
@@ -465,7 +484,7 @@ class Horde_Form_Type_cellphone extends Horde_Form_Type_phone {
      */
     function about()
     {
-        return array('name' => _("Mobile phone number"));
+        return array('name' => $this->_dict->t("Mobile phone number"));
     }
 
 }
@@ -491,11 +510,11 @@ class Horde_Form_Type_ipaddress extends Horde_Form_Type_text {
             }
 
             if (!$valid) {
-                $message = _("Please enter a valid IP address.");
+                $message = $this->_dict->t("Please enter a valid IP address.");
             }
         } elseif ($var->isRequired()) {
             $valid = false;
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
         }
 
         return $valid;
@@ -506,7 +525,7 @@ class Horde_Form_Type_ipaddress extends Horde_Form_Type_text {
      */
     function about()
     {
-        return array('name' => _("IP address"));
+        return array('name' => $this->_dict->t("IP address"));
     }
 
 }
@@ -521,11 +540,11 @@ class Horde_Form_Type_ip6address extends Horde_Form_Type_text {
             $valid = @inet_pton($value);
 
             if ($valid === false) {
-                $message = _("Please enter a valid IP address.");
+                $message = $this->_dict->t("Please enter a valid IP address.");
             }
         } elseif ($var->isRequired()) {
             $valid = false;
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
         }
 
         return true;
@@ -536,7 +555,7 @@ class Horde_Form_Type_ip6address extends Horde_Form_Type_text {
      */
     function about()
     {
-        return array('name' => _("IPv6 address"));
+        return array('name' => $this->_dict->t("IPv6 address"));
     }
 
 }
@@ -589,13 +608,13 @@ class Horde_Form_Type_longtext extends Horde_Form_Type_text {
     function about()
     {
         return array(
-            'name' => _("Long text"),
+            'name' => $this->_dict->t("Long text"),
             'params' => array(
-                'rows'   => array('label' => _("Number of rows"),
+                'rows'   => array('label' => $this->_dict->t("Number of rows"),
                                   'type'  => 'int'),
-                'cols'   => array('label' => _("Number of columns"),
+                'cols'   => array('label' => $this->_dict->t("Number of columns"),
                                   'type'  => 'int'),
-                'helper' => array('label' => _("Helpers"),
+                'helper' => array('label' => $this->_dict->t("Helpers"),
                                   'type'  => 'stringarray')));
     }
 
@@ -619,11 +638,11 @@ class Horde_Form_Type_countedtext extends Horde_Form_Type_longtext {
 
         if ($var->isRequired() && $length <= 0) {
             $valid = false;
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
         } elseif ($length > $this->_chars) {
             $valid = false;
-            $message = sprintf(ngettext("There are too many characters in this field. You have entered %d character; ", "There are too many characters in this field. You have entered %d characters; ", $length), $length)
-                . sprintf(_("you must enter less than %d."), $this->_chars);
+            $message = sprintf($this->_dict->n("There are too many characters in this field. You have entered %d character; ", "There are too many characters in this field. You have entered %d characters; ", $length), $length)
+                . sprintf($this->_dict->t("you must enter less than %d."), $this->_chars);
         }
 
         return $valid;
@@ -640,13 +659,13 @@ class Horde_Form_Type_countedtext extends Horde_Form_Type_longtext {
     function about()
     {
         return array(
-            'name' => _("Counted text"),
+            'name' => $this->_dict->t("Counted text"),
             'params' => array(
-                'rows'  => array('label' => _("Number of rows"),
+                'rows'  => array('label' => $this->_dict->t("Number of rows"),
                                  'type'  => 'int'),
-                'cols'  => array('label' => _("Number of columns"),
+                'cols'  => array('label' => $this->_dict->t("Number of columns"),
                                  'type'  => 'int'),
-                'chars' => array('label' => _("Number of characters"),
+                'chars' => array('label' => $this->_dict->t("Number of characters"),
                                  'type'  => 'int')));
     }
 
@@ -751,11 +770,11 @@ class Horde_Form_Type_address extends Horde_Form_Type_longtext {
     function about()
     {
         return array(
-            'name' => _("Address"),
+            'name' => $this->_dict->t("Address"),
             'params' => array(
-                'rows' => array('label' => _("Number of rows"),
+                'rows' => array('label' => $this->_dict->t("Number of rows"),
                                 'type'  => 'int'),
-                'cols' => array('label' => _("Number of columns"),
+                'cols' => array('label' => $this->_dict->t("Number of columns"),
                                 'type'  => 'int')));
     }
 
@@ -773,7 +792,7 @@ class Horde_Form_Type_addresslink extends Horde_Form_Type_address {
      */
     function about()
     {
-        return array('name' => _("Address Link"));
+        return array('name' => $this->_dict->t("Address Link"));
     }
 
 }
@@ -817,15 +836,15 @@ class Horde_Form_Type_pgp extends Horde_Form_Type_longtext {
     function about()
     {
         return array(
-            'name' => _("PGP Key"),
+            'name' => $this->_dict->t("PGP Key"),
             'params' => array(
-                'gpg'      => array('label' => _("Path to the GnuPG binary"),
+                'gpg'      => array('label' => $this->_dict->t("Path to the GnuPG binary"),
                                     'type'  => 'string'),
-                'temp_dir' => array('label' => _("A temporary directory"),
+                'temp_dir' => array('label' => $this->_dict->t("A temporary directory"),
                                     'type'  => 'string'),
-                'rows'     => array('label' => _("Number of rows"),
+                'rows'     => array('label' => $this->_dict->t("Number of rows"),
                                     'type'  => 'int'),
-                'cols'     => array('label' => _("Number of columns"),
+                'cols'     => array('label' => $this->_dict->t("Number of columns"),
                                     'type'  => 'int')));
     }
 
@@ -862,13 +881,13 @@ class Horde_Form_Type_smime extends Horde_Form_Type_longtext {
     function about()
     {
         return array(
-            'name' => _("S/MIME Key"),
+            'name' => $this->_dict->t("S/MIME Key"),
             'params' => array(
-                'temp_dir' => array('label' => _("A temporary directory"),
+                'temp_dir' => array('label' => $this->_dict->t("A temporary directory"),
                                     'type'  => 'string'),
-                'rows'     => array('label' => _("Number of rows"),
+                'rows'     => array('label' => $this->_dict->t("Number of rows"),
                                     'type'  => 'int'),
-                'cols'     => array('label' => _("Number of columns"),
+                'cols'     => array('label' => $this->_dict->t("Number of columns"),
                                     'type'  => 'int')));
     }
 
@@ -887,9 +906,9 @@ class Horde_Form_Type_country extends Horde_Form_Type_enum {
     function about()
     {
         return array(
-            'name' => _("Country drop down list"),
+            'name' => $this->_dict->t("Country drop down list"),
             'params' => array(
-                'prompt' => array('label' => _("Prompt text"),
+                'prompt' => array('label' => $this->_dict->t("Prompt text"),
                                   'type'  => 'text')));
     }
 
@@ -930,7 +949,7 @@ class Horde_Form_Type_file extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("File upload"));
+        return array('name' => $this->_dict->t("File upload"));
     }
 
 }
@@ -1019,7 +1038,7 @@ class Horde_Form_Type_image extends Horde_Form_Type {
             if (($this->_uploaded->getCode() == UPLOAD_ERR_NO_FILE) &&
                 empty($field['hash'])) {
                 /* Nothing uploaded and no older upload. */
-                $message = _("This field is required.");
+                $message = $this->_dict->t("This field is required.");
                 return false;
             } elseif (!empty($field['hash'])) {
                 if ($this->_img && isset($this->_img['error'])) {
@@ -1034,11 +1053,11 @@ class Horde_Form_Type_image extends Horde_Form_Type {
                 return false;
             }
         } elseif (empty($this->_img['img']['size'])) {
-            $message = _("The image file size could not be determined or it was 0 bytes. The upload may have been interrupted.");
+            $message = $this->_dict->t("The image file size could not be determined or it was 0 bytes. The upload may have been interrupted.");
             return false;
         } elseif ($this->_max_filesize &&
                   $this->_img['img']['size'] > $this->_max_filesize) {
-            $message = sprintf(_("The image file was larger than the maximum allowed size (%d bytes)."), $this->_max_filesize);
+            $message = sprintf($this->_dict->t("The image file was larger than the maximum allowed size (%d bytes)."), $this->_max_filesize);
             return false;
         }
 
@@ -1270,13 +1289,13 @@ class Horde_Form_Type_image extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Image upload"),
+            'name' => $this->_dict->t("Image upload"),
             'params' => array(
-                'show_upload'   => array('label' => _("Show upload?"),
+                'show_upload'   => array('label' => $this->_dict->t("Show upload?"),
                                          'type'  => 'boolean'),
-                'show_keeporig' => array('label' => _("Show option to keep original?"),
+                'show_keeporig' => array('label' => $this->_dict->t("Show option to keep original?"),
                                          'type'  => 'boolean'),
-                'max_filesize'  => array('label' => _("Maximum file size in bytes"),
+                'max_filesize'  => array('label' => $this->_dict->t("Maximum file size in bytes"),
                                          'type'  => 'int')));
     }
 
@@ -1299,7 +1318,7 @@ class Horde_Form_Type_boolean extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("True or false"));
+        return array('name' => $this->_dict->t("True or false"));
     }
 
 }
@@ -1330,25 +1349,25 @@ class Horde_Form_Type_link extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Link"),
+            'name' => $this->_dict->t("Link"),
             'params' => array(
                 'url' => array(
-                    'label' => _("Link URL"),
+                    'label' => $this->_dict->t("Link URL"),
                     'type' => 'text'),
                 'text' => array(
-                    'label' => _("Link text"),
+                    'label' => $this->_dict->t("Link text"),
                     'type' => 'text'),
                 'target' => array(
-                    'label' => _("Link target"),
+                    'label' => $this->_dict->t("Link target"),
                     'type' => 'text'),
                 'onclick' => array(
-                    'label' => _("Onclick event"),
+                    'label' => $this->_dict->t("Onclick event"),
                     'type' => 'text'),
                 'title' => array(
-                    'label' => _("Link title attribute"),
+                    'label' => $this->_dict->t("Link title attribute"),
                     'type' => 'text'),
                 'accesskey' => array(
-                    'label' => _("Link access key"),
+                    'label' => $this->_dict->t("Link access key"),
                     'type' => 'text')));
     }
 
@@ -1427,7 +1446,7 @@ class Horde_Form_Type_email extends Horde_Form_Type {
 
         // Check for too many.
         if (!$this->_allow_multi && count($emails) > 1) {
-            $message = _("Only one email address is allowed.");
+            $message = $this->_dict->t("Only one email address is allowed.");
             return false;
         }
 
@@ -1438,7 +1457,7 @@ class Horde_Form_Type_email extends Horde_Form_Type {
                 continue;
             }
             if (!$this->validateEmailAddress($email)) {
-                $message = sprintf(_("\"%s\" is not a valid email address."), $email);
+                $message = sprintf($this->_dict->t("\"%s\" is not a valid email address."), $email);
                 return false;
             }
             ++$nonEmpty;
@@ -1446,9 +1465,9 @@ class Horde_Form_Type_email extends Horde_Form_Type {
 
         if (!$nonEmpty && $var->isRequired()) {
             if ($this->_allow_multi) {
-                $message = _("You must enter at least one email address.");
+                $message = $this->_dict->t("You must enter at least one email address.");
             } else {
-                $message = _("You must enter an email address.");
+                $message = $this->_dict->t("You must enter an email address.");
             }
             return false;
         }
@@ -1595,22 +1614,22 @@ class Horde_Form_Type_email extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Email"),
+            'name' => $this->_dict->t("Email"),
             'params' => array(
                 'allow_multi' => array(
-                    'label' => _("Allow multiple addresses?"),
+                    'label' => $this->_dict->t("Allow multiple addresses?"),
                     'type'  => 'boolean'),
                 'strip_domain' => array(
-                    'label' => _("Protect address from spammers?"),
+                    'label' => $this->_dict->t("Protect address from spammers?"),
                     'type' => 'boolean'),
                 'link_compose' => array(
-                    'label' => _("Link the email address to the compose page when displaying?"),
+                    'label' => $this->_dict->t("Link the email address to the compose page when displaying?"),
                     'type' => 'boolean'),
                 'link_name' => array(
-                    'label' => _("The name to use when linking to the compose page"),
+                    'label' => $this->_dict->t("The name to use when linking to the compose page"),
                     'type' => 'text'),
                 'delimiters' => array(
-                    'label' => _("Character to split multiple addresses with"),
+                    'label' => $this->_dict->t("Character to split multiple addresses with"),
                     'type' => 'text'),
             ),
         );
@@ -2048,9 +2067,9 @@ class Horde_Form_Type_matrix extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Field matrix"),
+            'name' => $this->_dict->t("Field matrix"),
             'params' => array(
-                'cols' => array('label' => _("Column titles"),
+                'cols' => array('label' => $this->_dict->t("Column titles"),
                                 'type'  => 'stringarray')));
     }
 
@@ -2061,12 +2080,12 @@ class Horde_Form_Type_emailConfirm extends Horde_Form_Type {
     function isValid(&$var, &$vars, $value, &$message)
     {
         if ($var->isRequired() && empty($value['original'])) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
         if ($value['original'] != $value['confirm']) {
-            $message = _("Email addresses must match.");
+            $message = $this->_dict->t("Email addresses must match.");
             return false;
         } else {
             try {
@@ -2076,11 +2095,11 @@ class Horde_Form_Type_emailConfirm extends Horde_Form_Type {
                 return false;
             }
             if (count($parsed_email) > 1) {
-                $message = _("Only one email address allowed.");
+                $message = $this->_dict->t("Only one email address allowed.");
                 return false;
             }
             if (empty($parsed_email[0]->mailbox)) {
-                $message = _("You did not enter a valid email address.");
+                $message = $this->_dict->t("You did not enter a valid email address.");
                 return false;
             }
         }
@@ -2093,7 +2112,7 @@ class Horde_Form_Type_emailConfirm extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Email with confirmation"));
+        return array('name' => $this->_dict->t("Email with confirmation"));
     }
 
 }
@@ -2108,7 +2127,7 @@ class Horde_Form_Type_password extends Horde_Form_Type {
             $valid = strlen(trim($value)) > 0;
 
             if (!$valid) {
-                $message = _("This field is required.");
+                $message = $this->_dict->t("This field is required.");
             }
         }
 
@@ -2120,7 +2139,7 @@ class Horde_Form_Type_password extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Password"));
+        return array('name' => $this->_dict->t("Password"));
     }
 
 }
@@ -2130,12 +2149,12 @@ class Horde_Form_Type_passwordconfirm extends Horde_Form_Type {
     function isValid(&$var, &$vars, $value, &$message)
     {
         if ($var->isRequired() && empty($value['original'])) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
         if ($value['original'] != $value['confirm']) {
-            $message = _("Passwords must match.");
+            $message = $this->_dict->t("Passwords must match.");
             return false;
         }
 
@@ -2153,7 +2172,7 @@ class Horde_Form_Type_passwordconfirm extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Password with confirmation"));
+        return array('name' => $this->_dict->t("Password with confirmation"));
     }
 
 }
@@ -2168,7 +2187,7 @@ class Horde_Form_Type_enum extends Horde_Form_Type {
         $this->setValues($values);
 
         if ($prompt === true) {
-            $this->_prompt = _("-- select --");
+            $this->_prompt = $this->_dict->t("-- select --");
         } else {
             $this->_prompt = $prompt;
         }
@@ -2177,7 +2196,7 @@ class Horde_Form_Type_enum extends Horde_Form_Type {
     function isValid(&$var, &$vars, $value, &$message)
     {
         if ($var->isRequired() && $value == '' && !isset($this->_values[$value])) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -2186,7 +2205,7 @@ class Horde_Form_Type_enum extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("Invalid data submitted.");
+        $message = $this->_dict->t("Invalid data submitted.");
         return false;
     }
 
@@ -2211,11 +2230,11 @@ class Horde_Form_Type_enum extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Drop down list"),
+            'name' => $this->_dict->t("Drop down list"),
             'params' => array(
-                'values' => array('label' => _("Values to select from"),
+                'values' => array('label' => $this->_dict->t("Values to select from"),
                                   'type'  => 'stringarray'),
-                'prompt' => array('label' => _("Prompt text"),
+                'prompt' => array('label' => $this->_dict->t("Prompt text"),
                                   'type'  => 'text')));
     }
 
@@ -2231,7 +2250,7 @@ class Horde_Form_Type_mlenum extends Horde_Form_Type {
         $this->_values = &$values;
 
         if ($prompts === true) {
-            $this->_prompts = array(_("-- select --"), _("-- select --"));
+            $this->_prompts = array($this->_dict->t("-- select --"), $this->_dict->t("-- select --"));
         } elseif (!is_array($prompts)) {
             $this->_prompts = array($prompts, $prompts);
         } else {
@@ -2252,7 +2271,7 @@ class Horde_Form_Type_mlenum extends Horde_Form_Type {
     function isValid(&$var, &$vars, $value, &$message)
     {
         if ($var->isRequired() && (empty($value['1']) || empty($value['2']))) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -2261,7 +2280,7 @@ class Horde_Form_Type_mlenum extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("Invalid data submitted.");
+        $message = $this->_dict->t("Invalid data submitted.");
         return false;
     }
 
@@ -2287,11 +2306,11 @@ class Horde_Form_Type_mlenum extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Multi-level drop down lists"),
+            'name' => $this->_dict->t("Multi-level drop down lists"),
             'params' => array(
-                'values' => array('label' => _("Values to select from"),
+                'values' => array('label' => $this->_dict->t("Values to select from"),
                                   'type'  => 'stringarray'),
-                'prompt' => array('label' => _("Prompt text"),
+                'prompt' => array('label' => $this->_dict->t("Prompt text"),
                                   'type'  => 'text')));
     }
 
@@ -2323,7 +2342,7 @@ class Horde_Form_Type_multienum extends Horde_Form_Type_enum {
 
         if (empty($value) && ((string)(int)$value !== $value)) {
             if ($var->isRequired()) {
-                $message = _("This field is required.");
+                $message = $this->_dict->t("This field is required.");
                 return false;
             } else {
                 return true;
@@ -2334,7 +2353,7 @@ class Horde_Form_Type_multienum extends Horde_Form_Type_enum {
             return true;
         }
 
-        $message = _("Invalid data submitted.");
+        $message = $this->_dict->t("Invalid data submitted.");
         return false;
     }
 
@@ -2344,11 +2363,11 @@ class Horde_Form_Type_multienum extends Horde_Form_Type_enum {
     function about()
     {
         return array(
-            'name' => _("Multiple selection"),
+            'name' => $this->_dict->t("Multiple selection"),
             'params' => array(
-                'values' => array('label' => _("Values"),
+                'values' => array('label' => $this->_dict->t("Values"),
                                   'type'  => 'stringarray'),
-                'size'   => array('label' => _("Size"),
+                'size'   => array('label' => $this->_dict->t("Size"),
                                   'type'  => 'int'))
         );
     }
@@ -2379,9 +2398,9 @@ class Horde_Form_Type_radio extends Horde_Form_Type_enum {
     function about()
     {
         return array(
-            'name' => _("Radio selection"),
+            'name' => $this->_dict->t("Radio selection"),
             'params' => array(
-                'values' => array('label' => _("Values"),
+                'values' => array('label' => $this->_dict->t("Values"),
                                   'type'  => 'stringarray')));
     }
 
@@ -2413,7 +2432,7 @@ class Horde_Form_Type_set extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("Invalid data submitted.");
+        $message = $this->_dict->t("Invalid data submitted.");
         return false;
     }
 
@@ -2428,9 +2447,9 @@ class Horde_Form_Type_set extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Set"),
+            'name' => $this->_dict->t("Set"),
             'params' => array(
-                'values' => array('label' => _("Values"),
+                'values' => array('label' => $this->_dict->t("Values"),
                                   'type'  => 'stringarray')));
     }
 
@@ -2453,7 +2472,7 @@ class Horde_Form_Type_date extends Horde_Form_Type {
             $valid = strlen(trim($value)) > 0;
 
             if (!$valid) {
-                $message = sprintf(_("%s is required"), $var->getHumanName());
+                $message = sprintf($this->_dict->t("%s is required"), $var->getHumanName());
             }
         }
 
@@ -2498,15 +2517,15 @@ class Horde_Form_Type_date extends Horde_Form_Type {
                                                    date('j'), date('n'),
                                                    date('Y'));
         if ($ago < -1) {
-            return sprintf(_(" (%s days ago)"), $diffdays);
+            return sprintf($this->_dict->t(" (%s days ago)"), $diffdays);
         } elseif ($ago == -1) {
-            return _(" (yesterday)");
+            return $this->_dict->t(" (yesterday)");
         } elseif ($ago == 0) {
-            return _(" (today)");
+            return $this->_dict->t(" (today)");
         } elseif ($ago == 1) {
-            return _(" (tomorrow)");
+            return $this->_dict->t(" (tomorrow)");
         } else {
-            return sprintf(_(" (in %s days)"), $diffdays);
+            return sprintf($this->_dict->t(" (in %s days)"), $diffdays);
         }
     }
 
@@ -2527,7 +2546,7 @@ class Horde_Form_Type_date extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Date"));
+        return array('name' => $this->_dict->t("Date"));
     }
 
 }
@@ -2537,7 +2556,7 @@ class Horde_Form_Type_time extends Horde_Form_Type {
     function isValid(&$var, &$vars, $value, &$message)
     {
         if ($var->isRequired() && empty($value) && ((string)(double)$value !== $value)) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -2545,7 +2564,7 @@ class Horde_Form_Type_time extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("This field may only contain numbers and the colon.");
+        $message = $this->_dict->t("This field may only contain numbers and the colon.");
         return false;
     }
 
@@ -2554,7 +2573,7 @@ class Horde_Form_Type_time extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Time"));
+        return array('name' => $this->_dict->t("Time"));
     }
 
 }
@@ -2576,10 +2595,10 @@ class Horde_Form_Type_hourminutesecond extends Horde_Form_Type {
         }
 
         if (!$this->emptyTimeArray($time) && !$this->checktime($time['hour'], $time['minute'], $time['second'])) {
-            $message = _("Please enter a valid time.");
+            $message = $this->_dict->t("Please enter a valid time.");
             return false;
         } elseif ($this->emptyTimeArray($time) && $var->isRequired()) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -2664,9 +2683,9 @@ class Horde_Form_Type_hourminutesecond extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Time selection"),
+            'name' => $this->_dict->t("Time selection"),
             'params' => array(
-                'seconds' => array('label' => _("Show seconds?"),
+                'seconds' => array('label' => $this->_dict->t("Show seconds?"),
                                    'type'  => 'boolean')));
     }
 
@@ -2698,7 +2717,7 @@ class Horde_Form_Type_monthyear extends Horde_Form_Type {
 
         if (!$vars->get($this->getMonthVar($var)) ||
             !$vars->get($this->getYearVar($var))) {
-            $message = _("Please enter a month and a year.");
+            $message = $this->_dict->t("Please enter a month and a year.");
             return false;
         }
 
@@ -2720,11 +2739,11 @@ class Horde_Form_Type_monthyear extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Month and year"),
+        return array('name' => $this->_dict->t("Month and year"),
                      'params' => array(
-                         'start_year' => array('label' => _("Start year"),
+                         'start_year' => array('label' => $this->_dict->t("Start year"),
                                                'type'  => 'int'),
-                         'end_year'   => array('label' => _("End year"),
+                         'end_year'   => array('label' => $this->_dict->t("End year"),
                                                'type'  => 'int')));
     }
 
@@ -2773,15 +2792,15 @@ class Horde_Form_Type_monthdayyear extends Horde_Form_Type {
         $empty = $this->emptyDateArray($date);
 
         if ($empty == 1 && $var->isRequired()) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         } elseif ($empty == 0 && !checkdate($date['month'],
                                             $date['day'],
                                             $date['year'])) {
-            $message = _("Please enter a valid date, check the number of days in the month.");
+            $message = $this->_dict->t("Please enter a valid date, check the number of days in the month.");
             return false;
         } elseif ($empty == -1) {
-            $message = _("Select all date components.");
+            $message = $this->_dict->t("Select all date components.");
             return false;
         }
 
@@ -2936,17 +2955,17 @@ class Horde_Form_Type_monthdayyear extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Date selection"),
+            'name' => $this->_dict->t("Date selection"),
             'params' => array(
-                'start_year' => array('label' => _("Start year"),
+                'start_year' => array('label' => $this->_dict->t("Start year"),
                                       'type'  => 'int'),
-                'end_year'   => array('label' => _("End year"),
+                'end_year'   => array('label' => $this->_dict->t("End year"),
                                       'type'  => 'int'),
-                'picker'     => array('label' => _("Show picker?"),
+                'picker'     => array('label' => $this->_dict->t("Show picker?"),
                                       'type'  => 'boolean'),
-                'format_in'  => array('label' => _("Storage format"),
+                'format_in'  => array('label' => $this->_dict->t("Storage format"),
                                       'type'  => 'text'),
-                'format_out' => array('label' => _("Display format"),
+                'format_out' => array('label' => $this->_dict->t("Display format"),
                                       'type'  => 'text')));
     }
 
@@ -3004,9 +3023,9 @@ class Horde_Form_Type_datetime extends Horde_Form_Type {
 
             $valid = $mdy_valid && $hms_valid;
             if ($mdy_valid && !$hms_valid) {
-                $message = _("You must choose a time.");
+                $message = $this->_dict->t("You must choose a time.");
             } elseif ($hms_valid && !$mdy_valid) {
-                $message = _("You must choose a date.");
+                $message = $this->_dict->t("You must choose a date.");
             }
         }
 
@@ -3099,19 +3118,19 @@ class Horde_Form_Type_datetime extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Date and time selection"),
+            'name' => $this->_dict->t("Date and time selection"),
             'params' => array(
-                'start_year' => array('label' => _("Start year"),
+                'start_year' => array('label' => $this->_dict->t("Start year"),
                                       'type'  => 'int'),
-                'end_year'   => array('label' => _("End year"),
+                'end_year'   => array('label' => $this->_dict->t("End year"),
                                       'type'  => 'int'),
-                'picker'     => array('label' => _("Show picker?"),
+                'picker'     => array('label' => $this->_dict->t("Show picker?"),
                                       'type'  => 'boolean'),
-                'format_in'  => array('label' => _("Storage format"),
+                'format_in'  => array('label' => $this->_dict->t("Storage format"),
                                       'type'  => 'text'),
-                'format_out' => array('label' => _("Display format"),
+                'format_out' => array('label' => $this->_dict->t("Display format"),
                                       'type'  => 'text'),
-                'seconds'    => array('label' => _("Show seconds?"),
+                'seconds'    => array('label' => $this->_dict->t("Show seconds?"),
                                       'type'  => 'boolean')));
     }
 
@@ -3122,7 +3141,7 @@ class Horde_Form_Type_colorpicker extends Horde_Form_Type {
     function isValid(&$var, &$vars, $value, &$message)
     {
         if ($var->isRequired() && empty($value)) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -3130,7 +3149,7 @@ class Horde_Form_Type_colorpicker extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("This field must contain a color code in the RGB Hex format, for example '#1234af'.");
+        $message = $this->_dict->t("This field must contain a color code in the RGB Hex format, for example '#1234af'.");
         return false;
     }
 
@@ -3139,7 +3158,7 @@ class Horde_Form_Type_colorpicker extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Colour selection"));
+        return array('name' => $this->_dict->t("Colour selection"));
     }
 
 }
@@ -3161,7 +3180,7 @@ class Horde_Form_Type_sound extends Horde_Form_Type {
     function isValid(&$var, &$vars, $value, &$message)
     {
         if ($var->isRequired() && empty($value)) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -3169,7 +3188,7 @@ class Horde_Form_Type_sound extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("Please choose a sound.");
+        $message = $this->_dict->t("Please choose a sound.");
         return false;
     }
 
@@ -3178,7 +3197,7 @@ class Horde_Form_Type_sound extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Sound selection"));
+        return array('name' => $this->_dict->t("Sound selection"));
     }
 
 }
@@ -3257,13 +3276,13 @@ class Horde_Form_Type_sorter extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Sort order selection"),
+            'name' => $this->_dict->t("Sort order selection"),
             'params' => array(
-                'values' => array('label' => _("Values"),
+                'values' => array('label' => $this->_dict->t("Values"),
                                   'type'  => 'stringarray'),
-                'size'   => array('label' => _("Size"),
+                'size'   => array('label' => $this->_dict->t("Size"),
                                   'type'  => 'int'),
-                'header' => array('label' => _("Header"),
+                'header' => array('label' => $this->_dict->t("Header"),
                                   'type'  => 'text')));
     }
 
@@ -3304,7 +3323,7 @@ class Horde_Form_Type_selectfiles extends Horde_Form_Type {
     {
         $this->_selectid = $selectid;
         if (is_null($link_text)) {
-            $link_text = _("Select Files");
+            $link_text = $this->_dict->t("Select Files");
         }
         $this->_link_text = $link_text;
         $this->_link_style = $link_style;
@@ -3325,15 +3344,15 @@ class Horde_Form_Type_selectfiles extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("File selection"),
+            'name' => $this->_dict->t("File selection"),
             'params' => array(
-                'selectid'   => array('label' => _("Id"),
+                'selectid'   => array('label' => $this->_dict->t("Id"),
                                       'type' => 'text'),
-                'link_text'  => array('label' => _("Link text"),
+                'link_text'  => array('label' => $this->_dict->t("Link text"),
                                       'type' => 'text'),
-                'link_style' => array('label' => _("Link style"),
+                'link_style' => array('label' => $this->_dict->t("Link style"),
                                       'type' => 'text'),
-                'icon'       => array('label' => _("Show icon?"),
+                'icon'       => array('label' => $this->_dict->t("Show icon?"),
                                       'type' => 'boolean')));
     }
 
@@ -3451,19 +3470,19 @@ class Horde_Form_Type_assign extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Assignment columns"),
+            'name' => $this->_dict->t("Assignment columns"),
             'params' => array(
-                'leftValues'  => array('label' => _("Left values"),
+                'leftValues'  => array('label' => $this->_dict->t("Left values"),
                                        'type'  => 'stringarray'),
-                'rightValues' => array('label' => _("Right values"),
+                'rightValues' => array('label' => $this->_dict->t("Right values"),
                                        'type'  => 'stringarray'),
-                'leftHeader'  => array('label' => _("Left header"),
+                'leftHeader'  => array('label' => $this->_dict->t("Left header"),
                                        'type'  => 'text'),
-                'rightHeader' => array('label' => _("Right header"),
+                'rightHeader' => array('label' => $this->_dict->t("Right header"),
                                        'type'  => 'text'),
-                'size'        => array('label' => _("Size"),
+                'size'        => array('label' => $this->_dict->t("Size"),
                                        'type'  => 'int'),
-                'width'       => array('label' => _("Width in CSS units"),
+                'width'       => array('label' => $this->_dict->t("Width in CSS units"),
                                        'type'  => 'text')));
     }
 
@@ -3474,7 +3493,7 @@ class Horde_Form_Type_creditcard extends Horde_Form_Type {
     function isValid(&$var, &$vars, $value, &$message)
     {
         if (empty($value) && $var->isRequired()) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -3482,7 +3501,7 @@ class Horde_Form_Type_creditcard extends Horde_Form_Type {
             /* getCardType() will also verify the checksum. */
             $type = $this->getCardType($value);
             if ($type === false || $type == 'unknown') {
-                $message = _("This does not seem to be a valid card number.");
+                $message = $this->_dict->t("This does not seem to be a valid card number.");
                 return false;
             }
         }
@@ -3566,7 +3585,7 @@ class Horde_Form_Type_creditcard extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Credit card number"));
+        return array('name' => $this->_dict->t("Credit card number"));
     }
 
 }
@@ -3583,7 +3602,7 @@ class Horde_Form_Type_obrowser extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Relationship browser"));
+        return array('name' => $this->_dict->t("Relationship browser"));
     }
 
 }
@@ -3619,13 +3638,13 @@ class Horde_Form_Type_dblookup extends Horde_Form_Type_enum {
     function about()
     {
         return array(
-            'name' => _("Database lookup"),
+            'name' => $this->_dict->t("Database lookup"),
             'params' => array(
-                'dsn' => array('label' => _("DSN (see http://pear.php.net/manual/en/package.database.db.intro-dsn.php)"),
+                'dsn' => array('label' => $this->_dict->t("DSN (see http://pear.php.net/manual/en/package.database.db.intro-dsn.php)"),
                                'type'  => 'text'),
-                'sql' => array('label' => _("SQL statement for value lookups"),
+                'sql' => array('label' => $this->_dict->t("SQL statement for value lookups"),
                                'type'  => 'text'),
-                'prompt' => array('label' => _("Prompt text"),
+                'prompt' => array('label' => $this->_dict->t("Prompt text"),
                                   'type'  => 'text'))
             );
     }
@@ -3646,12 +3665,12 @@ class Horde_Form_Type_figlet extends Horde_Form_Type {
     function isValid(&$var, &$vars, $value, &$message)
     {
         if (empty($value) && $var->isRequired()) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
         if (Horde_String::lower($value) != Horde_String::lower($this->_text)) {
-            $message = _("The text you entered did not match the text on the screen.");
+            $message = $this->_dict->t("The text you entered did not match the text on the screen.");
             return false;
         }
 
@@ -3674,11 +3693,11 @@ class Horde_Form_Type_figlet extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Figlet CAPTCHA"),
+            'name' => $this->_dict->t("Figlet CAPTCHA"),
             'params' => array(
-                'text' => array('label' => _("Text"),
+                'text' => array('label' => $this->_dict->t("Text"),
                                 'type'  => 'text'),
-                'font' => array('label' => _("Figlet font"),
+                'font' => array('label' => $this->_dict->t("Figlet font"),
                                 'type'  => 'text'))
             );
     }
@@ -3693,11 +3712,11 @@ class Horde_Form_Type_captcha extends Horde_Form_Type_figlet {
     function about()
     {
         return array(
-            'name' => _("Image CAPTCHA"),
+            'name' => $this->_dict->t("Image CAPTCHA"),
             'params' => array(
-                'text' => array('label' => _("Text"),
+                'text' => array('label' => $this->_dict->t("Text"),
                                 'type'  => 'text'),
-                'font' => array('label' => _("Font"),
+                'font' => array('label' => $this->_dict->t("Font"),
                                 'type'  => 'text'))
             );
     }
@@ -3723,13 +3742,13 @@ class Horde_Form_Type_category extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Category"));
+        return array('name' => $this->_dict->t("Category"));
     }
 
     function isValid(&$var, &$vars, $value, &$message)
     {
         if (empty($value) && $var->isRequired()) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
index 6451cfd..5b7ce3e 100644 (file)
@@ -31,7 +31,7 @@ class Horde_Form_Type_tableset extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("Invalid data submitted.");
+        $message = $this->_dict->t("Invalid data submitted.");
         return false;
     }
 
@@ -51,11 +51,11 @@ class Horde_Form_Type_tableset extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Table Set"),
+            'name' => $this->_dict->t("Table Set"),
             'params' => array(
-                'values' => array('label' => _("Values"),
+                'values' => array('label' => $this->_dict->t("Values"),
                                   'type'  => 'stringlist'),
-                'header' => array('label' => _("Headers"),
+                'header' => array('label' => $this->_dict->t("Headers"),
                                   'type'  => 'stringlist')),
             );
     }
index c7efba3..79dc5f6 100644 (file)
@@ -114,6 +114,13 @@ class Horde_Form_Variable {
     var $_options = array();
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Variable constructor.
      *
      * @param string $humanName      A short description of the variable's
@@ -124,9 +131,13 @@ class Horde_Form_Variable {
      * @param boolean $readonly      Whether this is a readonly variable.
      * @param string $description    A long description of the variable's
      *                               purpose, special instructions, etc.
+     * @param array $params  Hash with configuration data. Possible values:
+     *                       - 'translation': A translation handler
+     *                                        implementing Horde_Translation.
      */
     function Horde_Form_Variable($humanName, $varName, &$type, $required,
-                                 $readonly = false, $description = null)
+                                 $readonly = false, $description = null,
+                                 $params = array())
     {
         $this->humanName   = $humanName;
         $this->varName     = $varName;
@@ -135,6 +146,12 @@ class Horde_Form_Variable {
         $this->readonly    = $readonly;
         $this->description = $description;
         $this->_arrayVal   = (strpos($varName, '[]') !== false);
+
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Form', dirname(__FILE__) . '/../../locale');
+        }
     }
 
     /**
@@ -451,7 +468,7 @@ class Horde_Form_Variable {
             $vals = $this->getValue($vars);
             if (!is_array($vals)) {
                 if ($this->required) {
-                    $message = _("This field is required.");
+                    $message = $this->_dict->t("This field is required.");
                     return false;
                 } else {
                     return true;
@@ -459,7 +476,7 @@ class Horde_Form_Variable {
             }
             foreach ($vals as $i => $value) {
                 if ($value === null && $this->required) {
-                    $message = _("This field is required.");
+                    $message = $this->_dict->t("This field is required.");
                     return false;
                 } else {
                     if (!$this->type->isValid($this, $vars, $value, $message)) {
index 3c4d625..d0d4ef9 100644 (file)
@@ -118,7 +118,8 @@ class Horde_Icalendar_Vevent extends Horde_Icalendar
         try {
             $organizer = $this->getAttribute('ORGANIZER', true);
         } catch (Horde_Icalendar_Exception $e) {
-            return _("An unknown person");
+            $dict = new Horde_Translation_Gettext('Horde_Icalendar', dirname(__FILE__) . '/../../../locale');
+            return $this->_dict->t("An unknown person");
         }
 
         if (isset($organizer[0]['CN'])) {
index ff42807..995977d 100644 (file)
@@ -62,72 +62,79 @@ class Horde_Image_Exif
      *
      * @TODO: This should probably be extended by the subclass?
      *
+     * @param Horde_Translation $dict  A translation handler implementing
+     *                                 Horde_Translation.
+     *
      * @return array
      */
-    static public function getCategories()
+    static public function getCategories($dict = null)
     {
+        if (!$dict) {
+            $dict = new Horde_Translation_Gettext('Horde_Image', dirname(__FILE__) . '/../../../locale');
+        }
+
         return array(
             'IPTC' => array(
-                'Keywords' => array('description' => _("Image keywords"), 'type' => 'array'),
-                'ObjectName' => array('description' => _("Image Title"), 'type' => 'text'),
-                'By-line' => array('description' => _("By"), 'type' => 'text'),
-                'CopyrightNotice' => array('description' => _("Copyright"), 'type' => 'text'),
-                'Caption-Abstract' => array('description' => _("Caption"), 'type' => 'text'),
+                'Keywords' => array('description' => $dict->t("Image keywords"), 'type' => 'array'),
+                'ObjectName' => array('description' => $dict->t("Image Title"), 'type' => 'text'),
+                'By-line' => array('description' => $dict->t("By"), 'type' => 'text'),
+                'CopyrightNotice' => array('description' => $dict->t("Copyright"), 'type' => 'text'),
+                'Caption-Abstract' => array('description' => $dict->t("Caption"), 'type' => 'text'),
             ),
 
             'XMP' => array(
-                'Creator' => array('description' => _("Image Creator"), 'type' => 'text'),
-                'Rights' => array('description' => _("Rights"), 'type' => 'text'),
-                'UsageTerms' => array('description' => _("Usage Terms"), 'type' => 'type'),
+                'Creator' => array('description' => $dict->t("Image Creator"), 'type' => 'text'),
+                'Rights' => array('description' => $dict->t("Rights"), 'type' => 'text'),
+                'UsageTerms' => array('description' => $dict->t("Usage Terms"), 'type' => 'type'),
             ),
 
             'EXIF' => array(
-                'DateTime' => array('description' => _("Date Photo Modified"), 'type' => 'date'),
-                'DateTimeOriginal' => array('description' => _("Date Photo Taken"), 'type' => 'date'),
-                'DateTimeDigitized' => array('description' => _("Date Photo Digitized"), 'type' => 'date'),
-                'GPSLatitude' => array('description' => _("Latitude"), 'type' => 'gps'),
-                'GPSLongitude' => array('description' => _("Longitude"), 'type' => 'gps'),
-                'Make' => array('description' => _("Camera Make"), 'type' => 'text'),
-                'Model' => array('description' => _("Camera Model"), 'type' => 'text'),
-                'Software' => array('description' => _("Software Version"), 'type' => 'text'),
-                'ImageType' => array('description' => _("Photo Type"), 'type' => 'text'),
-                'ImageDescription' => array('description' => _("Photo Description"), 'type' => 'text'),
-                'FileSize' => array('description' => _("File Size"), 'type' => 'number'),
-                'ExifImageWidth' => array('description' => _("Width"), 'type' => 'number'),
-                'ExifImageLength' => array('description' => _("Height"), 'type' => 'number'),
-                'XResolution' => array('description' => _("X Resolution"), 'type' => 'number'),
-                'YResolution' => array('description' => _("Y Resolution"), 'type' => 'number'),
-                'ResolutionUnit' => array('description' => _("Resolution Unit"), 'type' => 'text'),
-                'ShutterSpeedValue' => array('description' => _("Shutter Speed"), 'type' => 'number'),
-                'ExposureTime' => array('description' => _("Exposure"), 'type' => 'number'),
-                'FocalLength' => array('description' => _("Focal Length"), 'type' => 'number'),
-                'FocalLengthIn35mmFilm' => array('description' => _("Focal Length (35mm equiv)"), 'type' => 'number'),
-                'ApertureValue' => array('description' => _("Aperture"), 'type' => 'number'),
-                'FNumber' => array('description' => _("F-Number"), 'type' => 'number'),
-                'ISOSpeedRatings' => array('description' => _("ISO Setting"), 'type' => 'number'),
-                'ExposureBiasValue' => array('description' => _("Exposure Bias"), 'type' => 'number'),
-                'ExposureMode' => array('description' => _("Exposure Mode"), 'type' => 'number'),
-                'ExposureProgram' => array('description' => _("Exposure Program"), 'type' => 'number'),
-                'MeteringMode' => array('description' => _("Metering Mode"), 'type' => 'number'),
-                'Flash' => array('description' => _("Flash Setting"), 'type' => 'number'),
-                'UserComment' => array('description' => _("User Comment"), 'type' => 'text'),
-                'ColorSpace' => array('description' => _("Color Space"), 'type' => 'number'),
-                'SensingMethod' => array('description' => _("Sensing Method"), 'type' => 'number'),
-                'WhiteBalance' => array('description' => _("White Balance"), 'type' => 'number'),
-                'Orientation' => array('description' => _("Camera Orientation"), 'type' => 'number'),
-                'Copyright' => array('description' => _("Copyright"), 'type' => 'text'),
-                'Artist' => array('description' => _("Artist"), 'type' => 'text'),
-                'LightSource' => array('description' => _("Light source"), 'type' => 'number'),
-                'ImageStabalization' => array('description' => _("Image Stabilization"), 'type' => 'text'),
-                'SceneCaptureType' => array('description' => _("Scene Type"), 'type' => 'number'),
+                'DateTime' => array('description' => $dict->t("Date Photo Modified"), 'type' => 'date'),
+                'DateTimeOriginal' => array('description' => $dict->t("Date Photo Taken"), 'type' => 'date'),
+                'DateTimeDigitized' => array('description' => $dict->t("Date Photo Digitized"), 'type' => 'date'),
+                'GPSLatitude' => array('description' => $dict->t("Latitude"), 'type' => 'gps'),
+                'GPSLongitude' => array('description' => $dict->t("Longitude"), 'type' => 'gps'),
+                'Make' => array('description' => $dict->t("Camera Make"), 'type' => 'text'),
+                'Model' => array('description' => $dict->t("Camera Model"), 'type' => 'text'),
+                'Software' => array('description' => $dict->t("Software Version"), 'type' => 'text'),
+                'ImageType' => array('description' => $dict->t("Photo Type"), 'type' => 'text'),
+                'ImageDescription' => array('description' => $dict->t("Photo Description"), 'type' => 'text'),
+                'FileSize' => array('description' => $dict->t("File Size"), 'type' => 'number'),
+                'ExifImageWidth' => array('description' => $dict->t("Width"), 'type' => 'number'),
+                'ExifImageLength' => array('description' => $dict->t("Height"), 'type' => 'number'),
+                'XResolution' => array('description' => $dict->t("X Resolution"), 'type' => 'number'),
+                'YResolution' => array('description' => $dict->t("Y Resolution"), 'type' => 'number'),
+                'ResolutionUnit' => array('description' => $dict->t("Resolution Unit"), 'type' => 'text'),
+                'ShutterSpeedValue' => array('description' => $dict->t("Shutter Speed"), 'type' => 'number'),
+                'ExposureTime' => array('description' => $dict->t("Exposure"), 'type' => 'number'),
+                'FocalLength' => array('description' => $dict->t("Focal Length"), 'type' => 'number'),
+                'FocalLengthIn35mmFilm' => array('description' => $dict->t("Focal Length (35mm equiv)"), 'type' => 'number'),
+                'ApertureValue' => array('description' => $dict->t("Aperture"), 'type' => 'number'),
+                'FNumber' => array('description' => $dict->t("F-Number"), 'type' => 'number'),
+                'ISOSpeedRatings' => array('description' => $dict->t("ISO Setting"), 'type' => 'number'),
+                'ExposureBiasValue' => array('description' => $dict->t("Exposure Bias"), 'type' => 'number'),
+                'ExposureMode' => array('description' => $dict->t("Exposure Mode"), 'type' => 'number'),
+                'ExposureProgram' => array('description' => $dict->t("Exposure Program"), 'type' => 'number'),
+                'MeteringMode' => array('description' => $dict->t("Metering Mode"), 'type' => 'number'),
+                'Flash' => array('description' => $dict->t("Flash Setting"), 'type' => 'number'),
+                'UserComment' => array('description' => $dict->t("User Comment"), 'type' => 'text'),
+                'ColorSpace' => array('description' => $dict->t("Color Space"), 'type' => 'number'),
+                'SensingMethod' => array('description' => $dict->t("Sensing Method"), 'type' => 'number'),
+                'WhiteBalance' => array('description' => $dict->t("White Balance"), 'type' => 'number'),
+                'Orientation' => array('description' => $dict->t("Camera Orientation"), 'type' => 'number'),
+                'Copyright' => array('description' => $dict->t("Copyright"), 'type' => 'text'),
+                'Artist' => array('description' => $dict->t("Artist"), 'type' => 'text'),
+                'LightSource' => array('description' => $dict->t("Light source"), 'type' => 'number'),
+                'ImageStabalization' => array('description' => $dict->t("Image Stabilization"), 'type' => 'text'),
+                'SceneCaptureType' => array('description' => $dict->t("Scene Type"), 'type' => 'number'),
 
             ),
 
             'COMPOSITE' => array(
-                'LensID' => array('description' => _("Lens"), 'type' => 'text'),
-                'Aperture' => array('description' => _("Aperture"), 'type' => 'text'),
-                'DOF' => array('description' => _("Depth of Field"), 'type' => 'text'),
-                'FOV' => array('description' => _("Field of View"), 'type' => 'text')
+                'LensID' => array('description' => $dict->t("Lens"), 'type' => 'text'),
+                'Aperture' => array('description' => $dict->t("Aperture"), 'type' => 'text'),
+                'DOF' => array('description' => $dict->t("Depth of Field"), 'type' => 'text'),
+                'FOV' => array('description' => $dict->t("Field of View"), 'type' => 'text')
             )
         );
     }
@@ -168,20 +175,22 @@ class Horde_Image_Exif
     /**
      * More human friendly exposure formatting.
      */
-    static protected function _formatExposure($data) {
+    static protected function _formatExposure($data)
+    {
+        $dict = new Horde_Translation_Gettext('Horde_Image', dirname(__FILE__) . '/../../../locale');
         if ($data > 0) {
             if ($data > 1) {
-                return sprintf(_("%d sec"), round($data, 2));
+                return sprintf($dict->t("%d sec"), round($data, 2));
             } else {
                 $n = $d = 0;
                 self::_convertToFraction($data, $n, $d);
                 if ($n <> 1) {
-                    return sprintf(_("%4f sec"), $n / $d);
+                    return sprintf($dict->t("%4f sec"), $n / $d);
                 }
-                return sprintf(_("%s / %s sec"), $n, $d);
+                return sprintf($dict->t("%s / %s sec"), $n, $d);
             }
         } else {
-            return _("Bulb");
+            return $dict->t("Bulb");
         }
     }
 
@@ -242,66 +251,67 @@ class Horde_Image_Exif
      */
     static public function getHumanReadable($field, $data)
     {
+        $dict = new Horde_Translation_Gettext('Horde_Image', dirname(__FILE__) . '/../../../locale');
         switch ($field) {
         case 'ExposureMode':
             switch ($data) {
-            case 0: return _("Auto exposure");
-            case 1: return _("Manual exposure");
-            case 2: return _("Auto bracket");
-            default: return _("Unknown");
+            case 0: return $dict->t("Auto exposure");
+            case 1: return $dict->t("Manual exposure");
+            case 2: return $dict->t("Auto bracket");
+            default: return $dict->t("Unknown");
             }
 
         case 'ExposureProgram':
             switch ($data) {
-            case 1: return _("Manual");
-            case 2: return _("Normal Program");
-            case 3: return _("Aperture Priority");
-            case 4: return _("Shutter Priority");
-            case 5: return _("Creative");
-            case 6: return _("Action");
-            case 7: return _("Portrait");
-            case 8: return _("Landscape");
-            default: return _("Unknown");
+            case 1: return $dict->t("Manual");
+            case 2: return $dict->t("Normal Program");
+            case 3: return $dict->t("Aperture Priority");
+            case 4: return $dict->t("Shutter Priority");
+            case 5: return $dict->t("Creative");
+            case 6: return $dict->t("Action");
+            case 7: return $dict->t("Portrait");
+            case 8: return $dict->t("Landscape");
+            default: return $dict->t("Unknown");
             }
 
         case 'XResolution':
         case 'YResolution':
             if (strpos($data, '/') !== false) {
                 list($n, $d) = explode('/', $data, 2);
-                return sprintf(_("%d dots per unit"), $n);
+                return sprintf($dict->t("%d dots per unit"), $n);
             }
-            return sprintf(_("%d per unit"), $data);
+            return sprintf($dict->t("%d per unit"), $data);
 
         case 'ResolutionUnit':
             switch ($data) {
-            case 1: return _("Pixels");
-            case 2: return _("Inch");
-            case 3: return _("Centimeter");
-            default: return _("Unknown");
+            case 1: return $dict->t("Pixels");
+            case 2: return $dict->t("Inch");
+            case 3: return $dict->t("Centimeter");
+            default: return $dict->t("Unknown");
             }
 
         case 'ExifImageWidth':
         case 'ExifImageLength':
-            return sprintf(_("%d pixels"), $data);
+            return sprintf($dict->t("%d pixels"), $data);
 
         case 'Orientation':
             switch ($data) {
             case 1:
-                return sprintf(_("Normal (O deg)"));
+                return sprintf($dict->t("Normal (O deg)"));
             case 2:
-                return sprintf(_("Mirrored"));
+                return sprintf($dict->t("Mirrored"));
             case 3:
-                return sprintf(_("Upsidedown"));
+                return sprintf($dict->t("Upsidedown"));
             case 4:
-                return sprintf(_("Upsidedown Mirrored"));
+                return sprintf($dict->t("Upsidedown Mirrored"));
             case 5:
-                return sprintf(_("90 deg CW Mirrored"));
+                return sprintf($dict->t("90 deg CW Mirrored"));
             case 6:
-                return sprintf(_("90 deg CCW"));
+                return sprintf($dict->t("90 deg CCW"));
             case 7:
-                return sprintf(_("90 deg CCW Mirrored"));
+                return sprintf($dict->t("90 deg CCW Mirrored"));
             case 8:
-                return sprintf(_("90 deg CW"));
+                return sprintf($dict->t("90 deg CW"));
             }
             break;
 
@@ -350,9 +360,9 @@ class Horde_Image_Exif
                 if ($d == 0) {
                     return;
                 }
-                return sprintf(_("%d mm"), round($n / $d));
+                return sprintf($dict->t("%d mm"), round($n / $d));
             }
-            return sprintf(_("%d mm"), $data);
+            return sprintf($dict->t("%d mm"), $data);
 
         case 'FNumber':
             if (strpos($data, '/') !== false) {
@@ -374,48 +384,48 @@ class Horde_Image_Exif
 
         case 'MeteringMode':
             switch ($data) {
-            case 0: return _("Unknown");
-            case 1: return _("Average");
-            case 2: return _("Center Weighted Average");
-            case 3: return _("Spot");
-            case 4: return _("Multi-Spot");
-            case 5: return _("Multi-Segment");
-            case 6: return _("Partial");
-            case 255: return _("Other");
-            default: return sprintf(_("Unknown: %s"), $data);
+            case 0: return $dict->t("Unknown");
+            case 1: return $dict->t("Average");
+            case 2: return $dict->t("Center Weighted Average");
+            case 3: return $dict->t("Spot");
+            case 4: return $dict->t("Multi-Spot");
+            case 5: return $dict->t("Multi-Segment");
+            case 6: return $dict->t("Partial");
+            case 255: return $dict->t("Other");
+            default: return sprintf($dict->t("Unknown: %s"), $data);
             }
             break;
 
         case 'LightSource':
             switch ($data) {;
-            case 1: return _("Daylight");
-            case 2: return _("Fluorescent");
-            case 3: return _("Tungsten");
-            case 4: return _("Flash");
-            case 9: return _("Fine weather");
-            case 10: return _("Cloudy weather");
-            case 11: return _("Shade");
-            case 12: return _("Daylight fluorescent");
-            case 13: return _("Day white fluorescent");
-            case 14: return _("Cool white fluorescent");
-            case 15: return _("White fluorescent");
-            case 17: return _("Standard light A");
-            case 18: return _("Standard light B");
-            case 19: return _("Standard light C");
+            case 1: return $dict->t("Daylight");
+            case 2: return $dict->t("Fluorescent");
+            case 3: return $dict->t("Tungsten");
+            case 4: return $dict->t("Flash");
+            case 9: return $dict->t("Fine weather");
+            case 10: return $dict->t("Cloudy weather");
+            case 11: return $dict->t("Shade");
+            case 12: return $dict->t("Daylight fluorescent");
+            case 13: return $dict->t("Day white fluorescent");
+            case 14: return $dict->t("Cool white fluorescent");
+            case 15: return $dict->t("White fluorescent");
+            case 17: return $dict->t("Standard light A");
+            case 18: return $dict->t("Standard light B");
+            case 19: return $dict->t("Standard light C");
             case 20: return 'D55';
             case 21: return 'D65';
             case 22: return 'D75';
             case 23: return 'D50';
-            case 24: return _("ISO studio tungsten");
-            case 255: return _("other light source");
-            default: return _("Unknown");
+            case 24: return $dict->t("ISO studio tungsten");
+            case 255: return $dict->t("other light source");
+            default: return $dict->t("Unknown");
             }
 
         case 'WhiteBalance':
             switch ($data) {
-            case 0: return _("Auto");
-            case 1: return _("Manual");
-            default: _("Unknown");
+            case 0: return $dict->t("Auto");
+            case 1: return $dict->t("Manual");
+            default: $dict->t("Unknown");
             }
             break;
 
@@ -424,28 +434,28 @@ class Horde_Image_Exif
 
         case 'Flash':
             switch ($data) {
-            case 0: return _("No Flash");
-            case 1: return _("Flash");
-            case 5: return _("Flash, strobe return light not detected");
-            case 7: return _("Flash, strobe return light detected");
-            case 9: return _("Compulsory Flash");
-            case 13: return _("Compulsory Flash, Return light not detected");
-            case 15: return _("Compulsory Flash, Return light detected");
-            case 16: return _("No Flash");
-            case 24: return _("No Flash");
-            case 25: return _("Flash, Auto-Mode");
-            case 29: return _("Flash, Auto-Mode, Return light not detected");
-            case 31: return _("Flash, Auto-Mode, Return light detected");
-            case 32: return _("No Flash");
-            case 65: return _("Red Eye");
-            case 69: return _("Red Eye, Return light not detected");
-            case 71: return _("Red Eye, Return light detected");
-            case 73: return _("Red Eye, Compulsory Flash");
-            case 77: return _("Red Eye, Compulsory Flash, Return light not detected");
-            case 79: return _("Red Eye, Compulsory Flash, Return light detected");
-            case 89: return _("Red Eye, Auto-Mode");
-            case 93: return _("Red Eye, Auto-Mode, Return light not detected");
-            case 95: return _("Red Eye, Auto-Mode, Return light detected");
+            case 0: return $dict->t("No Flash");
+            case 1: return $dict->t("Flash");
+            case 5: return $dict->t("Flash, strobe return light not detected");
+            case 7: return $dict->t("Flash, strobe return light detected");
+            case 9: return $dict->t("Compulsory Flash");
+            case 13: return $dict->t("Compulsory Flash, Return light not detected");
+            case 15: return $dict->t("Compulsory Flash, Return light detected");
+            case 16: return $dict->t("No Flash");
+            case 24: return $dict->t("No Flash");
+            case 25: return $dict->t("Flash, Auto-Mode");
+            case 29: return $dict->t("Flash, Auto-Mode, Return light not detected");
+            case 31: return $dict->t("Flash, Auto-Mode, Return light detected");
+            case 32: return $dict->t("No Flash");
+            case 65: return $dict->t("Red Eye");
+            case 69: return $dict->t("Red Eye, Return light not detected");
+            case 71: return $dict->t("Red Eye, Return light detected");
+            case 73: return $dict->t("Red Eye, Compulsory Flash");
+            case 77: return $dict->t("Red Eye, Compulsory Flash, Return light not detected");
+            case 79: return $dict->t("Red Eye, Compulsory Flash, Return light detected");
+            case 89: return $dict->t("Red Eye, Auto-Mode");
+            case 93: return $dict->t("Red Eye, Auto-Mode, Return light not detected");
+            case 95: return $dict->t("Red Eye, Auto-Mode, Return light detected");
             }
             break;
 
@@ -459,29 +469,29 @@ class Horde_Image_Exif
 
         case 'SensingMethod':
             switch ($data) {
-            case 1: return _("Not defined");
-            case 2: return _("One Chip Color Area Sensor");
-            case 3: return _("Two Chip Color Area Sensor");
-            case 4: return _("Three Chip Color Area Sensor");
-            case 5: return _("Color Sequential Area Sensor");
-            case 7: return _("Trilinear Sensor");
-            case 8: return _("Color Sequential Linear Sensor");
-            default: return _("Unknown");
+            case 1: return $dict->t("Not defined");
+            case 2: return $dict->t("One Chip Color Area Sensor");
+            case 3: return $dict->t("Two Chip Color Area Sensor");
+            case 4: return $dict->t("Three Chip Color Area Sensor");
+            case 5: return $dict->t("Color Sequential Area Sensor");
+            case 7: return $dict->t("Trilinear Sensor");
+            case 8: return $dict->t("Color Sequential Linear Sensor");
+            default: return $dict->t("Unknown");
             }
 
         case 'ColorSpace':
             switch ($data) {
-            case 1: return _("sRGB");
-            default: return _("Uncalibrated");
+            case 1: return $dict->t("sRGB");
+            default: return $dict->t("Uncalibrated");
             }
 
         case 'SceneCaptureType':
             switch ($data) {
-            case 0: return _("Standard");
-            case 1: return _("Landscape");
-            case 2: return _("Portrait");
-            case 3: return _("Night Scene");
-            default: return _("Unknown");
+            case 0: return $dict->t("Standard");
+            case 1: return $dict->t("Landscape");
+            case 2: return $dict->t("Portrait");
+            case 3: return $dict->t("Night Scene");
+            default: return $dict->t("Unknown");
             }
 
         case 'DateTime':
index 6198026..daab1f1 100644 (file)
@@ -26,6 +26,13 @@ abstract class Horde_Image_Exif_Base
     protected $_logger;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      *
      * @param $params
      */
@@ -35,6 +42,12 @@ abstract class Horde_Image_Exif_Base
             $this->_logger = $params['logger'];
             unset($params['logger']);
         }
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+            unset($params['translation']);
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Image', dirname(__FILE__) . '/../../../../locale');
+        }
         $this->_params = $params;
     }
 
index de9fda2..811cc85 100644 (file)
@@ -50,7 +50,7 @@ class Horde_Image_Exif_Bundled extends Horde_Image_Exif_Base
         // if the path was invalid, this error will catch it
         if (!$in || !$seek) {
             $result['Errors'] = 1;
-            $result['Error'][$result['Errors']] = _("The file could not be opened.");
+            $result['Error'][$result['Errors']] = $this->_dict->t("The file could not be opened.");
             return $result;
         }
 
@@ -229,7 +229,7 @@ class Horde_Image_Exif_Bundled extends Horde_Image_Exif_Base
         $v = fseek($in, $globalOffset + $ExitOffset);
         if ($v == -1) {
             $result['Errors'] = $result['Errors'] + 1;
-            $result['Error'][$result['Errors']] = _("Couldnt Find SubIFD");
+            $result['Error'][$result['Errors']] = $this->_dict->t("Couldnt Find SubIFD");
         }
 
         //===========================================================
@@ -248,7 +248,7 @@ class Horde_Image_Exif_Bundled extends Horde_Image_Exif_Base
             }
         } else {
             $result['Errors'] = $result['Errors'] + 1;
-            $result['Error'][$result['Errors']] = _("Illegal size for SubIFD");
+            $result['Error'][$result['Errors']] = $this->_dict->t("Illegal size for SubIFD");
         }
 
         // Add the 35mm equivalent focal length:
@@ -266,7 +266,7 @@ class Horde_Image_Exif_Bundled extends Horde_Image_Exif_Base
         $v = fseek($in, $globalOffset + $result['IFD1Offset']);
         if ($v == -1) {
             $result['Errors'] = $result['Errors'] + 1;
-            $result['Error'][$result['Errors']] = _("Couldnt Find IFD1");
+            $result['Error'][$result['Errors']] = $this->_dict->t("Couldnt Find IFD1");
         }
 
         //===========================================================
@@ -285,7 +285,7 @@ class Horde_Image_Exif_Bundled extends Horde_Image_Exif_Base
             }
         } else {
             $result['Errors'] = $result['Errors'] + 1;
-            $result['Error'][$result['Errors']] = _("Illegal size for IFD1");
+            $result['Error'][$result['Errors']] = $this->_dict->t("Illegal size for IFD1");
         }
 
         // include the thumbnail raw data...
@@ -312,7 +312,7 @@ class Horde_Image_Exif_Bundled extends Horde_Image_Exif_Base
         $v = fseek($in, $globalOffset + $result['SubIFD']['ExifInteroperabilityOffset']);
         if ($v == -1) {
             $result['Errors'] = $result['Errors'] + 1;
-            $result['Error'][$result['Errors']] = _("Couldnt Find InteroperabilityIFD");
+            $result['Error'][$result['Errors']] = $this->_dict->t("Couldnt Find InteroperabilityIFD");
         }
 
         //===========================================================
@@ -331,7 +331,7 @@ class Horde_Image_Exif_Bundled extends Horde_Image_Exif_Base
             }
         } else {
             $result['Errors'] = $result['Errors'] + 1;
-            $result['Error'][$result['Errors']] = _("Illegal size for InteroperabilityIFD");
+            $result['Error'][$result['Errors']] = $this->_dict->t("Illegal size for InteroperabilityIFD");
         }
 
         fclose($in);
@@ -410,22 +410,22 @@ class Horde_Image_Exif_Bundled extends Horde_Image_Exif_Base
             $make = Horde_String::lower($result['IFD0']['Make']);
             $parser = null;
             if (strpos($make, 'nikon') !== false) {
-                $parser = new Horde_Image_Exif_Parser_Nikon();
+                $parser = new Horde_Image_Exif_Parser_Nikon($this->_dict);
                 $result[$ifd_name]['KnownMaker'] = 1;
             } elseif (strpos($make, 'olympus') !== false) {
-                $parser = new Horde_Image_Exif_Parser_Olympus();
+                $parser = new Horde_Image_Exif_Parser_Olympus($this->_dict);
                 $result[$ifd_name]['KnownMaker'] = 1;
             } elseif (strpos($make, 'canon') !== false) {
-                $parser = new Horde_Image_Exif_Parser_Canon();
+                $parser = new Horde_Image_Exif_Parser_Canon($this->_dict);
                 $result[$ifd_name]['KnownMaker'] = 1;
             } elseif (strpos($make, 'fujifilm') !== false) {
-                $parser = new Horde_Image_Exif_Parser_Fujifilm();
+                $parser = new Horde_Image_Exif_Parser_Fujifilm($this->_dict);
                 $result[$ifd_name]['KnownMaker'] = 1;
             } elseif (strpos($make, 'sanyo') !== false) {
-                $parser = new Horde_Image_Exif_Parser_Sanyo();
+                $parser = new Horde_Image_Exif_Parser_Sanyo($this->_dict);
                 $result[$ifd_name]['KnownMaker'] = 1;
             } elseif (strpos($make, 'panasonic') !== false) {
-                $parser = new Horde_Image_Exif_Parser_Panasonic();
+                $parser = new Horde_Image_Exif_Parser_Panasonic($this->_dict);
                 $result[$ifd_name]['KnownMaker'] = 1;
             } else {
                 $result[$ifd_name]['KnownMaker'] = 0;
@@ -438,7 +438,7 @@ class Horde_Image_Exif_Bundled extends Horde_Image_Exif_Base
         case 'GPSInfoOffset':
             $formated_data = $this->_formatData($type, $tag, $intel, $data);
             $result[$ifd_name]['GPSInfo'] = $formated_data;
-            $parser = new Horde_Image_Exif_Parser_Gps();
+            $parser = new Horde_Image_Exif_Parser_Gps($this->_dict);
             $parser->parse($data, $result, $formated_data, $seek, $globalOffset);
             break;
 
@@ -797,7 +797,7 @@ class Horde_Image_Exif_Bundled extends Horde_Image_Exif_Base
         case 'UNDEFINED':
             // ExifVersion,FlashPixVersion,InteroperabilityVersion
             if ($tag == '9000' || $tag == 'a000' || $tag == '0002') {
-                $data = sprintf(_("version %d"), $data / 100);
+                $data = sprintf($this->_dict->t("version %d"), $data / 100);
             }
             break;
 
index 5296626..71ec729 100644 (file)
@@ -6,6 +6,28 @@
 class Horde_Image_Exif_Parser_Base
 {
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
+     * Constructor.
+     *
+     * @param Horde_Translation $dict  A translation handler implementing
+     *                                 Horde_Translation.
+     */
+    public function __construct($dict = null)
+    {
+        if ($dict) {
+            $this->_dict = $dict;
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Image', dirname(__FILE__) . '/../../../../../locale');
+        }
+    }
+
+    /**
      *
      * @param $type
      * @param $size
index eb2d757..1e3a96e 100644 (file)
@@ -42,7 +42,7 @@ class Horde_Image_Exif_Parser_Canon extends Horde_Image_Exif_Parser_Base
         case '0009': $tag = 'OwnerName'; break;
         case '000c': $tag = 'CameraSerialNumber'; break;
         case '000f': $tag = 'CustomFunctions'; break;
-        default:     $tag = sprintf(_("Unknown: (%s)"), $tag); break;
+        default:     $tag = sprintf($this->_dict->t("Unknown: (%s)"), $tag); break;
         }
 
         return $tag;
@@ -102,57 +102,57 @@ class Horde_Image_Exif_Parser_Canon extends Horde_Image_Exif_Parser_Base
                 $result['Macro'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//1
                 switch($result['Macro']) {
-                case 1: $result['Macro'] = _("Macro"); break;
-                case 2: $result['Macro'] = _("Normal"); break;
-                default: $result['Macro'] = _("Unknown");
+                case 1: $result['Macro'] = $this->_dict->t("Macro"); break;
+                case 2: $result['Macro'] = $this->_dict->t("Normal"); break;
+                default: $result['Macro'] = $this->_dict->t("Unknown");
                 }
                 $result['SelfTimer'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//2
                 switch($result['SelfTimer']) {
-                case 0: $result['SelfTimer'] = _("Off"); break;
-                default: $result['SelfTimer'] .= _("/10s");
+                case 0: $result['SelfTimer'] = $this->_dict->t("Off"); break;
+                default: $result['SelfTimer'] .= $this->_dict->t("/10s");
                 }
                 $result['Quality'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//3
                 switch($result['Quality']) {
-                case 2: $result['Quality'] = _("Normal"); break;
-                case 3: $result['Quality'] = _("Fine"); break;
-                case 5: $result['Quality'] = _("Superfine"); break;
-                default: $result['Quality'] = _("Unknown");
+                case 2: $result['Quality'] = $this->_dict->t("Normal"); break;
+                case 3: $result['Quality'] = $this->_dict->t("Fine"); break;
+                case 5: $result['Quality'] = $this->_dict->t("Superfine"); break;
+                default: $result['Quality'] = $this->_dict->t("Unknown");
                 }
                 $result['Flash'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//4
                 switch($result['Flash']) {
-                case 0: $result['Flash'] = _("Off"); break;
-                case 1: $result['Flash'] = _("Auto"); break;
-                case 2: $result['Flash'] = _("On"); break;
-                case 3: $result['Flash'] = _("Red Eye Reduction"); break;
-                case 4: $result['Flash'] = _("Slow Synchro"); break;
-                case 5: $result['Flash'] = _("Auto + Red Eye Reduction"); break;
-                case 6: $result['Flash'] = _("On + Red Eye Reduction"); break;
-                case 16: $result['Flash'] = _("External Flash"); break;
-                default: $result['Flash'] = _("Unknown");
+                case 0: $result['Flash'] = $this->_dict->t("Off"); break;
+                case 1: $result['Flash'] = $this->_dict->t("Auto"); break;
+                case 2: $result['Flash'] = $this->_dict->t("On"); break;
+                case 3: $result['Flash'] = $this->_dict->t("Red Eye Reduction"); break;
+                case 4: $result['Flash'] = $this->_dict->t("Slow Synchro"); break;
+                case 5: $result['Flash'] = $this->_dict->t("Auto + Red Eye Reduction"); break;
+                case 6: $result['Flash'] = $this->_dict->t("On + Red Eye Reduction"); break;
+                case 16: $result['Flash'] = $this->_dict->t("External Flash"); break;
+                default: $result['Flash'] = $this->_dict->t("Unknown");
                 }
                 $result['DriveMode'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//5
                 switch($result['DriveMode']) {
-                case 0: $result['DriveMode'] = _("Single/Timer"); break;
-                case 1: $result['DriveMode'] = _("Continuous"); break;
-                default: $result['DriveMode'] = _("Unknown");
+                case 0: $result['DriveMode'] = $this->_dict->t("Single/Timer"); break;
+                case 1: $result['DriveMode'] = $this->_dict->t("Continuous"); break;
+                default: $result['DriveMode'] = $this->_dict->t("Unknown");
                 }
                 $result['Unknown'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//6
                 $result['FocusMode'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//7
                 switch($result['FocusMode']) {
-                case 0: $result['FocusMode'] = _("One-Shot"); break;
-                case 1: $result['FocusMode'] = _("AI Servo"); break;
-                case 2: $result['FocusMode'] = _("AI Focus"); break;
-                case 3: $result['FocusMode'] = _("Manual Focus"); break;
-                case 4: $result['FocusMode'] = _("Single"); break;
-                case 5: $result['FocusMode'] = _("Continuous"); break;
-                case 6: $result['FocusMode'] = _("Manual Focus"); break;
-                default: $result['FocusMode'] = _("Unknown");
+                case 0: $result['FocusMode'] = $this->_dict->t("One-Shot"); break;
+                case 1: $result['FocusMode'] = $this->_dict->t("AI Servo"); break;
+                case 2: $result['FocusMode'] = $this->_dict->t("AI Focus"); break;
+                case 3: $result['FocusMode'] = $this->_dict->t("Manual Focus"); break;
+                case 4: $result['FocusMode'] = $this->_dict->t("Single"); break;
+                case 5: $result['FocusMode'] = $this->_dict->t("Continuous"); break;
+                case 6: $result['FocusMode'] = $this->_dict->t("Manual Focus"); break;
+                default: $result['FocusMode'] = $this->_dict->t("Unknown");
                 }
                 $result['Unknown'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//8
@@ -161,60 +161,60 @@ class Horde_Image_Exif_Parser_Canon extends Horde_Image_Exif_Parser_Base
                 $result['ImageSize'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//10
                 switch($result['ImageSize']) {
-                case 0: $result['ImageSize'] = _("Large"); break;
-                case 1: $result['ImageSize'] = _("Medium"); break;
-                case 2: $result['ImageSize'] = _("Small"); break;
-                default: $result['ImageSize'] = _("Unknown");
+                case 0: $result['ImageSize'] = $this->_dict->t("Large"); break;
+                case 1: $result['ImageSize'] = $this->_dict->t("Medium"); break;
+                case 2: $result['ImageSize'] = $this->_dict->t("Small"); break;
+                default: $result['ImageSize'] = $this->_dict->t("Unknown");
                 }
                 $result['EasyShooting'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//11
                 switch($result['EasyShooting']) {
-                case 0: $result['EasyShooting'] = _("Full Auto"); break;
-                case 1: $result['EasyShooting'] = _("Manual"); break;
-                case 2: $result['EasyShooting'] = _("Landscape"); break;
-                case 3: $result['EasyShooting'] = _("Fast Shutter"); break;
-                case 4: $result['EasyShooting'] = _("Slow Shutter"); break;
-                case 5: $result['EasyShooting'] = _("Night"); break;
-                case 6: $result['EasyShooting'] = _("Black & White"); break;
-                case 7: $result['EasyShooting'] = _("Sepia"); break;
-                case 8: $result['EasyShooting'] = _("Portrait"); break;
-                case 9: $result['EasyShooting'] = _("Sport"); break;
-                case 10: $result['EasyShooting'] = _("Macro/Close-Up"); break;
-                case 11: $result['EasyShooting'] = _("Pan Focus"); break;
-                default: $result['EasyShooting'] = _("Unknown");
+                case 0: $result['EasyShooting'] = $this->_dict->t("Full Auto"); break;
+                case 1: $result['EasyShooting'] = $this->_dict->t("Manual"); break;
+                case 2: $result['EasyShooting'] = $this->_dict->t("Landscape"); break;
+                case 3: $result['EasyShooting'] = $this->_dict->t("Fast Shutter"); break;
+                case 4: $result['EasyShooting'] = $this->_dict->t("Slow Shutter"); break;
+                case 5: $result['EasyShooting'] = $this->_dict->t("Night"); break;
+                case 6: $result['EasyShooting'] = $this->_dict->t("Black & White"); break;
+                case 7: $result['EasyShooting'] = $this->_dict->t("Sepia"); break;
+                case 8: $result['EasyShooting'] = $this->_dict->t("Portrait"); break;
+                case 9: $result['EasyShooting'] = $this->_dict->t("Sport"); break;
+                case 10: $result['EasyShooting'] = $this->_dict->t("Macro/Close-Up"); break;
+                case 11: $result['EasyShooting'] = $this->_dict->t("Pan Focus"); break;
+                default: $result['EasyShooting'] = $this->_dict->t("Unknown");
                 }
                 $result['DigitalZoom'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//12
                 switch($result['DigitalZoom']) {
                 case 0:
-                case 65535: $result['DigitalZoom'] = _("None"); break;
-                case 1: $result['DigitalZoom'] = _("2x"); break;
-                case 2: $result['DigitalZoom'] = _("4x"); break;
-                default: $result['DigitalZoom'] = _("Unknown");
+                case 65535: $result['DigitalZoom'] = $this->_dict->t("None"); break;
+                case 1: $result['DigitalZoom'] = $this->_dict->t("2x"); break;
+                case 2: $result['DigitalZoom'] = $this->_dict->t("4x"); break;
+                default: $result['DigitalZoom'] = $this->_dict->t("Unknown");
                 }
                 $result['Contrast'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//13
                 switch($result['Contrast']) {
-                case 0: $result['Contrast'] = _("Normal"); break;
-                case 1: $result['Contrast'] = _("High"); break;
-                case 65535: $result['Contrast'] = _("Low"); break;
-                default: $result['Contrast'] = _("Unknown");
+                case 0: $result['Contrast'] = $this->_dict->t("Normal"); break;
+                case 1: $result['Contrast'] = $this->_dict->t("High"); break;
+                case 65535: $result['Contrast'] = $this->_dict->t("Low"); break;
+                default: $result['Contrast'] = $this->_dict->t("Unknown");
                 }
                 $result['Saturation'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//14
                 switch($result['Saturation']) {
-                   case 0: $result['Saturation'] = _("Normal"); break;
-                    case 1: $result['Saturation'] = _("High"); break;
-                    case 65535: $result['Saturation'] = _("Low"); break;
-                    default: $result['Saturation'] = _("Unknown");
+                   case 0: $result['Saturation'] = $this->_dict->t("Normal"); break;
+                    case 1: $result['Saturation'] = $this->_dict->t("High"); break;
+                    case 65535: $result['Saturation'] = $this->_dict->t("Low"); break;
+                    default: $result['Saturation'] = $this->_dict->t("Unknown");
                 }
                 $result['Sharpness'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//15
                 switch($result['Sharpness']) {
-                case 0: $result['Sharpness'] = _("Normal"); break;
-                case 1: $result['Sharpness'] = _("High"); break;
-                case 65535: $result['Sharpness'] = _("Low"); break;
-                default: $result['Sharpness'] = _("Unknown");
+                case 0: $result['Sharpness'] = $this->_dict->t("Normal"); break;
+                case 1: $result['Sharpness'] = $this->_dict->t("High"); break;
+                case 65535: $result['Sharpness'] = $this->_dict->t("Low"); break;
+                default: $result['Sharpness'] = $this->_dict->t("Unknown");
                 }
                 $result['ISO'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//16
@@ -226,7 +226,7 @@ class Horde_Image_Exif_Parser_Canon extends Horde_Image_Exif_Parser_Base
                         'Unknown';
                      break;
                 case 15:
-                    $result['ISO'] = _("Auto");
+                    $result['ISO'] = $this->_dict->t("Auto");
                     break;
                 case 16:
                     $result['ISO'] = 50;
@@ -241,45 +241,45 @@ class Horde_Image_Exif_Parser_Canon extends Horde_Image_Exif_Parser_Base
                     $result['ISO'] = 400;
                      break;
                 default:
-                    $result['ISO'] = _("Unknown");
+                    $result['ISO'] = $this->_dict->t("Unknown");
                 }
                 $result['MeteringMode'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//17
                 switch($result['MeteringMode']) {
-                case 3: $result['MeteringMode'] = _("Evaluative"); break;
-                case 4: $result['MeteringMode'] = _("Partial"); break;
-                case 5: $result['MeteringMode'] = _("Center-weighted"); break;
-                default: $result['MeteringMode'] = _("Unknown");
+                case 3: $result['MeteringMode'] = $this->_dict->t("Evaluative"); break;
+                case 4: $result['MeteringMode'] = $this->_dict->t("Partial"); break;
+                case 5: $result['MeteringMode'] = $this->_dict->t("Center-weighted"); break;
+                default: $result['MeteringMode'] = $this->_dict->t("Unknown");
                 }
                 $result['FocusType'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//18
                 switch($result['FocusType']) {
-                case 0: $result['FocusType'] = _("Manual"); break;
-                case 1: $result['FocusType'] = _("Auto"); break;
-                case 3: $result['FocusType'] = _("Close-up (Macro)"); break;
-                case 8: $result['FocusType'] = _("Locked (Pan Mode)"); break;
-                default: $result['FocusType'] = _("Unknown");
+                case 0: $result['FocusType'] = $this->_dict->t("Manual"); break;
+                case 1: $result['FocusType'] = $this->_dict->t("Auto"); break;
+                case 3: $result['FocusType'] = $this->_dict->t("Close-up (Macro)"); break;
+                case 8: $result['FocusType'] = $this->_dict->t("Locked (Pan Mode)"); break;
+                default: $result['FocusType'] = $this->_dict->t("Unknown");
                 }
                 $result['AFPointSelected'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//19
                 switch($result['AFPointSelected']) {
-                case 12288: $result['AFPointSelected'] = _("Manual Focus"); break;
-                case 12289: $result['AFPointSelected'] = _("Auto Selected"); break;
-                case 12290: $result['AFPointSelected'] = _("Right"); break;
-                case 12291: $result['AFPointSelected'] = _("Center"); break;
-                case 12292: $result['AFPointSelected'] = _("Left"); break;
-                default: $result['AFPointSelected'] = _("Unknown");
+                case 12288: $result['AFPointSelected'] = $this->_dict->t("Manual Focus"); break;
+                case 12289: $result['AFPointSelected'] = $this->_dict->t("Auto Selected"); break;
+                case 12290: $result['AFPointSelected'] = $this->_dict->t("Right"); break;
+                case 12291: $result['AFPointSelected'] = $this->_dict->t("Center"); break;
+                case 12292: $result['AFPointSelected'] = $this->_dict->t("Left"); break;
+                default: $result['AFPointSelected'] = $this->_dict->t("Unknown");
                 }
                 $result['ExposureMode'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//20
                 switch($result['ExposureMode']) {
-                case 0: $result['ExposureMode'] = _("EasyShoot"); break;
-                case 1: $result['ExposureMode'] = _("Program"); break;
-                case 2: $result['ExposureMode'] = _("Tv"); break;
-                case 3: $result['ExposureMode'] = _("Av"); break;
-                case 4: $result['ExposureMode'] = _("Manual"); break;
-                case 5: $result['ExposureMode'] = _("Auto-DEP"); break;
-                default: $result['ExposureMode'] = _("Unknown");
+                case 0: $result['ExposureMode'] = $this->_dict->t("EasyShoot"); break;
+                case 1: $result['ExposureMode'] = $this->_dict->t("Program"); break;
+                case 2: $result['ExposureMode'] = $this->_dict->t("Tv"); break;
+                case 3: $result['ExposureMode'] = $this->_dict->t("Av"); break;
+                case 4: $result['ExposureMode'] = $this->_dict->t("Manual"); break;
+                case 5: $result['ExposureMode'] = $this->_dict->t("Auto-DEP"); break;
+                default: $result['ExposureMode'] = $this->_dict->t("Unknown");
                 }
                 $result['Unknown'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//21
@@ -301,27 +301,27 @@ class Horde_Image_Exif_Parser_Canon extends Horde_Image_Exif_Parser_Base
                 $result['FlashActivity'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//28
                 switch($result['FlashActivity']) {
-                case 0: $result['FlashActivity'] = _("Flash Did Not Fire"); break;
-                case 1: $result['FlashActivity'] = _("Flash Fired"); break;
-                default: $result['FlashActivity'] = _("Unknown");
+                case 0: $result['FlashActivity'] = $this->_dict->t("Flash Did Not Fire"); break;
+                case 1: $result['FlashActivity'] = $this->_dict->t("Flash Fired"); break;
+                default: $result['FlashActivity'] = $this->_dict->t("Unknown");
                 }
                 $result['FlashDetails'] = str_pad(base_convert(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)), 16, 2), 16, '0', STR_PAD_LEFT);
                 $place += 4;//29
                 $flashDetails = array();
                 if (substr($result['FlashDetails'], 1, 1) == 1) {
-                    $flashDetails[] = _("External E-TTL");
+                    $flashDetails[] = $this->_dict->t("External E-TTL");
                 }
                 if (substr($result['FlashDetails'], 2, 1) == 1) {
-                    $flashDetails[] = _("Internal Flash");
+                    $flashDetails[] = $this->_dict->t("Internal Flash");
                 }
                 if (substr($result['FlashDetails'], 4, 1) == 1) {
-                    $flashDetails[] = _("FP sync used");
+                    $flashDetails[] = $this->_dict->t("FP sync used");
                 }
                 if (substr($result['FlashDetails'], 8, 1) == 1) {
-                    $flashDetails[] = _("2nd(rear)-curtain sync used");
+                    $flashDetails[] = $this->_dict->t("2nd(rear)-curtain sync used");
                  }
                 if (substr($result['FlashDetails'], 12, 1) == 1) {
-                    $flashDetails[] = _("1st curtain sync");
+                    $flashDetails[] = $this->_dict->t("1st curtain sync");
                 }
                 $result['FlashDetails'] = implode(',', $flashDetails);
                 $result['Unknown'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
@@ -332,9 +332,9 @@ class Horde_Image_Exif_Parser_Canon extends Horde_Image_Exif_Parser_Base
                 $place += 4;//32
                 if (strpos(strtoupper($exif['IFD0']['Model']), 'G1') !== false) {
                     switch($anotherFocusMode) {
-                    case 0: $result['FocusMode'] = _("Single"); break;
-                    case 1: $result['FocusMode'] = _("Continuous"); break;
-                    default: $result['FocusMode'] = _("Unknown");
+                    case 0: $result['FocusMode'] = $this->_dict->t("Single"); break;
+                    case 1: $result['FocusMode'] = $this->_dict->t("Continuous"); break;
+                    default: $result['FocusMode'] = $this->_dict->t("Unknown");
                     }
                 }
                 break;
@@ -361,14 +361,14 @@ class Horde_Image_Exif_Parser_Canon extends Horde_Image_Exif_Parser_Base
                 $result['WhiteBalance'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//7
                 switch($result['WhiteBalance']) {
-                case 0: $result['WhiteBalance'] = _("Auto"); break;
-                case 1: $result['WhiteBalance'] = _("Sunny"); break;
-                case 2: $result['WhiteBalance'] = _("Cloudy"); break;
-                case 3: $result['WhiteBalance'] = _("Tungsten"); break;
-                case 4: $result['WhiteBalance'] = _("Fluorescent"); break;
-                case 5: $result['WhiteBalance'] = _("Flash"); break;
-                case 6: $result['WhiteBalance'] = _("Custom"); break;
-                default: $result['WhiteBalance'] = _("Unknown");
+                case 0: $result['WhiteBalance'] = $this->_dict->t("Auto"); break;
+                case 1: $result['WhiteBalance'] = $this->_dict->t("Sunny"); break;
+                case 2: $result['WhiteBalance'] = $this->_dict->t("Cloudy"); break;
+                case 3: $result['WhiteBalance'] = $this->_dict->t("Tungsten"); break;
+                case 4: $result['WhiteBalance'] = $this->_dict->t("Fluorescent"); break;
+                case 5: $result['WhiteBalance'] = $this->_dict->t("Flash"); break;
+                case 6: $result['WhiteBalance'] = $this->_dict->t("Custom"); break;
+                default: $result['WhiteBalance'] = $this->_dict->t("Unknown");
                 }
                 $result['Unknown'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//8
@@ -386,13 +386,13 @@ class Horde_Image_Exif_Parser_Canon extends Horde_Image_Exif_Parser_Base
                 $place += 4;//14
                 $afPointUsed = array();
                 if ($result['AFPointUsed'] & 0x0001) {
-                    $afPointUsed[] = _("Right"); //bit 0
+                    $afPointUsed[] = $this->_dict->t("Right"); //bit 0
                 }
                 if ($result['AFPointUsed'] & 0x0002) {
-                    $afPointUsed[] = _("Center"); //bit 1
+                    $afPointUsed[] = $this->_dict->t("Center"); //bit 1
                 }
                 if ($result['AFPointUsed'] & 0x0004) {
-                    $afPointUsed[] = _("Left"); //bit 2
+                    $afPointUsed[] = $this->_dict->t("Left"); //bit 2
                 }
                 if ($result['AFPointUsed'] & 0x0800) {
                     $afPointUsed[] = 12; //bit 12
@@ -427,7 +427,7 @@ class Horde_Image_Exif_Parser_Canon extends Horde_Image_Exif_Parser_Base
                 case '0030': $result['FlashBias'] = '1.5 EV'; break;
                 case '0034': $result['FlashBias'] = '1.67 EV'; break;
                 case '0040': $result['FlashBias'] = '2 EV'; break;
-                default: $result['FlashBias'] = _("Unknown");
+                default: $result['FlashBias'] = $this->_dict->t("Unknown");
                 }
                 $result['Unknown'] = hexdec(Horde_Image_Exif::intel2Moto(substr($data, $place, 4)));
                 $place += 4;//16
index cf89f29..a6075d3 100644 (file)
@@ -33,7 +33,7 @@ class Horde_Image_Exif_Parser_Fujifilm extends Horde_Image_Exif_Parser_Base
      */
     protected function _lookupTag($tag)
     {
-        switch($tag) {
+        switch ($tag) {
         case '0000': return 'Version';
         case '1000': return 'Quality';
         case '1001': return 'Sharpness';
@@ -74,7 +74,7 @@ class Horde_Image_Exif_Parser_Fujifilm extends Horde_Image_Exif_Parser_Base
         case 'URATIONAL':
         case 'SRATIONAL':
             $data = bin2hex($data);
-            if ($intel == 1) {
+            if ($intel) {
                 $data = Horde_Image_Exif::intel2Moto($data);
             }
             $top = hexdec(substr($data, 8, 8));
@@ -100,7 +100,7 @@ class Horde_Image_Exif_Parser_Fujifilm extends Horde_Image_Exif_Parser_Base
         case 'FLOAT':
         case 'DOUBLE':
             $data = bin2hex($data);
-            if ($intel == 1) {
+            if ($intel) {
                 $data = Horde_Image_Exif::intel2Moto($data);
             }
             $data = hexdec($data);
@@ -109,137 +109,137 @@ class Horde_Image_Exif_Parser_Fujifilm extends Horde_Image_Exif_Parser_Base
             case '1001':
                 //Sharpness
                 switch ($data) {
-                case 1:  $data = _("Soft"); break;
-                case 2:  $data = _("Soft"); break;
-                case 3:  $data = _("Normal"); break;
-                case 4:  $data = _("Hard"); break;
-                case 5:  $data = _("Hard"); break;
-                default: $data = _("Unknown") . ': ' . $data; break;
+                case 1:  $data = $this->_dict->t("Soft"); break;
+                case 2:  $data = $this->_dict->t("Soft"); break;
+                case 3:  $data = $this->_dict->t("Normal"); break;
+                case 4:  $data = $this->_dict->t("Hard"); break;
+                case 5:  $data = $this->_dict->t("Hard"); break;
+                default: $data = $this->_dict->t("Unknown") . ': ' . $data; break;
                 }
                 break;
 
             case '1002':
                 //WhiteBalance
                 switch ($data) {
-                case 0:    $data = _("Auto"); break;
-                case 256:  $data = _("Daylight"); break;
-                case 512:  $data = _("Cloudy"); break;
-                case 768:  $data = _("DaylightColor-fluorescence"); break;
-                case 769:  $data = _("DaywhiteColor-fluorescence"); break;
-                case 770:  $data = _("White-fluorescence"); break;
-                case 1024: $data = _("Incandescense"); break;
-                case 3840: $data = _("Custom"); break;
-                default:   $data = _("Unknown") . ': ' . $data; break;
+                case 0:    $data = $this->_dict->t("Auto"); break;
+                case 256:  $data = $this->_dict->t("Daylight"); break;
+                case 512:  $data = $this->_dict->t("Cloudy"); break;
+                case 768:  $data = $this->_dict->t("DaylightColor-fluorescence"); break;
+                case 769:  $data = $this->_dict->t("DaywhiteColor-fluorescence"); break;
+                case 770:  $data = $this->_dict->t("White-fluorescence"); break;
+                case 1024: $data = $this->_dict->t("Incandescense"); break;
+                case 3840: $data = $this->_dict->t("Custom"); break;
+                default:   $data = $this->_dict->t("Unknown") . ': ' . $data; break;
                 }
                 break;
 
             case '1003':
                 //Color
                 switch ($data) {
-                case 0:   $data = _("Chroma Saturation Normal(STD)"); break;
-                case 256: $data = _("Chroma Saturation High"); break;
-                case 512: $data = _("Chroma Saturation Low(ORG)"); break;
-                default:  $data = _("Unknown: ") . $data; break;
+                case 0:   $data = $this->_dict->t("Chroma Saturation Normal(STD)"); break;
+                case 256: $data = $this->_dict->t("Chroma Saturation High"); break;
+                case 512: $data = $this->_dict->t("Chroma Saturation Low(ORG)"); break;
+                default:  $data = $this->_dict->t("Unknown: ") . $data; break;
                 }
                 break;
 
             case '1004':
                 //Tone
                 switch ($data) {
-                case 0: $data = _("Contrast Normal(STD)"); break;
-                case 256: $data = _("Contrast High(HARD)"); break;
-                case 512: $data = _("Contrast Low(ORG)"); break;
-                default: $data = _("Unknown: ") . $data; break;
+                case 0: $data = $this->_dict->t("Contrast Normal(STD)"); break;
+                case 256: $data = $this->_dict->t("Contrast High(HARD)"); break;
+                case 512: $data = $this->_dict->t("Contrast Low(ORG)"); break;
+                default: $data = $this->_dict->t("Unknown: ") . $data; break;
                 }
                 break;
 
             case '1010':
                 //FlashMode
                 switch ($data) {
-                case 0:  $data = _("Auto"); break;
-                case 1:  $data = _("On"); break;
-                case 2:  $data = _("Off"); break;
-                case 3:  $data = _("Red-Eye Reduction"); break;
-                default: $data = _("Unknown: ") . $data; break;
+                case 0:  $data = $this->_dict->t("Auto"); break;
+                case 1:  $data = $this->_dict->t("On"); break;
+                case 2:  $data = $this->_dict->t("Off"); break;
+                case 3:  $data = $this->_dict->t("Red-Eye Reduction"); break;
+                default: $data = $this->_dict->t("Unknown: ") . $data; break;
                 }
                 break;
 
             case '1020':
                 //Macro
                 switch ($data) {
-                case 0:  $data = _("Off"); break;
-                case 1:  $data = _("On"); break;
-                default: $data = _("Unknown: ") . $data; break;
+                case 0:  $data = $this->_dict->t("Off"); break;
+                case 1:  $data = $this->_dict->t("On"); break;
+                default: $data = $this->_dict->t("Unknown: ") . $data; break;
                 }
                 break;
 
             case '1021':
                 //FocusMode
                 switch ($data) {
-                case 0:  $data = _("Auto"); break;
-                case 1:  $data = _("Manual"); break;
-                default: $data = _("Unknown: ") . $data; break;
+                case 0:  $data = $this->_dict->t("Auto"); break;
+                case 1:  $data = $this->_dict->t("Manual"); break;
+                default: $data = $this->_dict->t("Unknown: ") . $data; break;
                 }
                 break;
 
             case '1030':
                 //SlowSync
                 switch ($data) {
-                case 0:  $data = _("Off"); break;
-                case 1:  $data = _("On"); break;
-                default: $data = _("Unknown: ") . $data; break;
+                case 0:  $data = $this->_dict->t("Off"); break;
+                case 1:  $data = $this->_dict->t("On"); break;
+                default: $data = $this->_dict->t("Unknown: ") . $data; break;
                 }
                 break;
 
             case '1031':
                 //PictureMode
                 switch ($data) {
-                case 0:  $data = _("Auto"); break;
-                case 1:  $data = _("Portrait"); break;
-                case 2:  $data = _("Landscape"); break;
-                case 4:  $data = _("Sports"); break;
-                case 5:  $data = _("Night"); break;
-                case 6:  $data = _("Program AE"); break;
-                case 256:  $data = _("Aperture Prority AE"); break;
-                case 512:  $data = _("Shutter Priority"); break;
-                case 768:  $data = _("Manual Exposure"); break;
-                default: $data = _("Unknown: ") . $data; break;
+                case 0:  $data = $this->_dict->t("Auto"); break;
+                case 1:  $data = $this->_dict->t("Portrait"); break;
+                case 2:  $data = $this->_dict->t("Landscape"); break;
+                case 4:  $data = $this->_dict->t("Sports"); break;
+                case 5:  $data = $this->_dict->t("Night"); break;
+                case 6:  $data = $this->_dict->t("Program AE"); break;
+                case 256:  $data = $this->_dict->t("Aperture Prority AE"); break;
+                case 512:  $data = $this->_dict->t("Shutter Priority"); break;
+                case 768:  $data = $this->_dict->t("Manual Exposure"); break;
+                default: $data = $this->_dict->t("Unknown: ") . $data; break;
                 }
                 break;
 
             case '1100':
                 //ContinuousTakingBracket
                 switch ($data) {
-                case 0:  $data = _("Off"); break;
-                case 1:  $data = _("On"); break;
-                default: $data = _("Unknown: ") . $data; break;
+                case 0:  $data = $this->_dict->t("Off"); break;
+                case 1:  $data = $this->_dict->t("On"); break;
+                default: $data = $this->_dict->t("Unknown: ") . $data; break;
                 }
                 break;
 
             case '1300':
                 //BlurWarning
                 switch ($data) {
-                case 0:  $data = _("No Warning"); break;
-                case 1:  $data = _("Warning"); break;
-                default: $data = _("Unknown: ") . $data; break;
+                case 0:  $data = $this->_dict->t("No Warning"); break;
+                case 1:  $data = $this->_dict->t("Warning"); break;
+                default: $data = $this->_dict->t("Unknown: ") . $data; break;
                 }
                 break;
 
             case '1301':
                 //FocusWarning
                 switch ($data) {
-                case 0:  $data = _("Auto Focus Good"); break;
-                case 1:  $data = _("Out of Focus"); break;
-                default: $data = _("Unknown: ") . $data; break;
+                case 0:  $data = $this->_dict->t("Auto Focus Good"); break;
+                case 1:  $data = $this->_dict->t("Out of Focus"); break;
+                default: $data = $this->_dict->t("Unknown: ") . $data; break;
                 }
                 break;
 
             case '1302':
                 //AEWarning
                 switch ($data) {
-                case 0:  $data = _("AE Good"); break;
-                case 1:  $data = _("Over Exposure"); break;
-                default: $data = _("Unknown: ") . $data; break;
+                case 0:  $data = $this->_dict->t("AE Good"); break;
+                case 1:  $data = $this->_dict->t("Over Exposure"); break;
+                default: $data = $this->_dict->t("Unknown: ") . $data; break;
                 }
                 break;
             }
@@ -247,7 +247,7 @@ class Horde_Image_Exif_Parser_Fujifilm extends Horde_Image_Exif_Parser_Base
 
         default:
             $data = bin2hex($data);
-            if ($intel == 1) {
+            if ($intel) {
                 $data = Horde_Image_Exif::intel2Moto($data);
             }
             break;
@@ -264,7 +264,7 @@ class Horde_Image_Exif_Parser_Fujifilm extends Horde_Image_Exif_Parser_Base
      */
     public function parse($block, &$result)
     {
-        $intel = 1;
+        $intel = true;
         $model = $result['IFD0']['Model'];
 
         //current place
@@ -273,7 +273,7 @@ class Horde_Image_Exif_Parser_Fujifilm extends Horde_Image_Exif_Parser_Base
 
         $num = bin2hex(substr($block, $place, 4));
         $place += 4;
-        if ($intel == 1) {
+        if ($intel) {
             $num = Horde_Image_Exif::intel2Moto($num);
         }
         $result['SubIFD']['MakerNote']['Offset'] = hexdec($num);
@@ -281,7 +281,7 @@ class Horde_Image_Exif_Parser_Fujifilm extends Horde_Image_Exif_Parser_Base
         //Get number of tags (2 bytes)
         $num = bin2hex(substr($block, $place, 2));
         $place += 2;
-        if ($intel == 1) {
+        if ($intel) {
             $num = Horde_Image_Exif::intel2Moto($num);
         }
         $result['SubIFD']['MakerNote']['MakerNoteNumTags'] = hexdec($num);
@@ -291,7 +291,7 @@ class Horde_Image_Exif_Parser_Fujifilm extends Horde_Image_Exif_Parser_Base
             //2 byte tag
             $tag = bin2hex(substr($block, $place, 2));
             $place += 2;
-            if ($intel == 1) {
+            if ($intel) {
                 $tag = Horde_Image_Exif::intel2Moto($tag);
             }
             $tag_name = $this->_lookupTag($tag);
@@ -299,7 +299,7 @@ class Horde_Image_Exif_Parser_Fujifilm extends Horde_Image_Exif_Parser_Base
             //2 byte type
             $type = bin2hex(substr($block, $place, 2));
             $place += 2;
-            if ($intel == 1) {
+            if ($intel) {
                 $type = Horde_Image_Exif::intel2Moto($type);
             }
             $this->_lookupType($type, $size);
@@ -307,7 +307,7 @@ class Horde_Image_Exif_Parser_Fujifilm extends Horde_Image_Exif_Parser_Base
             //4 byte count of number of data units
             $count = bin2hex(substr($block, $place, 4));
             $place += 4;
-            if ($intel == 1) {
+            if ($intel) {
                 $count = Horde_Image_Exif::intel2Moto($count);
             }
             $bytesofdata = $size * hexdec($count);
@@ -320,7 +320,7 @@ class Horde_Image_Exif_Parser_Fujifilm extends Horde_Image_Exif_Parser_Base
                 $data = $value;
             } else {
                 $value = bin2hex($value);
-                if ($intel == 1) {
+                if ($intel) {
                     $value = Horde_Image_Exif::intel2Moto($value);
                 }
                 $data = substr($block, hexdec($value) - $offset, $bytesofdata * 2);
index c7714ac..03fd54c 100644 (file)
@@ -148,34 +148,34 @@ class Horde_Image_Exif_Parser_Nikon extends Horde_Image_Exif_Parser_Base
             case '0003':
                 //Quality
                 switch ($data) {
-                case 1:  $data = _("VGA Basic"); break;
-                case 2:  $data = _("VGA Normal"); break;
-                case 3:  $data = _("VGA Fine"); break;
-                case 4:  $data = _("SXGA Basic"); break;
-                case 5:  $data = _("SXGA Normal"); break;
-                case 6:  $data = _("SXGA Fine"); break;
-                default: $data = _("Unknown") . ': ' . $data; break;
+                case 1:  $data = $this->_dict->t("VGA Basic"); break;
+                case 2:  $data = $this->_dict->t("VGA Normal"); break;
+                case 3:  $data = $this->_dict->t("VGA Fine"); break;
+                case 4:  $data = $this->_dict->t("SXGA Basic"); break;
+                case 5:  $data = $this->_dict->t("SXGA Normal"); break;
+                case 6:  $data = $this->_dict->t("SXGA Fine"); break;
+                default: $data = $this->_dict->t("Unknown") . ': ' . $data; break;
                 }
                 break;
 
             case '0004':
                 //Color
                 switch ($data) {
-                case 1:  $data = _("Color"); break;
-                case 2:  $data = _("Monochrome"); break;
-                default: $data = _("Unknown") . ': ' . $data; break;
+                case 1:  $data = $this->_dict->t("Color"); break;
+                case 2:  $data = $this->_dict->t("Monochrome"); break;
+                default: $data = $this->_dict->t("Unknown") . ': ' . $data; break;
                 }
                 break;
 
             case '0005':
                 //Image Adjustment
                 switch ($data) {
-                case 0:  $data = _("Normal"); break;
-                case 1:  $data = _("Bright+"); break;
-                case 2:  $data = _("Bright-"); break;
-                case 3:  $data = _("Contrast+"); break;
-                case 4:  $data = _("Contrast-"); break;
-                default: $data = _("Unknown") . ': ' . $data; break;
+                case 0:  $data = $this->_dict->t("Normal"); break;
+                case 1:  $data = $this->_dict->t("Bright+"); break;
+                case 2:  $data = $this->_dict->t("Bright-"); break;
+                case 3:  $data = $this->_dict->t("Contrast+"); break;
+                case 4:  $data = $this->_dict->t("Contrast-"); break;
+                default: $data = $this->_dict->t("Unknown") . ': ' . $data; break;
                 }
                 break;
 
@@ -186,30 +186,30 @@ class Horde_Image_Exif_Parser_Nikon extends Horde_Image_Exif_Parser_Base
                 case 2:  $data = 'ISO-160'; break;
                 case 4:  $data = 'ISO-320'; break;
                 case 5:  $data = 'ISO-100'; break;
-                default: $data = _("Unknown") . ': ' . $data; break;
+                default: $data = $this->_dict->t("Unknown") . ': ' . $data; break;
                 }
                 break;
 
             case '0007':
                 //White Balance
                 switch ($data) {
-                case 0:  $data = _("Auto"); break;
-                case 1:  $data = _("Preset"); break;
-                case 2:  $data = _("Daylight"); break;
-                case 3:  $data = _("Incandescense"); break;
-                case 4:  $data = _("Flourescence"); break;
-                case 5:  $data = _("Cloudy"); break;
-                case 6:  $data = _("SpeedLight"); break;
-                default: $data = _("Unknown") . ': ' . $data; break;
+                case 0:  $data = $this->_dict->t("Auto"); break;
+                case 1:  $data = $this->_dict->t("Preset"); break;
+                case 2:  $data = $this->_dict->t("Daylight"); break;
+                case 3:  $data = $this->_dict->t("Incandescense"); break;
+                case 4:  $data = $this->_dict->t("Flourescence"); break;
+                case 5:  $data = $this->_dict->t("Cloudy"); break;
+                case 6:  $data = $this->_dict->t("SpeedLight"); break;
+                default: $data = $this->_dict->t("Unknown") . ': ' . $data; break;
                 }
                 break;
 
             case '000b':
                 //Converter
                 switch ($data) {
-                case 0:  $data = _("None"); break;
-                case 1:  $data = _("Fisheye"); break;
-                default: $data = _("Unknown") . ': ' . $data; break;
+                case 0:  $data = $this->_dict->t("None"); break;
+                case 1:  $data = $this->_dict->t("Fisheye"); break;
+                default: $data = $this->_dict->t("Unknown") . ': ' . $data; break;
                 }
                 break;
             }
@@ -225,7 +225,7 @@ class Horde_Image_Exif_Parser_Nikon extends Horde_Image_Exif_Parser_Base
                 break;
             case '0088':
                 //AF Focus Position
-                $temp = _("Center");
+                $temp = $this->_dict->t("Center");
                 $data = bin2hex($data);
                 $data = str_replace('01', 'Top', $data);
                 $data = str_replace('02', 'Bottom', $data);
@@ -253,12 +253,12 @@ class Horde_Image_Exif_Parser_Nikon extends Horde_Image_Exif_Parser_Base
                 //Lens Type
                 $data = hexdec(substr($data, 0, 2));
                 switch ($data) {
-                case 0:  $data = _("AF non D"); break;
-                case 1:  $data = _("Manual"); break;
+                case 0:  $data = $this->_dict->t("AF non D"); break;
+                case 1:  $data = $this->_dict->t("Manual"); break;
                 case 2:  $data = 'AF-D or AF-S'; break;
                 case 6:  $data = 'AF-D G'; break;
                 case 10:  $data = 'AF-D VR'; break;
-                default: $data = _("Unknown") . ': ' . $data; break;
+                default: $data = $this->_dict->t("Unknown") . ': ' . $data; break;
                 }
                 break;
 
@@ -266,11 +266,11 @@ class Horde_Image_Exif_Parser_Nikon extends Horde_Image_Exif_Parser_Base
                 //Flash type
                 $data = hexdec(substr($data,0,2));
                 switch ($data) {
-                case 0:  $data = _("Did Not Fire"); break;
-                case 4:  $data = _("Unknown"); break;
-                case 7:  $data = _("External"); break;
-                case 9:  $data = _("On Camera"); break;
-                default: $data = _("Unknown") . ': ' . $data; break;
+                case 0:  $data = $this->_dict->t("Did Not Fire"); break;
+                case 4:  $data = $this->_dict->t("Unknown"); break;
+                case 7:  $data = $this->_dict->t("External"); break;
+                case 9:  $data = $this->_dict->t("On Camera"); break;
+                default: $data = $this->_dict->t("Unknown") . ': ' . $data; break;
                 }
                 break;
             }
index 4e633f5..83bc698 100644 (file)
@@ -115,7 +115,7 @@ class Horde_Image_Exif_Parser_Olympus extends Horde_Image_Exif_Parser_Base
                 case 1:  $data = 'SQ'; break;
                 case 2:  $data = 'HQ'; break;
                 case 3:  $data = 'SHQ'; break;
-                default: $data = _("Unknown") . ': ' . $data; break;
+                default: $data = $this->_dict->t("Unknown") . ': ' . $data; break;
                 }
                 break;
             case '0202':
@@ -123,7 +123,7 @@ class Horde_Image_Exif_Parser_Olympus extends Horde_Image_Exif_Parser_Base
                 switch ($data) {
                 case 0:  $data = 'Normal'; break;
                 case 1:  $data = 'Macro'; break;
-                default: $data = _("Unknown") . ': ' . $data; break;
+                default: $data = $this->_dict->t("Unknown") . ': ' . $data; break;
                 }
                 break;
             }
index b2167bf..a77b9b7 100644 (file)
@@ -79,25 +79,25 @@ class Horde_Image_Exif_Parser_Panasonic extends Horde_Image_Exif_Parser_Base
                 //AFMode
                 switch ($data) {
                 case 256:
-                    $data = _("9-area-focusing");
+                    $data = $this->_dict->t("9-area-focusing");
                     break;
                 case 16:
-                    $data = _("1-area-focusing");
+                    $data = $this->_dict->t("1-area-focusing");
                     break;
                 case 4096:
-                    $data = _("3-area-focusing (High speed)");
+                    $data = $this->_dict->t("3-area-focusing (High speed)");
                     break;
                 case 4112:
-                    $data = _("1-area-focusing (High speed)");
+                    $data = $this->_dict->t("1-area-focusing (High speed)");
                     break;
                 case 16:
-                    $data = _("1-area-focusing");
+                    $data = $this->_dict->t("1-area-focusing");
                     break;
                 case 1:
-                    $data = _("Spot-focusing");
+                    $data = $this->_dict->t("Spot-focusing");
                     break;
                 default:
-                    $data = sprintf(_("Unknown (%s)"), $data);
+                    $data = sprintf($this->_dict->t("Unknown (%s)"), $data);
                     break;
                 }
             }
@@ -137,19 +137,19 @@ class Horde_Image_Exif_Parser_Panasonic extends Horde_Image_Exif_Parser_Base
                 //Image Quality
                 switch ($data) {
                 case 2:
-                    $data = _("High");
+                    $data = $this->_dict->t("High");
                     break;
                 case 3:
-                    $data = _("Standard");
+                    $data = $this->_dict->t("Standard");
                     break;
                 case 6:
-                    $data = _("Very High");
+                    $data = $this->_dict->t("Very High");
                     break;
                 case 7:
-                    $data = _("RAW");
+                    $data = $this->_dict->t("RAW");
                     break;
                 default:
-                    $data = sprintf(_("Unknown (%s)"), $data);
+                    $data = sprintf($this->_dict->t("Unknown (%s)"), $data);
                     break;
                 }
                 break;
@@ -158,31 +158,31 @@ class Horde_Image_Exif_Parser_Panasonic extends Horde_Image_Exif_Parser_Base
                 //White Balance
                 switch ($data) {
                 case 1:
-                    $data = _("Auto");
+                    $data = $this->_dict->t("Auto");
                     break;
                 case 2:
-                    $data = _("Daylight");
+                    $data = $this->_dict->t("Daylight");
                     break;
                 case 3:
-                    $data = _("Cloudy");
+                    $data = $this->_dict->t("Cloudy");
                     break;
                 case 4:
-                    $data = _("Halogen");
+                    $data = $this->_dict->t("Halogen");
                     break;
                 case 5:
-                    $data = _("Manual");
+                    $data = $this->_dict->t("Manual");
                     break;
                 case 8:
-                    $data = _("Flash");
+                    $data = $this->_dict->t("Flash");
                     break;
                 case 10:
-                    $data = _("Black and White");
+                    $data = $this->_dict->t("Black and White");
                     break;
                 case 11:
-                    $data = _("Manual");
+                    $data = $this->_dict->t("Manual");
                     break;
                 default:
-                    $data = sprintf(_("Unknown(%s)"), $data);
+                    $data = sprintf($this->_dict->t("Unknown(%s)"), $data);
                     break;
                 }
                 break;
@@ -191,19 +191,19 @@ class Horde_Image_Exif_Parser_Panasonic extends Horde_Image_Exif_Parser_Base
                 //Focus Mode
                 switch ($data) {
                 case 1:
-                    $data = _("Auto");
+                    $data = $this->_dict->t("Auto");
                     break;
                 case 2:
-                    $data = _("Manual");
+                    $data = $this->_dict->t("Manual");
                     break;
                 case 4:
-                    $data = _("Auto, Focus button");
+                    $data = $this->_dict->t("Auto, Focus button");
                     break;
                 case 5:
-                    $data = _("Auto, Continuous");
+                    $data = $this->_dict->t("Auto, Continuous");
                     break;
                 default:
-                    $data = sprintf(_("Unknown(%s)"), $data);
+                    $data = sprintf($this->_dict->t("Unknown(%s)"), $data);
                     break;
                 }
                 break;
@@ -212,16 +212,16 @@ class Horde_Image_Exif_Parser_Panasonic extends Horde_Image_Exif_Parser_Base
                 //Image Stabilizer
                 switch ($data) {
                 case 2:
-                    $data = _("Mode 1");
+                    $data = $this->_dict->t("Mode 1");
                     break;
                 case 3:
-                    $data = _("Off");
+                    $data = $this->_dict->t("Off");
                     break;
                 case 4:
-                    $data = _("Mode 2");
+                    $data = $this->_dict->t("Mode 2");
                     break;
                 default:
-                    $data = sprintf(_("Unknown(%s)"), $data);
+                    $data = sprintf($this->_dict->t("Unknown(%s)"), $data);
                     break;
                 }
                 break;
@@ -230,13 +230,13 @@ class Horde_Image_Exif_Parser_Panasonic extends Horde_Image_Exif_Parser_Base
                 //Macro mode
                 switch ($data) {
                 case 1:
-                    $data = _("On");
+                    $data = $this->_dict->t("On");
                     break;
                 case 2:
-                    $data = _("Off");
+                    $data = $this->_dict->t("Off");
                     break;
                 default:
-                    $data = sprintf(_("Unknown(%s)"), $data);
+                    $data = sprintf($this->_dict->t("Unknown(%s)"), $data);
                     break;
                 }
                 break;
@@ -245,70 +245,70 @@ class Horde_Image_Exif_Parser_Panasonic extends Horde_Image_Exif_Parser_Base
                 //Shooting Mode
                 switch ($data) {
                 case 1:
-                    $data = _("Normal");
+                    $data = $this->_dict->t("Normal");
                     break;
                 case 2:
-                    $data = _("Portrait");
+                    $data = $this->_dict->t("Portrait");
                     break;
                 case 3:
-                    $data = _("Scenery");
+                    $data = $this->_dict->t("Scenery");
                     break;
                 case 4:
-                    $data = _("Sports");
+                    $data = $this->_dict->t("Sports");
                     break;
                 case 5:
-                    $data = _("Night Portrait");
+                    $data = $this->_dict->t("Night Portrait");
                     break;
                 case 6:
-                    $data = _("Program");
+                    $data = $this->_dict->t("Program");
                     break;
                 case 7:
-                    $data = _("Aperture Priority");
+                    $data = $this->_dict->t("Aperture Priority");
                     break;
                 case 8:
-                    $data = _("Shutter Priority");
+                    $data = $this->_dict->t("Shutter Priority");
                     break;
                 case 9:
-                    $data = _("Macro");
+                    $data = $this->_dict->t("Macro");
                     break;
                 case 11:
-                    $data = _("Manual");
+                    $data = $this->_dict->t("Manual");
                     break;
                 case 13:
-                    $data = _("Panning");
+                    $data = $this->_dict->t("Panning");
                     break;
                 case 14:
-                    $data = _("Simple");
+                    $data = $this->_dict->t("Simple");
                     break;
                 case 18:
-                    $data = _("Fireworks");
+                    $data = $this->_dict->t("Fireworks");
                     break;
                 case 19:
-                    $data = _("Party");
+                    $data = $this->_dict->t("Party");
                     break;
                 case 20:
-                    $data = _("Snow");
+                    $data = $this->_dict->t("Snow");
                     break;
                 case 21:
-                    $data = _("Night Scenery");
+                    $data = $this->_dict->t("Night Scenery");
                     break;
                 case 22:
-                    $data = _("Food");
+                    $data = $this->_dict->t("Food");
                     break;
                 case 23:
-                    $data = _("Baby");
+                    $data = $this->_dict->t("Baby");
                     break;
                 case 27:
-                    $data = _("High Sensitivity");
+                    $data = $this->_dict->t("High Sensitivity");
                     break;
                 case 29:
-                    $data = _("Underwater");
+                    $data = $this->_dict->t("Underwater");
                     break;
                 case 33:
-                    $data = _("Pet");
+                    $data = $this->_dict->t("Pet");
                     break;
                 default:
-                    $data = sprintf(_("Unknown(%s)"), $data);
+                    $data = sprintf($this->_dict->t("Unknown(%s)"), $data);
                     break;
                 }
                 break;
@@ -317,13 +317,13 @@ class Horde_Image_Exif_Parser_Panasonic extends Horde_Image_Exif_Parser_Base
                 //Audio
                 switch ($data) {
                 case 1:
-                    $data = _("Yes");
+                    $data = $this->_dict->t("Yes");
                     break;
                 case 2:
-                    $data = _("No");
+                    $data = $this->_dict->t("No");
                     break;
                 default:
-                    $data = sprintf(_("Unknown (%s)"), $data);
+                    $data = sprintf($this->_dict->t("Unknown (%s)"), $data);
                     break;
                 }
                 break;
@@ -342,22 +342,22 @@ class Horde_Image_Exif_Parser_Panasonic extends Horde_Image_Exif_Parser_Base
                 //Colour Effect
                 switch ($data) {
                 case 1:
-                    $data = _("Off");
+                    $data = $this->_dict->t("Off");
                     break;
                 case 2:
-                    $data = _("Warm");
+                    $data = $this->_dict->t("Warm");
                     break;
                 case 3:
-                    $data = _("Cool");
+                    $data = $this->_dict->t("Cool");
                     break;
                 case 4:
-                    $data = _("Black and White");
+                    $data = $this->_dict->t("Black and White");
                     break;
                 case 5:
-                    $data = _("Sepia");
+                    $data = $this->_dict->t("Sepia");
                     break;
                 default:
-                    $data = sprintf(_("Unknown (%s)"), $data);
+                    $data = sprintf($this->_dict->t("Unknown (%s)"), $data);
                     break;
                 }
                 break;
@@ -366,16 +366,16 @@ class Horde_Image_Exif_Parser_Panasonic extends Horde_Image_Exif_Parser_Base
                 //Burst Mode
                 switch ($data) {
                 case 0:
-                    $data = _("Off");
+                    $data = $this->_dict->t("Off");
                     break;
                 case 1:
-                    $data = _("Low/High Quality");
+                    $data = $this->_dict->t("Low/High Quality");
                     break;
                 case 2:
-                    $data = _("Infinite");
+                    $data = $this->_dict->t("Infinite");
                     break;
                 default:
-                    $data = sprintf(_("Unknown (%s)"), $data);
+                    $data = sprintf($this->_dict->t("Unknown (%s)"), $data);
                     break;
                 }
                 break;
@@ -384,16 +384,16 @@ class Horde_Image_Exif_Parser_Panasonic extends Horde_Image_Exif_Parser_Base
                 //Contrast
                 switch ($data) {
                 case 0:
-                    $data = _("Standard");
+                    $data = $this->_dict->t("Standard");
                     break;
                 case 1:
-                    $data = _("Low");
+                    $data = $this->_dict->t("Low");
                     break;
                 case 2:
-                    $data = _("High");
+                    $data = $this->_dict->t("High");
                     break;
                 default:
-                    $data = sprintf(_("Unknown (%s)"), $data);
+                    $data = sprintf($this->_dict->t("Unknown (%s)"), $data);
                     break;
                 }
                 break;
@@ -402,16 +402,16 @@ class Horde_Image_Exif_Parser_Panasonic extends Horde_Image_Exif_Parser_Base
                 //Noise Reduction
                 switch ($data) {
                 case 0:
-                    $data = _("Standard");
+                    $data = $this->_dict->t("Standard");
                     break;
                 case 1:
-                    $data = _("Low");
+                    $data = $this->_dict->t("Low");
                     break;
                 case 2:
-                    $data = _("High");
+                    $data = $this->_dict->t("High");
                     break;
                 default:
-                    $data = sprintf(_("Unknown (%s)"), $data);
+                    $data = sprintf($this->_dict->t("Unknown (%s)"), $data);
                     break;
                 }
                 break;
@@ -420,16 +420,16 @@ class Horde_Image_Exif_Parser_Panasonic extends Horde_Image_Exif_Parser_Base
                 //Self Timer
                 switch ($data) {
                 case 1:
-                    $data = _("Off");
+                    $data = $this->_dict->t("Off");
                     break;
                 case 2:
-                    $data = _("10s");
+                    $data = $this->_dict->t("10s");
                     break;
                 case 3:
-                    $data = _("2s");
+                    $data = $this->_dict->t("2s");
                     break;
                 default:
-                    $data = sprintf(_("Unknown (%s)"), $data);
+                    $data = sprintf($this->_dict->t("Unknown (%s)"), $data);
                     break;
                 }
                 break;
@@ -438,16 +438,16 @@ class Horde_Image_Exif_Parser_Panasonic extends Horde_Image_Exif_Parser_Base
                 //Rotation
                 switch ($data) {
                 case 1:
-                    $data = _("Horizontal (normal)");
+                    $data = $this->_dict->t("Horizontal (normal)");
                     break;
                 case 6:
-                    $data = _("Rotate 90 CW");
+                    $data = $this->_dict->t("Rotate 90 CW");
                     break;
                 case 8:
-                    $data = _("Rotate 270 CW");
+                    $data = $this->_dict->t("Rotate 270 CW");
                     break;
                 default:
-                    $data = sprintf(_("Unknown (%s)"), $data);
+                    $data = sprintf($this->_dict->t("Unknown (%s)"), $data);
                     break;
                 }
                 break;
@@ -456,13 +456,13 @@ class Horde_Image_Exif_Parser_Panasonic extends Horde_Image_Exif_Parser_Base
                 //Color Mode
                 switch ($data) {
                 case 0:
-                    $data = _("Normal");
+                    $data = $this->_dict->t("Normal");
                     break;
                 case 1:
-                    $data = _("Natural");
+                    $data = $this->_dict->t("Natural");
                     break;
                 default:
-                    $data = sprintf(_("Unknown (%s)"), $data);
+                    $data = sprintf($this->_dict->t("Unknown (%s)"), $data);
                     break;
                 }
                 break;
index 82ec86c..350568a 100644 (file)
@@ -95,15 +95,15 @@ class Horde_Image_Exif_Parser_Sanyo extends Horde_Image_Exif_Parser_Base
             switch ($tag) {
             case '0200':
                 //SpecialMode
-                $data = $data == 0 ? _("Normal") : _("Unknown") . ': ' . $data;
+                $data = $data == 0 ? $this->_dict->t("Normal") : $this->_dict->t("Unknown") . ': ' . $data;
                 break;
             case '0201':
                 //Quality
-                $data = $data == 2 ? _("High") : _("Unknown") . ': ' . $data;
+                $data = $data == 2 ? $this->_dict->t("High") : $this->_dict->t("Unknown") . ': ' . $data;
                 break;
             case '0202':
                 //Macro
-                $data = $data == 0 ? _("Normal") : _("Unknown") . ': ' . $data;
+                $data = $data == 0 ? $this->_dict->t("Normal") : $this->_dict->t("Unknown") . ': ' . $data;
                 break;
             }
             break;
index ced204f..10a85bc 100644 (file)
@@ -42,14 +42,28 @@ implements Horde_Itip_Event
     private $_vevent;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor.
      *
      * @param Horde_Icalendar_Vevent $vevent The iCalendar object that will be
      *                                       wrapped by this instance.
+     * @param Horde_Translation      $dict   A translation handler
+     *                                       implementing Horde_Translation.
      */
-    public function __construct(Horde_Icalendar_Vevent $vevent)
+    public function __construct(Horde_Icalendar_Vevent $vevent, $dict = null)
     {
         $this->_vevent = $vevent;
+        if ($dict) {
+            $this->_dict = $dict;
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Itip', dirname(__FILE__) . '/../../../../locale');
+        }
     }
 
     /**
@@ -89,7 +103,7 @@ implements Horde_Itip_Event
      */
     public function getSummary()
     {
-        return $this->_vevent->getAttributeDefault('SUMMARY', _("No summary available"));
+        return $this->_vevent->getAttributeDefault('SUMMARY', $this->_dict->t("No summary available"));
     }
 
     /**
index b777a94..411eccf 100644 (file)
@@ -46,7 +46,7 @@ extends Horde_Itip_Response_Type_Base
      */
     public function getShortSubject()
     {
-        return _("Accepted");
+        return $this->_dict->t("Accepted");
     }
 
     /**
@@ -59,7 +59,7 @@ extends Horde_Itip_Response_Type_Base
     public function getShortMessage($is_update = false)
     {
         return $is_update
-            ? _("has accepted the update to the following event")
-            : _("has accepted the invitation to the following event");
+            ? $this->_dict->t("has accepted the update to the following event")
+            : $this->_dict->t("has accepted the invitation to the following event");
     }
 }
\ No newline at end of file
index 3a30dc1..c38e975 100644 (file)
@@ -51,18 +51,33 @@ implements Horde_Itip_Response_Type
     private $_comment;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor.
      *
-     * @param Horde_Itip_Resource $resource The invited resource. 
-     * @param string              $comment  A comment for the subject line.
+     * @param Horde_Itip_Resource $resource  The invited resource. 
+     * @param string              $comment   A comment for the subject line.
+     * @param Horde_Translation   $dict      A translation handler
+     *                                       implementing Horde_Translation.
      */
     public function __construct(
         Horde_Itip_Resource $resource,
-        $comment = null
+        $comment = null,
+        $dict = null
     )
     {
         $this->_resource = $resource;
         $this->_comment  = $comment;
+        if ($dict) {
+            $this->_dict = $dict;
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Itip', dirname(__FILE__) . '/../../../../../locale');
+        }
     }
 
     /**
index aeaff4c..c716858 100644 (file)
@@ -46,7 +46,7 @@ extends Horde_Itip_Response_Type_Base
      */
     public function getShortSubject()
     {
-        return _("Declined");
+        return $this->_dict->t("Declined");
     }
 
     /**
@@ -59,7 +59,7 @@ extends Horde_Itip_Response_Type_Base
     public function getShortMessage($is_update = false)
     {
         return $is_update
-            ? _("has declined the update to the following event")
-            : _("has declined the invitation to the following event");
+            ? $this->_dict->t("has declined the update to the following event")
+            : $this->_dict->t("has declined the invitation to the following event");
     }
 }
\ No newline at end of file
index 7f79515..1ae146c 100644 (file)
@@ -46,7 +46,7 @@ extends Horde_Itip_Response_Type_Base
      */
     public function getShortSubject()
     {
-        return _("Tentative");
+        return $this->_dict->t("Tentative");
     }
 
     /**
@@ -59,7 +59,7 @@ extends Horde_Itip_Response_Type_Base
     public function getShortMessage($is_update = false)
     {
         return $is_update
-            ? _("has tentatively accepted the update to the following event")
-            : _("has tentatively accepted the invitation to the following event");
+            ? $this->_dict->t("has tentatively accepted the update to the following event")
+            : $this->_dict->t("has tentatively accepted the invitation to the following event");
     }
 }
\ No newline at end of file
index 14982b9..15b5073 100644 (file)
@@ -719,6 +719,7 @@ class Kolab {
      */
     function getAppConsts($app)
     {
+        $dict = new Horde_Translation_Gettext('Horde_Kolab', dirname(__FILE__) . '/locale');
         switch ($app) {
         case 'mnemo':
             return array(
@@ -727,7 +728,7 @@ class Kolab {
                 'allowed_types'         => array(
                     'note',
                 ),
-                'default_folder_name'   => _("Notes"),
+                'default_folder_name'   => $dict->t("Notes"),
                 'application'           => $app,
             );
 
@@ -738,7 +739,7 @@ class Kolab {
                 'allowed_types'         => array(
                     'event',
                 ),
-                'default_folder_name'   => _("Calendar"),
+                'default_folder_name'   => $dict->t("Calendar"),
                 'application'           => $app,
             );
 
@@ -750,7 +751,7 @@ class Kolab {
                     'contact',
                     'distribution-list',
                 ),
-                'default_folder_name'   => _("Contacts"),
+                'default_folder_name'   => $dict->t("Contacts"),
                 'application'           => $app,
             );
 
@@ -761,7 +762,7 @@ class Kolab {
                 'allowed_types'         => array(
                     'task',
                 ),
-                'default_folder_name'   => _("Tasks"),
+                'default_folder_name'   => $dict->t("Tasks"),
                 'application'           => $app,
             );
 
@@ -772,12 +773,12 @@ class Kolab {
                 'allowed_types'         => array(
                     'h-prefs',
                 ),
-                'default_folder_name'   => _("Preferences"),
+                'default_folder_name'   => $dict->t("Preferences"),
                 'application'           => $app,
             );
 
         default:
-            return PEAR::raiseError(sprintf(_("The Horde/Kolab integration engine does not support \"%s\""), $app));
+            return PEAR::raiseError(sprintf($dict->t("The Horde/Kolab integration engine does not support \"%s\""), $app));
         }
     }
 
index 36aef80..1efece8 100644 (file)
@@ -388,7 +388,7 @@ class Horde_Kolab_Filter_Content extends Horde_Kolab_Filter_Base
         if (isset($conf['kolab']['filter']['unauthenticated_from_insert'])) {
             $fmt = $conf['kolab']['filter']['unauthenticated_from_insert'];
         } else {
-            $fmt = _("(UNTRUSTED, sender <%s> is not authenticated)");
+            $fmt = '(UNTRUSTED, sender <%s> is not authenticated)';
         }
 
         $adrs = imap_rfc822_parse_adrlist($fromhdr, $domains[0]);
index f975739..fd52117 100644 (file)
@@ -54,7 +54,7 @@ abstract class Horde_Kolab_Format
             $driver = call_user_func(array($class, 'factory'), $object_type,
                                      $params);
         } else {
-            throw new Horde_Kolab_Format_Exception(sprintf(_("Failed to load Kolab Format driver %s"),
+            throw new Horde_Kolab_Format_Exception(sprintf('Failed to load Kolab Format driver %s',
                                               $format_type));
         }
 
index b1abcc5..2301b7d 100644 (file)
@@ -281,12 +281,25 @@ class Horde_Kolab_Format_Xml
     );
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor
      *
      * @param array $params Any additional options
      */
     public function __construct($params = null)
     {
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Kolab_Format', dirname(__FILE__) . '/../../../../locale');
+        }
+
         if (is_array($params) && isset($params['version'])) {
             $this->_version = $params['version'];
         } else {
@@ -372,7 +385,7 @@ class Horde_Kolab_Format_Xml
         if (class_exists($class)) {
             $driver = new $class($params);
         } else {
-            throw new Horde_Kolab_Format_Exception(sprintf(_("Failed to load Kolab XML driver %s"),
+            throw new Horde_Kolab_Format_Exception(sprintf('Failed to load Kolab XML driver %s',
                                               $object_type));
         }
 
@@ -440,7 +453,7 @@ class Horde_Kolab_Format_Xml
             $this->_parseXml($xmltext);
         }
         if (!$this->_xmldoc->documentElement->hasChildNodes()) {
-            throw new Horde_Kolab_Format_Exception(_("No or unreadable content in Kolab XML object"));
+            throw new Horde_Kolab_Format_Exception($this->_dict->t("No or unreadable content in Kolab XML object"));
         }
 
         // fresh object data
@@ -455,7 +468,7 @@ class Horde_Kolab_Format_Xml
 
         // uid is vital
         if (!isset($object['uid'])) {
-            throw new Horde_Kolab_Format_Exception(_("UID not found in Kolab XML object"));
+            throw new Horde_Kolab_Format_Exception($this->_dict->t("UID not found in Kolab XML object"));
         }
 
         return $object;
@@ -546,7 +559,7 @@ class Horde_Kolab_Format_Xml
                 return null;
             } elseif ($params['value'] == self::VALUE_NOT_EMPTY) {
                 // May not be empty. Return an error
-                throw new Horde_Kolab_Format_Exception(sprintf(_("Data value for %s is empty in Kolab XML object!"),
+                throw new Horde_Kolab_Format_Exception(sprintf($this->_dict->t("Data value for %s is empty in Kolab XML object!"),
                                                   $name));
             } elseif ($params['value'] == self::VALUE_DEFAULT) {
                 // Return the default
@@ -595,7 +608,7 @@ class Horde_Kolab_Format_Xml
 
         @$this->_xmldoc->loadXML($xmltext);
         if (empty($this->_xmldoc->documentElement)) {
-            throw new Horde_Kolab_Format_Exception(_("No or unreadable content in Kolab XML object"));
+            throw new Horde_Kolab_Format_Exception($this->_dict->t("No or unreadable content in Kolab XML object"));
         }
 
     }
@@ -711,7 +724,7 @@ class Horde_Kolab_Format_Xml
                 $value = $params['default'];
             } elseif ($params['value'] == self::VALUE_NOT_EMPTY) {
                 // May not be empty. Return an error
-                throw new Horde_Kolab_Format_Exception(sprintf(_("Data value for %s is empty in Kolab XML object!"),
+                throw new Horde_Kolab_Format_Exception(sprintf($this->_dict->t("Data value for %s is empty in Kolab XML object!"),
                                                   $name));
             } elseif ($params['value'] == self::VALUE_MAYBE_MISSING) {
                 /**
index c9fa356..03fb217 100644 (file)
@@ -54,11 +54,19 @@ class Horde_Kolab_FreeBusy_Driver_Base
     protected $logger;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor.
      *
      * @param array       $params        Any additional options
      */
-    public function __construct($callee = null, $callee_part = null, $logger = null)
+    public function __construct($callee = null, $callee_part = null,
+                                $logger = null, $params = array())
     {
         list($this->user, $this->pass) = $this->getCredentials();
 
@@ -74,6 +82,12 @@ class Horde_Kolab_FreeBusy_Driver_Base
         }
 
         $this->logger = $logger;
+
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Kolab_FreeBusy', dirname(__FILE__) . '/../../../../../locale');
+        }
     }
 
     /**
@@ -175,11 +189,11 @@ class Horde_Kolab_FreeBusy_Driver_Base
 
         if (empty($this->user)) {
             header('WWW-Authenticate: Basic realm="Kolab Freebusy"');
-            return PEAR::raiseError(_("Please authenticate!"));
+            return PEAR::raiseError($this->_dict->t("Please authenticate!"));
         }
 
         if (!$this->_authenticated) {
-            return PEAR::raiseError(sprintf(_("Invalid authentication for user %s!"),
+            return PEAR::raiseError(sprintf($this->_dict->t("Invalid authentication for user %s!"),
                                             $this->user));
         }
         return true;
index 8dff13f..509afc4 100644 (file)
@@ -215,7 +215,7 @@ class Horde_Kolab_FreeBusy_Driver_Freebusy_Base extends Horde_Kolab_FreeBusy_Dri
             }
 
             if (empty($access->owner)) {
-                $message = sprintf(_("No such account %s!"),
+                $message = sprintf($this->_dict->t("No such account %s!"),
                                    htmlentities($access->req_owner));
                 $error = array('type' => FREEBUSY_ERROR_NOTFOUND,
                                'error' => PEAR::raiseError($message));
@@ -292,7 +292,7 @@ class Horde_Kolab_FreeBusy_Driver_Freebusy_Base extends Horde_Kolab_FreeBusy_Dri
                 $redirect = 'https://' . urlencode($this->user) . ':' . urlencode($GLOBALS['registry']->getAuthCredential('password'))
                     . '@' . $this->freebusyserver . $path;
                 if (!@readfile($redirect)) {
-                    $message = sprintf(_("Unable to read free/busy information from %s"),
+                    $message = sprintf($this->_dict->t("Unable to read free/busy information from %s"),
                                        'https://' . urlencode($this->user) . ':XXX'
                                        . '@' . $this->freebusyserver . $_SERVER['REQUEST_URI']);
                     return PEAR::raiseError($message);
index bb4162d..998fd67 100644 (file)
@@ -79,7 +79,7 @@ class Horde_Kolab_FreeBusy_Driver_Freebusy_Kolab extends Horde_Kolab_FreeBusy_Dr
         $req_folder = Horde_String::convertCharset($req_folder, 'UTF-8', 'UTF7-IMAP');
         $folder = explode('/', $req_folder);
         if (count($folder) < 2) {
-            return PEAR::raiseError(sprintf(_("No such folder %s"), $req_folder));
+            return PEAR::raiseError(sprintf($this->_dict->t("No such folder %s"), $req_folder));
         }
 
         $folder[0] = strtolower($folder[0]);
@@ -194,7 +194,7 @@ class Horde_Kolab_FreeBusy_Driver_Freebusy_Kolab extends Horde_Kolab_FreeBusy_Dr
                 }
             }
         } else {
-            return PEAR::raiseError(_("Unable to determine owner of the free/busy data!"));
+            return PEAR::raiseError($this->_dict->t("Unable to determine owner of the free/busy data!"));
         }
 
         /* Mangle the folder request into an IMAP folder name */
index 03a8841..a94a24b 100644 (file)
@@ -91,10 +91,23 @@ class Horde_Kolab_FreeBusy_Imap {
     var $_xacl;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Initialize the free/busy IMAP handler.
      */
-    public function __construct()
+    public function __construct($params = array())
     {
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Kolab_FreeBusy', dirname(__FILE__) . '/../../../../locale');
+        }
+
         //@todo: Make Kolab_FreeBusy session-less again and ensure we get the
         //driver information as well as the login credentials here.
         $params = array('driver'   => 'Mock',
@@ -125,14 +138,14 @@ class Horde_Kolab_FreeBusy_Imap {
             return $this->_data;
         }
         if (!$this->_folder->exists()) {
-            return PEAR::raiseError(sprintf(_("Folder %s does not exist!"), $folder));
+            return PEAR::raiseError(sprintf($this->_dict->t("Folder %s does not exist!"), $folder));
         }
         $type = $this->_folder->getType();
         if (is_a($type, 'PEAR_Error')) {
             return $type;
         }
         if ($type != 'event') {
-            return PEAR::raiseError(sprintf(_("Folder %s has type \"%s\" not \"event\"!"),
+            return PEAR::raiseError(sprintf($this->_dict->t("Folder %s has type \"%s\" not \"event\"!"),
                                             $folder, $type));
         }
     }
index 2ffa511..e028c3d 100644 (file)
@@ -14,7 +14,14 @@ class Horde_Kolab_FreeBusy_Report {
 
     var $_errors = array();
 
-    function Horde_Kolab_FreeBusy_Report()
+    /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    function Horde_Kolab_FreeBusy_Report($params = array())
     {
         if (PHP_SAPI == 'cli') {
             $this->_break = "\n";
@@ -25,24 +32,30 @@ class Horde_Kolab_FreeBusy_Report {
             /** Don't report notices */
             error_reporting(E_ALL & ~E_NOTICE);
         }
+
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Kolab_FreeBusy', dirname(__FILE__) . '/../../../../locale');
+        }
     }
 
     function start()
     {
-        echo _("Starting to regenerate the free/busy cache...");
+        echo $this->_dict->t("Starting to regenerate the free/busy cache...");
         $this->linebreak(2);
     }
 
     function success($calendar)
     {
-        echo sprintf(_("Successfully regenerated calendar \"%s\"!"),
+        echo sprintf($this->_dict->t("Successfully regenerated calendar \"%s\"!"),
                      $calendar);
         $this->linebreak(1);
     }
 
     function failure($calendar, $error)
     {
-        $this->_errors[] = sprintf(_("Failed regenerating calendar %s: %s"),
+        $this->_errors[] = sprintf($this->_dict->t("Failed regenerating calendar %s: %s"),
                                    $calendar, $error->getMessage());
     }
 
@@ -50,7 +63,7 @@ class Horde_Kolab_FreeBusy_Report {
     {
         if (!empty($this->_errors)) {
             $this->linebreak(1);
-            echo _("Errors:");
+            echo $this->_dict->t("Errors:");
             $this->linebreak(1);
             foreach ($this->_errors as $error) {
                 echo $error;
@@ -58,7 +71,7 @@ class Horde_Kolab_FreeBusy_Report {
             return false;
         } else {
             $this->linebreak(1);
-            echo _("Successfully regenerated all calendar caches!");
+            echo $this->_dict->t("Successfully regenerated all calendar caches!");
             $this->linebreak(1);
             return true;
         }
index 4930689..112ba67 100644 (file)
@@ -27,13 +27,25 @@ class Horde_Kolab_FreeBusy_View {
     var $_data;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor.
      *
      * @param array $data The data to display
      */
-    function Horde_Kolab_FreeBusy_View(&$data)
+    function Horde_Kolab_FreeBusy_View(&$data, $params = array())
     {
         $this->_data = $data;
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Kolab_FreeBusy', dirname(__FILE__) . '/../../../../locale');
+        }
     }
 
     /**
@@ -203,9 +215,9 @@ class Horde_Kolab_FreeBusy_View_error extends Horde_Kolab_FreeBusy_View {
         } else {
             $url = '/';
         }
-        $message = sprintf(_("The requested URL %s was not found on this server."), $url);
+        $message = sprintf($this->_dict->t("The requested URL %s was not found on this server."), $url);
 
-        $this->_errorPage($error, $headers, _("404 Not Found"), _("Not found"), $message);
+        $this->_errorPage($error, $headers, $this->_dict->t("404 Not Found"), $this->_dict->t("Not found"), $message);
     }
 
     /**
@@ -226,8 +238,8 @@ class Horde_Kolab_FreeBusy_View_error extends Horde_Kolab_FreeBusy_View {
         $headers = array('WWW-Authenticate: Basic realm="freebusy-' . $email_domain . '"',
                          'HTTP/1.0 401 Unauthorized');
 
-        $this->_errorPage($error, $headers, _("401 Unauthorized"), _("Unauthorized"),
-                  _("You are not authorized to access the requested URL."));
+        $this->_errorPage($error, $headers, $this->_dict->t("401 Unauthorized"), $this->_dict->t("Unauthorized"),
+                  $this->_dict->t("You are not authorized to access the requested URL."));
     }
 
     /**
@@ -243,7 +255,7 @@ class Horde_Kolab_FreeBusy_View_error extends Horde_Kolab_FreeBusy_View {
         } else {
             $url = '/';
         }
-        $this->_errorPage($error, $headers, _("500 Server Error"), _("Error"),
+        $this->_errorPage($error, $headers, $this->_dict->t("500 Server Error"), $this->_dict->t("Error"),
                   htmlentities($$url));
     }
 
index 0e8837c..0567b93 100644 (file)
@@ -54,6 +54,24 @@ define('RM_ITIP_TENTATIVE',                 3);
  */
 class Kolab_Resource
 {
+    /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
+     * Constructor.
+     */
+    public function __construct($dict = null)
+    {
+        if ($dict) {
+            $this->_dict = $dict;
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Kolab_Resource', dirname(__FILE__) . '/../../../locale');
+        }
+    }
 
     /**
      * Returns the resource policy applying for the given sender
@@ -533,13 +551,13 @@ class Kolab_Resource
             Horde::logMessage(sprintf('Removing event %s', $uid), 'INFO');
 
             if (is_a($imap_error, 'PEAR_Error')) {
-                $body = sprintf(_("Unable to access %s's calendar:"), $resource) . "\n\n" . $summary;
-                $subject = sprintf(_("Error processing \"%s\""), $summary);
+                $body = sprintf($this->_dict->t("Unable to access %s's calendar:"), $resource) . "\n\n" . $summary;
+                $subject = sprintf($this->_dict->t("Error processing \"%s\""), $summary);
             } else if (!$data->objectUidExists($uid)) {
                 Horde::logMessage(sprintf('Canceled event %s is not present in %s\'s calendar',
                                           $uid, $resource), 'WARNING');
-                $body = sprintf(_("The following event that was canceled is not present in %s's calendar:"), $resource) . "\n\n" . $summary;
-                $subject = sprintf(_("Error processing \"%s\""), $summary);
+                $body = sprintf($this->_dict->t("The following event that was canceled is not present in %s's calendar:"), $resource) . "\n\n" . $summary;
+                $subject = sprintf($this->_dict->t("Error processing \"%s\""), $summary);
             } else {
                 /**
                  * Delete the messages from IMAP
@@ -554,8 +572,8 @@ class Kolab_Resource
                                               $uid, $result->getMessage()), 'DEBUG');
                 }
 
-                $body = _("The following event has been successfully removed:") . "\n\n" . $summary;
-                $subject = sprintf(_("%s has been cancelled"), $summary);
+                $body = $this->_dict->t("The following event has been successfully removed:") . "\n\n" . $summary;
+                $subject = sprintf($this->_dict->t("%s has been cancelled"), $summary);
             }
 
             Horde::logMessage(sprintf('Sending confirmation of cancelation to %s', $organiser), 'WARNING');
index b884f08..22d7579 100644 (file)
@@ -90,13 +90,24 @@ class Horde_Kolab_Storage_Data
     private $_cache_cyrus_optimize = true;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Creates a Kolab Folder Data representation.
      *
      * @param string $type         Type of the folder.
      * @param string $object_type  Type of the objects we want to read.
      * @param int    $data_version Format version of the object data.
+     * @param array $params  Hash with configuration data. Possible values:
+     *                       - 'translation': A translation handler
+     *                                        implementing Horde_Translation.
      */
-    public function __construct($type, $object_type = null, $data_version = 1)
+    public function __construct($type, $object_type = null, $data_version = 1,
+                                $params = array())
     {
         $this->_type = $type;
         if (!empty($object_type)) {
@@ -111,6 +122,12 @@ class Horde_Kolab_Storage_Data
         } else {
             $this->_type_key = '';
         }
+
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Block', dirname(__FILE__) . '/../../../locale');
+        }
     }
 
     /**
@@ -295,14 +312,14 @@ class Horde_Kolab_Storage_Data
         if ($old_object_id != null) {
             // check if object really exists
             if (!$this->objectUidExists($old_object_id)) {
-                throw new Horde_Kolab_Storage_Exception(sprintf(_("Old object %s does not exist."),
+                throw new Horde_Kolab_Storage_Exception(sprintf($this->_dict->t("Old object %s does not exist."),
                                                                 $old_object_id));
             }
 
             // get the storage ID
             $id = $this->getStorageId($old_object_id);
             if ($id === false) {
-                throw new Horde_Kolab_Storage_Exception(sprintf(_("Old object %s does not map to a uid."),
+                throw new Horde_Kolab_Storage_Exception(sprintf($this->_dict->t("Old object %s does not map to a uid."),
                                                                 $old_object_id));
             }
 
@@ -610,7 +627,7 @@ class Horde_Kolab_Storage_Data
         $this->_cache->load($this->_cache_key, $this->_data_version);
 
         if (!isset($this->_cache->objects[$object_id])) {
-            throw new Horde_Kolab_Storage_Exception(sprintf(_("Kolab cache: Object uid %s does not exist in the cache!"), $object_id));
+            throw new Horde_Kolab_Storage_Exception(sprintf($this->_dict->t("Kolab cache: Object uid %s does not exist in the cache!"), $object_id));
         }
         return $this->_cache->objects[$object_id];
     }
index 0834eca..d8b259d 100644 (file)
@@ -251,16 +251,23 @@ class Horde_LoginTasks
     /**
      * Labels for the class constants.
      *
+     * @param Horde_Translation $dict  A translation handler implementing
+     *                                 Horde_Translation.
+     *
      * @return array  A mapping of constant to gettext string.
      */
-    static public function getLabels()
+    static public function getLabels($dict = null)
     {
+        if (!$dict) {
+            $dict = new Horde_Translation_Gettext('Horde_LoginTasks', dirname(__FILE__) . '/../../locale');
+        }
+
         return array(
-            self::YEARLY => _("Yearly"),
-            self::MONTHLY => _("Monthly"),
-            self::WEEKLY => _("Weekly"),
-            self::DAILY => _("Daily"),
-            self::EVERY => _("Every Login")
+            self::YEARLY => $dict->t("Yearly"),
+            self::MONTHLY => $dict->t("Monthly"),
+            self::WEEKLY => $dict->t("Weekly"),
+            self::DAILY => $dict->t("Daily"),
+            self::EVERY => $dict->t("Every Login")
         );
     }
 
index 3b40b55..23ae853 100644 (file)
@@ -499,20 +499,26 @@ class Horde_Mime_Headers implements Serializable
     /**
      * Returns the list of valid mailing list headers.
      *
+     * @param Horde_Translation $dict  A translation handler implementing
+     *                                 Horde_Translation.
+     *
      * @return array  The list of valid mailing list headers.
      */
-    static public function listHeaders()
+    static public function listHeaders($dict = null)
     {
+        if (!$dict) {
+            $dict = new Horde_Translation_Gettext('Horde_Mime', dirname(__FILE__) . '/../../../locale');
+        }
         return array(
             /* RFC 2369 */
-            'list-help'         =>  _("List-Help"),
-            'list-unsubscribe'  =>  _("List-Unsubscribe"),
-            'list-subscribe'    =>  _("List-Subscribe"),
-            'list-owner'        =>  _("List-Owner"),
-            'list-post'         =>  _("List-Post"),
-            'list-archive'      =>  _("List-Archive"),
+            'list-help'         =>  $dict->t("List-Help"),
+            'list-unsubscribe'  =>  $dict->t("List-Unsubscribe"),
+            'list-subscribe'    =>  $dict->t("List-Subscribe"),
+            'list-owner'        =>  $dict->t("List-Owner"),
+            'list-post'         =>  $dict->t("List-Post"),
+            'list-archive'      =>  $dict->t("List-Archive"),
             /* RFC 2919 */
-            'list-id'           =>  _("List-Id")
+            'list-id'           =>  $dict->t("List-Id")
         );
     }
 
index 4d624ad..da727ab 100644 (file)
@@ -81,6 +81,13 @@ class Horde_Mime_Mail
     protected $_mailer_params = array();
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor.
      *
      * @param array $params  A hash with basic message information. 'charset'
@@ -90,8 +97,14 @@ class Horde_Mime_Mail
      *
      * @throws Horde_Mime_Exception
      */
-    public function __construct($params = array())
+    public function __construct($params = array(), $dict = null)
     {
+        if ($dict) {
+            $this->_dict = $dict;
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Mime', dirname(__FILE__) . '/../../../locale');
+        }
+
         /* Set SERVER_NAME. */
         if (!isset($_SERVER['SERVER_NAME'])) {
             $_SERVER['SERVER_NAME'] = php_uname('n');
@@ -388,7 +401,7 @@ class Horde_Mime_Mail
 
         foreach (Horde_Mime_Address::bareAddress(implode(', ', $addrlist), null, true) as $val) {
             if (Horde_Mime::is8bit($val)) {
-                throw new Horde_Mime_Exception(sprintf(_("Invalid character in e-mail address: %s."), $val));
+                throw new Horde_Mime_Exception(sprintf($this->_dict->t("Invalid character in e-mail address: %s."), $val));
             }
         }
 
@@ -442,9 +455,9 @@ class Horde_Mime_Mail
             $body = new Horde_Mime_Part();
             if (!empty($this->_body) && !empty($this->_htmlBody)) {
                 $body->setType('multipart/alternative');
-                $this->_body->setDescription(_("Plaintext Version of Message"));
+                $this->_body->setDescription($this->_dict->t("Plaintext Version of Message"));
                 $body->addPart($this->_body);
-                $this->_htmlBody->setDescription(_("HTML Version of Message"));
+                $this->_htmlBody->setDescription($this->_dict->t("HTML Version of Message"));
                 $body->addPart($this->_htmlBody);
             } elseif (!empty($this->_htmlBody)) {
                 $body = $this->_htmlBody;
index 46b6199..dfc0d48 100644 (file)
@@ -30,12 +30,26 @@ class Horde_Mime_Mdn
     protected $_msgtext = false;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor.
      *
      * @param Horde_Mime_Headers $mime_headers  A headers object.
+     * @param Horde_Translation $dict           A translation handler
+     *                                          implementing Horde_Translation.
      */
-    public function __construct(Horde_Mime_Headers $headers)
+    public function __construct(Horde_Mime_Headers $headers, $dict = null)
     {
+        if ($dict) {
+            $this->_dict = $dict;
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Mime', dirname(__FILE__) . '/../../../locale');
+        }
         $this->_headers = $headers;
     }
 
@@ -185,7 +199,7 @@ class Horde_Mime_Mdn
             $msg_headers->addHeader('From', $opts['from_addr']);
         }
         $msg_headers->addHeader('To', $this->getMdnReturnAddr());
-        $msg_headers->addHeader('Subject', _("Disposition Notification"));
+        $msg_headers->addHeader('Subject', $this->_dict->t("Disposition Notification"));
 
         /* MDNs are a subtype of 'multipart/report'. */
         $msg = new Horde_Mime_Part();
@@ -196,7 +210,7 @@ class Horde_Mime_Mdn
         $part_one = new Horde_Mime_Part('text/plain');
         $part_one->setCharset($opts['charset']);
         if ($type == 'displayed') {
-            $contents = sprintf(_("The message sent on %s to %s with subject \"%s\" has been displayed.\n\nThis is no guarantee that the message has been read or understood."), $this->_headers->getValue('Date'), $this->_headers->getValue('To'), $this->_headers->getValue('Subject'));
+            $contents = sprintf($this->_dict->t("The message sent on %s to %s with subject \"%s\" has been displayed.\n\nThis is no guarantee that the message has been read or understood."), $this->_headers->getValue('Date'), $this->_headers->getValue('To'), $this->_headers->getValue('Subject'));
             $flowed = new Horde_Text_Flowed($contents, $opts['charset']);
             $flowed->setDelSp(true);
             $part_one->setContentTypeParameter('format', 'flowed');
index c55ab7e..e7c4ba5 100644 (file)
@@ -63,24 +63,39 @@ class Horde_Mime_Viewer_Base
     );
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor.
      *
      * @param Horde_Mime_Part $mime_part  The object with the data to be
      *                                    rendered.
-     * @param array $conf                 Configuration:
-     * <pre>
-     * 'temp_file' - (callback) A callback function that returns a temporary
-     *               filename.  Is passed one parameter: a prefix string.
-     *                DEFAULT: Uses Horde_Util::getTempFile().
-     * 'text_filter' - (callback) A callback function used to filter text.
-     *                 Is called the same as Horde_Text_Filter::filter().
-     *                 DEFAULT: Uses Horde_Text_Filter::filter().
-     * </pre>
+     * @param array $conf
+     *     Configuration:
+     *     - 'temp_file': (callback) A callback function that returns a
+     *                    temporary filename.  Is passed one parameter: a
+     *                     prefix string. DEFAULT: Uses
+     *                     Horde_Util::getTempFile().
+     *     - 'text_filter': (callback) A callback function used to filter text.
+     *                      Is called the same as Horde_Text_Filter::filter().
+     *                      DEFAULT: Uses Horde_Text_Filter::filter().
+     *     - 'translation': (object) A translation handler implementing
+     *                      Horde_Translation.
      *
      * @throws InvalidArgumentException
      */
     public function __construct(Horde_Mime_Part $part, array $conf = array())
     {
+        if (isset($conf['translation'])) {
+            $this->_dict = $conf['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Mime_Viewer', dirname(__FILE__) . '/../../../../locale');
+        }
+
         foreach ($this->_required as $val) {
             if (!isset($conf[$val])) {
                 throw new InvalidArgumentException(__CLASS__ . ': Missing configuration value (' . $val . ')');
index d082548..7ccf82a 100644 (file)
@@ -73,7 +73,7 @@ class Horde_Mime_Viewer_Msword extends Horde_Mime_Viewer_Base
             $data = file_get_contents($tmp_out);
             $type = 'text/html';
         } else {
-            $data = _("Unable to translate this Word document");
+            $data = $this->_dict->t("Unable to translate this Word document");
             $type = 'text/plain';
         }
 
index bc7ba4e..e221ac5 100644 (file)
@@ -75,36 +75,36 @@ class Horde_Mime_Viewer_Rar extends Horde_Mime_Viewer_Base
 
         $name = $this->_mimepart->getName(true);
         if (empty($name)) {
-            $name = _("unnamed");
+            $name = $this->_dict->t("unnamed");
         }
 
         $monospace = $this->getConfigParam('monospace');
 
         $text = '<table><tr><td align="left"><span ' .
             ($monospace ? 'class="' . $monospace . '">' : 'style="font-family:monospace">') .
-            $this->_textFilter(_("Archive Name") . ':  ' . $name, 'space2html', array(
+            $this->_textFilter($this->_dict->t("Archive Name") . ':  ' . $name, 'space2html', array(
                 'charset' => $charset,
                 'encode' => true,
                 'encode_all' => true
             )) . "\n" .
-            $this->_textFilter(_("Archive File Size") . ': ' . strlen($contents) . ' bytes', 'space2html', array(
+            $this->_textFilter($this->_dict->t("Archive File Size") . ': ' . strlen($contents) . ' bytes', 'space2html', array(
                 'charset' => $charset,
                 'encode' => true,
                 'encode_all' => true
             )) . "\n" .
-            $this->_textFilter(sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount), 'space2html', array(
+            $this->_textFilter(sprintf($this->_dict->n("File Count: %d file", "File Count: %d files", $fileCount), $fileCount), 'space2html', array(
                 'charset' => $charset,
                 'encode' => true,
                 'encode_all' => true
             )) .
             "\n\n" .
             $this->_textFilter(
-                Horde_String::pad(_("File Name"), 50, ' ', STR_PAD_RIGHT) .
-                Horde_String::pad(_("Attributes"), 10, ' ', STR_PAD_LEFT) .
-                Horde_String::pad(_("Size"), 10, ' ', STR_PAD_LEFT) .
-                Horde_String::pad(_("Modified Date"), 19, ' ', STR_PAD_LEFT) .
-                Horde_String::pad(_("Method"), 10, ' ', STR_PAD_LEFT) .
-                Horde_String::pad(_("Ratio"), 10, ' ', STR_PAD_LEFT),
+                Horde_String::pad($this->_dict->t("File Name"), 50, ' ', STR_PAD_RIGHT) .
+                Horde_String::pad($this->_dict->t("Attributes"), 10, ' ', STR_PAD_LEFT) .
+                Horde_String::pad($this->_dict->t("Size"), 10, ' ', STR_PAD_LEFT) .
+                Horde_String::pad($this->_dict->t("Modified Date"), 19, ' ', STR_PAD_LEFT) .
+                Horde_String::pad($this->_dict->t("Method"), 10, ' ', STR_PAD_LEFT) .
+                Horde_String::pad($this->_dict->t("Ratio"), 10, ' ', STR_PAD_LEFT),
                 'space2html',
                 array(
                     'charset' => $charset,
index 4e96236..03f29b5 100644 (file)
@@ -63,13 +63,13 @@ class Horde_Mime_Viewer_Rfc822 extends Horde_Mime_Viewer_Base
         $headers = Horde_Mime_Headers::parseHeaders($text);
 
         $header_array = array(
-            'date' => _("Date"),
-            'from' => _("From"),
-            'to' => _("To"),
-            'cc' => _("Cc"),
-            'bcc' => _("Bcc"),
-            'reply-to' => _("Reply-To"),
-            'subject' => _("Subject")
+            'date' => $this->_dict->t("Date"),
+            'from' => $this->_dict->t("From"),
+            'to' => $this->_dict->t("To"),
+            'cc' => $this->_dict->t("Cc"),
+            'bcc' => $this->_dict->t("Bcc"),
+            'reply-to' => $this->_dict->t("Reply-To"),
+            'subject' => $this->_dict->t("Subject")
         );
         $header_output = array();
 
index f5d5e0c..1337fbf 100644 (file)
@@ -72,7 +72,7 @@ class Horde_Mime_Viewer_Rtf extends Horde_Mime_Viewer_Base
 
         $data = file_exists($tmp_output)
             ? file_get_contents($tmp_output)
-            : _("Unable to translate this RTF document");
+            : $this->_dict->t("Unable to translate this RTF document");
 
         return $this->_renderReturn(
             $data,
index 49db5ea..b5a1042 100644 (file)
@@ -93,34 +93,34 @@ class Horde_Mime_Viewer_Tgz extends Horde_Mime_Viewer_Base
 
         $name = $this->_mimepart->getName(true);
         if (empty($name)) {
-            $name = _("unnamed");
+            $name = $this->_dict->t("unnamed");
         }
 
         $monospace = $this->getConfigParam('monospace');
 
         $text = '<table><tr><td align="left"><span ' .
             ($monospace ? 'class="' . $monospace . '">' : 'style="font-family:monospace">') .
-            $this->_textFilter(_("Archive Name") . ':  ' . $name, 'Space2html', array(
+            $this->_textFilter($this->_dict->t("Archive Name") . ':  ' . $name, 'Space2html', array(
                 'charset' => $charset,
                 'encode' => true,
                 'encode_all' => true
             )) . "\n" .
-            $this->_textFilter(_("Archive File Size") . ': ' . strlen($contents) . ' bytes', 'Space2html', array(
+            $this->_textFilter($this->_dict->t("Archive File Size") . ': ' . strlen($contents) . ' bytes', 'Space2html', array(
                 'charset' => $charset,
                 'encode' => true,
                 'encode_all' => true
             )) . "\n" .
-            $this->_textFilter(sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount), 'Space2html', array(
+            $this->_textFilter(sprintf($this->_dict->n("File Count: %d file", "File Count: %d files", $fileCount), $fileCount), 'Space2html', array(
                 'charset' => $charset,
                 'encode' => true,
                 'encode_all' => true
             )) .
             "\n\n" .
             $this->_textFilter(
-                str_pad(_("File Name"), 62, ' ', STR_PAD_RIGHT) .
-                str_pad(_("Attributes"), 15, ' ', STR_PAD_LEFT) .
-                str_pad(_("Size"), 10, ' ', STR_PAD_LEFT) .
-                str_pad(_("Modified Date"), 19, ' ', STR_PAD_LEFT),
+                str_pad($this->_dict->t("File Name"), 62, ' ', STR_PAD_RIGHT) .
+                str_pad($this->_dict->t("Attributes"), 15, ' ', STR_PAD_LEFT) .
+                str_pad($this->_dict->t("Size"), 10, ' ', STR_PAD_LEFT) .
+                str_pad($this->_dict->t("Modified Date"), 19, ' ', STR_PAD_LEFT),
                 'Space2html',
                 array(
                     'charset' => $charset,
index ec172dd..aaf356e 100644 (file)
@@ -72,7 +72,7 @@ class Horde_Mime_Viewer_Wordperfect extends Horde_Mime_Viewer_Base
 
         $data = file_exists($tmp_output)
             ? file_get_contents($tmp_output)
-            : _("Unable to translate this WordPerfect document");
+            : $this->_dict->t("Unable to translate this WordPerfect document");
 
         return $this->_renderReturn(
             $data,
index 29dc03e..d77bdb8 100644 (file)
@@ -87,7 +87,7 @@ class Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Base
 
         $name = $this->_mimepart->getName(true);
         if (empty($name)) {
-            $name = _("unnamed");
+            $name = $this->_dict->t("unnamed");
         }
 
         $monospace = $this->getConfigParam('monospace');
@@ -95,17 +95,17 @@ class Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Base
         $text = '<table><tr><td align="left"><span ' .
             ($monospace ? 'class="' . $monospace . '">' : 'style="font-family:monospace">') .
             $this->_textFilter(
-                _("Archive Name") . ': ' . $name . "\n" .
-                _("Archive File Size") . ': ' . strlen($contents) .
+                $this->_dict->t("Archive Name") . ': ' . $name . "\n" .
+                $this->_dict->t("Archive File Size") . ': ' . strlen($contents) .
                 " bytes\n" .
-                sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount) .
+                sprintf($this->_dict->n("File Count: %d file", "File Count: %d files", $fileCount), $fileCount) .
                 "\n\n" .
                 str_repeat(' ', 15) .
-                Horde_String::pad(_("Attributes"), 10, ' ', STR_PAD_LEFT) .
-                Horde_String::pad(_("Size"), 10, ' ', STR_PAD_LEFT) .
-                Horde_String::pad(_("Modified Date"), 19, ' ', STR_PAD_LEFT) .
-                Horde_String::pad(_("Method"), 10, ' ', STR_PAD_LEFT) .
-                Horde_String::pad(_("Ratio"), 10, ' ', STR_PAD_LEFT) .
+                Horde_String::pad($this->_dict->t("Attributes"), 10, ' ', STR_PAD_LEFT) .
+                Horde_String::pad($this->_dict->t("Size"), 10, ' ', STR_PAD_LEFT) .
+                Horde_String::pad($this->_dict->t("Modified Date"), 19, ' ', STR_PAD_LEFT) .
+                Horde_String::pad($this->_dict->t("Method"), 10, ' ', STR_PAD_LEFT) .
+                Horde_String::pad($this->_dict->t("Ratio"), 10, ' ', STR_PAD_LEFT) .
                 "\n",
                 'Space2html',
                 array(
index 89f8d21..4668179 100644 (file)
@@ -31,8 +31,21 @@ class Horde_Form {
     protected $_autofilled = false;
     protected $_help = false;
 
-    public function __construct($vars, $title = '', $name = null)
+    /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    public function __construct($vars, $title = '', $name = null, $dict = null)
     {
+        if ($dict) {
+            $this->_dict = $dict;
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Model', dirname(__FILE__) . '/../../locale');
+        }
+
         if (is_null($name)) {
             $name = Horde_String::lower(get_class($this));
         }
@@ -372,7 +385,7 @@ class Horde_Form {
         if ($this->_useFormToken) {
             $tokenSource = $GLOBALS['injector']->getInstance('Horde_Token');
             if (!$tokenSource->verify($this->_vars->get($this->_name . '_formToken'))) {
-                $this->_errors['_formToken'] = _("This form has already been processed.");
+                $this->_errors['_formToken'] = $this->_dict->t("This form has already been processed.");
             }
         }
 
@@ -628,7 +641,7 @@ class Horde_Form_Type_number extends Horde_Form_Type
     function isValid($var, $vars, $value, &$message)
     {
         if ($var->isRequired() && empty($value) && ((string)(double)$value !== $value)) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         } elseif (empty($value)) {
             return true;
@@ -639,7 +652,7 @@ class Horde_Form_Type_number extends Horde_Form_Type
             return true;
         }
 
-        $message = _("This field must be a valid number.");
+        $message = $this->_dict->t("This field must be a valid number.");
         return false;
     }
 
@@ -695,7 +708,7 @@ class Horde_Form_Type_number extends Horde_Form_Type
      */
     function about()
     {
-        return array('name' => _("Number"));
+        return array('name' => $this->_dict->t("Number"));
     }
 }
 
@@ -704,7 +717,7 @@ class Horde_Form_Type_int extends Horde_Form_Type {
     function isValid($var, $vars, $value, &$message)
     {
         if ($var->isRequired() && empty($value) && ((string)(int)$value !== $value)) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -712,7 +725,7 @@ class Horde_Form_Type_int extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("This field may only contain integers.");
+        $message = $this->_dict->t("This field may only contain integers.");
         return false;
     }
 
@@ -721,7 +734,7 @@ class Horde_Form_Type_int extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Integer"));
+        return array('name' => $this->_dict->t("Integer"));
     }
 
 }
@@ -731,7 +744,7 @@ class Horde_Form_Type_octal extends Horde_Form_Type {
     function isValid($var, $vars, $value, &$message)
     {
         if ($var->isRequired() && empty($value) && ((string)(int)$value !== $value)) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -739,7 +752,7 @@ class Horde_Form_Type_octal extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("This field may only contain octal values.");
+        $message = $this->_dict->t("This field may only contain octal values.");
         return false;
     }
 
@@ -748,7 +761,7 @@ class Horde_Form_Type_octal extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Octal"));
+        return array('name' => $this->_dict->t("Octal"));
     }
 
 }
@@ -758,7 +771,7 @@ class Horde_Form_Type_intlist extends Horde_Form_Type {
     function isValid($var, $vars, $value, &$message)
     {
         if (empty($value) && $var->isRequired()) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -766,7 +779,7 @@ class Horde_Form_Type_intlist extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("This field must be a comma or space separated list of integers");
+        $message = $this->_dict->t("This field must be a comma or space separated list of integers");
         return false;
     }
 
@@ -775,7 +788,7 @@ class Horde_Form_Type_intlist extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Integer list"));
+        return array('name' => $this->_dict->t("Integer list"));
     }
 
 }
@@ -818,14 +831,14 @@ class Horde_Form_Type_text extends Horde_Form_Type {
 
         if (!empty($this->_maxlength) && Horde_String::length($value) > $this->_maxlength) {
             $valid = false;
-            $message = sprintf(_("Value is over the maximum length of %s."), $this->_maxlength);
+            $message = sprintf($this->_dict->t("Value is over the maximum length of %s."), $this->_maxlength);
         } elseif ($var->isRequired() && empty($this->_regex)) {
             if (!($valid = strlen(trim($value)) > 0)) {
-                $message = _("This field is required.");
+                $message = $this->_dict->t("This field is required.");
             }
         } elseif (strlen($this->_regex)) {
             if (!($valid = preg_match($this->_regex, $value))) {
-                $message = _("You must enter a valid value.");
+                $message = $this->_dict->t("You must enter a valid value.");
             }
         }
 
@@ -838,13 +851,13 @@ class Horde_Form_Type_text extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Text"),
+            'name' => $this->_dict->t("Text"),
             'params' => array(
-                'regex'     => array('label' => _("Regex"),
+                'regex'     => array('label' => $this->_dict->t("Regex"),
                                      'type'  => 'text'),
-                'size'      => array('label' => _("Size"),
+                'size'      => array('label' => $this->_dict->t("Size"),
                                      'type'  => 'int'),
-                'maxlength' => array('label' => _("Maximum length"),
+                'maxlength' => array('label' => $this->_dict->t("Maximum length"),
                                      'type'  => 'int')));
     }
 
@@ -858,13 +871,13 @@ class Horde_Form_Type_stringlist extends Horde_Form_Type_text {
     function about()
     {
         return array(
-            'name' => _("String list"),
+            'name' => $this->_dict->t("String list"),
             'params' => array(
-                'regex'     => array('label' => _("Regex"),
+                'regex'     => array('label' => $this->_dict->t("Regex"),
                                      'type'  => 'text'),
-                'size'      => array('label' => _("Size"),
+                'size'      => array('label' => $this->_dict->t("Size"),
                                      'type'  => 'int'),
-                'maxlength' => array('label' => _("Maximum length"),
+                'maxlength' => array('label' => $this->_dict->t("Maximum length"),
                                      'type'  => 'int')),
         );
     }
@@ -880,12 +893,12 @@ class Horde_Form_Type_phone extends Horde_Form_Type {
         if ($var->isRequired()) {
             $valid = strlen(trim($value)) > 0;
             if (!$valid) {
-                $message = _("This field is required.");
+                $message = $this->_dict->t("This field is required.");
             }
         } else {
             $valid = preg_match('/^\+?[\d()\-\/ ]*$/', $value);
             if (!$valid) {
-                $message = _("You must enter a valid phone number, digits only with an optional '+' for the international dialing prefix.");
+                $message = $this->_dict->t("You must enter a valid phone number, digits only with an optional '+' for the international dialing prefix.");
             }
         }
 
@@ -897,7 +910,7 @@ class Horde_Form_Type_phone extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Phone number"));
+        return array('name' => $this->_dict->t("Phone number"));
     }
 
 }
@@ -909,7 +922,7 @@ class Horde_Form_Type_cellphone extends Horde_Form_Type_phone {
      */
     function about()
     {
-        return array('name' => _("Mobile phone number"));
+        return array('name' => $this->_dict->t("Mobile phone number"));
     }
 
 }
@@ -935,11 +948,11 @@ class Horde_Form_Type_ipaddress extends Horde_Form_Type_text {
             }
 
             if (!$valid) {
-                $message = _("Please enter a valid IP address.");
+                $message = $this->_dict->t("Please enter a valid IP address.");
             }
         } elseif ($var->isRequired()) {
             $valid = false;
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
         }
 
         return $valid;
@@ -950,7 +963,7 @@ class Horde_Form_Type_ipaddress extends Horde_Form_Type_text {
      */
     function about()
     {
-        return array('name' => _("IP address"));
+        return array('name' => $this->_dict->t("IP address"));
     }
 
 }
@@ -993,13 +1006,13 @@ class Horde_Form_Type_longtext extends Horde_Form_Type_text {
     function about()
     {
         return array(
-            'name' => _("Long text"),
+            'name' => $this->_dict->t("Long text"),
             'params' => array(
-                'rows'   => array('label' => _("Number of rows"),
+                'rows'   => array('label' => $this->_dict->t("Number of rows"),
                                   'type'  => 'int'),
-                'cols'   => array('label' => _("Number of columns"),
+                'cols'   => array('label' => $this->_dict->t("Number of columns"),
                                   'type'  => 'int'),
-                'helper' => array('label' => _("Helper?"),
+                'helper' => array('label' => $this->_dict->t("Helper?"),
                                   'type'  => 'boolean')));
     }
 
@@ -1023,10 +1036,10 @@ class Horde_Form_Type_countedtext extends Horde_Form_Type_longtext {
 
         if ($var->isRequired() && $length <= 0) {
             $valid = false;
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
         } elseif ($length > $this->_chars) {
             $valid = false;
-            $message = sprintf(_("There are too many characters in this field. You have entered %s characters; you must enter less than %s."), Horde_String::length(trim($value)), $this->_chars);
+            $message = sprintf($this->_dict->t("There are too many characters in this field. You have entered %s characters; you must enter less than %s."), Horde_String::length(trim($value)), $this->_chars);
         }
 
         return $valid;
@@ -1038,13 +1051,13 @@ class Horde_Form_Type_countedtext extends Horde_Form_Type_longtext {
     function about()
     {
         return array(
-            'name' => _("Counted text"),
+            'name' => $this->_dict->t("Counted text"),
             'params' => array(
-                'rows'  => array('label' => _("Number of rows"),
+                'rows'  => array('label' => $this->_dict->t("Number of rows"),
                                  'type'  => 'int'),
-                'cols'  => array('label' => _("Number of columns"),
+                'cols'  => array('label' => $this->_dict->t("Number of columns"),
                                  'type'  => 'int'),
-                'chars' => array('label' => _("Number of characters"),
+                'chars' => array('label' => $this->_dict->t("Number of characters"),
                                  'type'  => 'int')));
     }
 
@@ -1058,11 +1071,11 @@ class Horde_Form_Type_address extends Horde_Form_Type_longtext {
     function about()
     {
         return array(
-            'name' => _("Address"),
+            'name' => $this->_dict->t("Address"),
             'params' => array(
-                'rows' => array('label' => _("Number of rows"),
+                'rows' => array('label' => $this->_dict->t("Number of rows"),
                                 'type'  => 'int'),
-                'cols' => array('label' => _("Number of columns"),
+                'cols' => array('label' => $this->_dict->t("Number of columns"),
                                 'type'  => 'int')));
     }
 
@@ -1112,7 +1125,7 @@ class Horde_Form_Type_file extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("File upload"));
+        return array('name' => $this->_dict->t("File upload"));
     }
 
 }
@@ -1134,7 +1147,7 @@ class Horde_Form_Type_boolean extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("True or false"));
+        return array('name' => $this->_dict->t("True or false"));
     }
 
 }
@@ -1165,25 +1178,25 @@ class Horde_Form_Type_link extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Link"),
+            'name' => $this->_dict->t("Link"),
             'params' => array(
                 'url' => array(
-                    'label' => _("Link URL"),
+                    'label' => $this->_dict->t("Link URL"),
                     'type' => 'text'),
                 'text' => array(
-                    'label' => _("Link text"),
+                    'label' => $this->_dict->t("Link text"),
                     'type' => 'text'),
                 'target' => array(
-                    'label' => _("Link target"),
+                    'label' => $this->_dict->t("Link target"),
                     'type' => 'text'),
                 'onclick' => array(
-                    'label' => _("Onclick event"),
+                    'label' => $this->_dict->t("Onclick event"),
                     'type' => 'text'),
                 'title' => array(
-                    'label' => _("Link title attribute"),
+                    'label' => $this->_dict->t("Link title attribute"),
                     'type' => 'text'),
                 'accesskey' => array(
-                    'label' => _("Link access key"),
+                    'label' => $this->_dict->t("Link access key"),
                     'type' => 'text')));
     }
 
@@ -1224,7 +1237,7 @@ class Horde_Form_Type_email extends Horde_Form_Type {
 
         // Check for too many.
         if (!$this->_allow_multi && count($emails) > 1) {
-            $message = _("Only one email address is allowed.");
+            $message = $this->_dict->t("Only one email address is allowed.");
             return false;
         }
 
@@ -1235,7 +1248,7 @@ class Horde_Form_Type_email extends Horde_Form_Type {
                 continue;
             }
             if (!$this->validateEmailAddress($email)) {
-                $message = sprintf(_("\"%s\" is not a valid email address."), $email);
+                $message = sprintf($this->_dict->t("\"%s\" is not a valid email address."), $email);
                 return false;
             }
             ++$nonEmpty;
@@ -1243,9 +1256,9 @@ class Horde_Form_Type_email extends Horde_Form_Type {
 
         if (!$nonEmpty && $var->isRequired()) {
             if ($this->_allow_multi) {
-                $message = _("You must enter at least one email address.");
+                $message = $this->_dict->t("You must enter at least one email address.");
             } else {
-                $message = _("You must enter an email address.");
+                $message = $this->_dict->t("You must enter an email address.");
             }
             return false;
         }
@@ -1420,17 +1433,17 @@ class Horde_Form_Type_email extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Email"),
+            'name' => $this->_dict->t("Email"),
             'params' => array(
-                'allow_multi' => array('label' => _("Allow multiple addresses?"),
+                'allow_multi' => array('label' => $this->_dict->t("Allow multiple addresses?"),
                                        'type'  => 'boolean'),
-                'strip_domain' => array('label' => _("Protect address from spammers?"),
+                'strip_domain' => array('label' => $this->_dict->t("Protect address from spammers?"),
                                         'type' => 'boolean'),
-                'link_compose' => array('label' => _("Link the email address to the compose page when displaying?"),
+                'link_compose' => array('label' => $this->_dict->t("Link the email address to the compose page when displaying?"),
                                         'type' => 'boolean'),
-                'link_name' => array('label' => _("The name to use when linking to the compose page"),
+                'link_name' => array('label' => $this->_dict->t("The name to use when linking to the compose page"),
                                      'type' => 'text'),
-                'delimiters' => array('label' => _("Character to split multiple addresses with"),
+                'delimiters' => array('label' => $this->_dict->t("Character to split multiple addresses with"),
                                       'type' => 'text'),
             ),
         );
@@ -1640,9 +1653,9 @@ class Horde_Form_Type_matrix extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Field matrix"),
+            'name' => $this->_dict->t("Field matrix"),
             'params' => array(
-                'cols' => array('label' => _("Column titles"),
+                'cols' => array('label' => $this->_dict->t("Column titles"),
                                 'type'  => 'stringlist')));
     }
 
@@ -1653,12 +1666,12 @@ class Horde_Form_Type_emailConfirm extends Horde_Form_Type {
     function isValid($var, $vars, $value, &$message)
     {
         if ($var->isRequired() && empty($value['original'])) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
         if ($value['original'] != $value['confirm']) {
-            $message = _("Email addresses must match.");
+            $message = $this->_dict->t("Email addresses must match.");
             return false;
         } else {
             $parser = new Horde_Mail_Rfc822();
@@ -1667,11 +1680,11 @@ class Horde_Form_Type_emailConfirm extends Horde_Form_Type {
             ));
 
             if (count($parsed_email) > 1) {
-                $message = _("Only one email address allowed.");
+                $message = $this->_dict->t("Only one email address allowed.");
                 return false;
             }
             if (empty($parsed_email[0]->mailbox)) {
-                $message = _("You did not enter a valid email address.");
+                $message = $this->_dict->t("You did not enter a valid email address.");
                 return false;
             }
         }
@@ -1684,7 +1697,7 @@ class Horde_Form_Type_emailConfirm extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Email with confirmation"));
+        return array('name' => $this->_dict->t("Email with confirmation"));
     }
 
 }
@@ -1699,7 +1712,7 @@ class Horde_Form_Type_password extends Horde_Form_Type {
             $valid = strlen(trim($value)) > 0;
 
             if (!$valid) {
-                $message = _("This field is required.");
+                $message = $this->_dict->t("This field is required.");
             }
         }
 
@@ -1711,7 +1724,7 @@ class Horde_Form_Type_password extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Password"));
+        return array('name' => $this->_dict->t("Password"));
     }
 
 }
@@ -1721,12 +1734,12 @@ class Horde_Form_Type_passwordconfirm extends Horde_Form_Type {
     function isValid($var, $vars, $value, &$message)
     {
         if ($var->isRequired() && empty($value['original'])) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
         if ($value['original'] != $value['confirm']) {
-            $message = _("Passwords must match.");
+            $message = $this->_dict->t("Passwords must match.");
             return false;
         }
 
@@ -1744,7 +1757,7 @@ class Horde_Form_Type_passwordconfirm extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Password with confirmation"));
+        return array('name' => $this->_dict->t("Password with confirmation"));
     }
 
 }
@@ -1759,7 +1772,7 @@ class Horde_Form_Type_enum extends Horde_Form_Type {
         $this->_values = $values;
 
         if ($prompt === true) {
-            $this->_prompt = _("-- select --");
+            $this->_prompt = $this->_dict->t("-- select --");
         } else {
             $this->_prompt = $prompt;
         }
@@ -1768,7 +1781,7 @@ class Horde_Form_Type_enum extends Horde_Form_Type {
     function isValid($var, $vars, $value, &$message)
     {
         if ($var->isRequired() && $value == '' && !isset($this->_values[$value])) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -1777,7 +1790,7 @@ class Horde_Form_Type_enum extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("Invalid data.");
+        $message = $this->_dict->t("Invalid data.");
         return false;
     }
 
@@ -1787,11 +1800,11 @@ class Horde_Form_Type_enum extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Drop down list"),
+            'name' => $this->_dict->t("Drop down list"),
             'params' => array(
-                'values' => array('label' => _("Values to select from"),
+                'values' => array('label' => $this->_dict->t("Values to select from"),
                                   'type'  => 'stringlist'),
-                'prompt' => array('label' => _("Prompt text"),
+                'prompt' => array('label' => $this->_dict->t("Prompt text"),
                                   'type'  => 'text')));
     }
 
@@ -1807,7 +1820,7 @@ class Horde_Form_Type_mlenum extends Horde_Form_Type {
         $this->_values = &$values;
 
         if ($prompts === true) {
-            $this->_prompts = array(_("-- select --"), _("-- select --"));
+            $this->_prompts = array($this->_dict->t("-- select --"), $this->_dict->t("-- select --"));
         } elseif (!is_array($prompts)) {
             $this->_prompts = array($prompts, $prompts);
         } else {
@@ -1828,7 +1841,7 @@ class Horde_Form_Type_mlenum extends Horde_Form_Type {
     function isValid($var, $vars, $value, &$message)
     {
         if ($var->isRequired() && (empty($value['1']) || empty($value['2']))) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -1837,7 +1850,7 @@ class Horde_Form_Type_mlenum extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("Invalid data.");
+        $message = $this->_dict->t("Invalid data.");
         return false;
     }
 
@@ -1853,11 +1866,11 @@ class Horde_Form_Type_mlenum extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Multi-level drop down lists"),
+            'name' => $this->_dict->t("Multi-level drop down lists"),
             'params' => array(
-                'values' => array('label' => _("Values to select from"),
+                'values' => array('label' => $this->_dict->t("Values to select from"),
                                   'type'  => 'stringlist'),
-                'prompt' => array('label' => _("Prompt text"),
+                'prompt' => array('label' => $this->_dict->t("Prompt text"),
                                   'type'  => 'text')));
     }
 
@@ -1889,7 +1902,7 @@ class Horde_Form_Type_multienum extends Horde_Form_Type_enum {
 
         if (empty($value) && ((string)(int)$value !== $value)) {
             if ($var->isRequired()) {
-                $message = _("This field is required.");
+                $message = $this->_dict->t("This field is required.");
                 return false;
             } else {
                 return true;
@@ -1900,7 +1913,7 @@ class Horde_Form_Type_multienum extends Horde_Form_Type_enum {
             return true;
         }
 
-        $message = _("Invalid data.");
+        $message = $this->_dict->t("Invalid data.");
         return false;
     }
 
@@ -1910,11 +1923,11 @@ class Horde_Form_Type_multienum extends Horde_Form_Type_enum {
     function about()
     {
         return array(
-            'name' => _("Multiple selection"),
+            'name' => $this->_dict->t("Multiple selection"),
             'params' => array(
-                'values' => array('label' => _("Values"),
+                'values' => array('label' => $this->_dict->t("Values"),
                                   'type'  => 'stringlist'),
-                'size'   => array('label' => _("Size"),
+                'size'   => array('label' => $this->_dict->t("Size"),
                                   'type'  => 'int'))
         );
     }
@@ -1945,9 +1958,9 @@ class Horde_Form_Type_radio extends Horde_Form_Type_enum {
     function about()
     {
         return array(
-            'name' => _("Radio selection"),
+            'name' => $this->_dict->t("Radio selection"),
             'params' => array(
-                'values' => array('label' => _("Values"),
+                'values' => array('label' => $this->_dict->t("Values"),
                                   'type'  => 'stringlist')));
     }
 
@@ -1979,7 +1992,7 @@ class Horde_Form_Type_set extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("Invalid data.");
+        $message = $this->_dict->t("Invalid data.");
         return false;
     }
 
@@ -1989,9 +2002,9 @@ class Horde_Form_Type_set extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Set"),
+            'name' => $this->_dict->t("Set"),
             'params' => array(
-                'values' => array('label' => _("Values"),
+                'values' => array('label' => $this->_dict->t("Values"),
                                   'type'  => 'stringlist')));
     }
 
@@ -2014,7 +2027,7 @@ class Horde_Form_Type_date extends Horde_Form_Type {
             $valid = strlen(trim($value)) > 0;
 
             if (!$valid) {
-                $message = sprintf(_("%s is required"), $var->getHumanName());
+                $message = sprintf($this->_dict->t("%s is required"), $var->getHumanName());
             }
         }
 
@@ -2046,15 +2059,15 @@ class Horde_Form_Type_date extends Horde_Form_Type {
                                                    date('j'), date('n'),
                                                    date('Y'));
         if ($ago < -1) {
-            return sprintf(_(" (%s days ago)"), $diffdays);
+            return sprintf($this->_dict->t(" (%s days ago)"), $diffdays);
         } elseif ($ago == -1) {
-            return _(" (yesterday)");
+            return $this->_dict->t(" (yesterday)");
         } elseif ($ago == 0) {
-            return _(" (today)");
+            return $this->_dict->t(" (today)");
         } elseif ($ago == 1) {
-            return _(" (tomorrow)");
+            return $this->_dict->t(" (tomorrow)");
         } else {
-            return sprintf(_(" (in %s days)"), $diffdays);
+            return sprintf($this->_dict->t(" (in %s days)"), $diffdays);
         }
     }
 
@@ -2075,7 +2088,7 @@ class Horde_Form_Type_date extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Date"));
+        return array('name' => $this->_dict->t("Date"));
     }
 
 }
@@ -2085,7 +2098,7 @@ class Horde_Form_Type_time extends Horde_Form_Type {
     function isValid($var, $vars, $value, &$message)
     {
         if ($var->isRequired() && empty($value) && ((string)(double)$value !== $value)) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -2093,7 +2106,7 @@ class Horde_Form_Type_time extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("This field may only contain numbers and the colon.");
+        $message = $this->_dict->t("This field may only contain numbers and the colon.");
         return false;
     }
 
@@ -2102,7 +2115,7 @@ class Horde_Form_Type_time extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Time"));
+        return array('name' => $this->_dict->t("Time"));
     }
 
 }
@@ -2124,10 +2137,10 @@ class Horde_Form_Type_hourminutesecond extends Horde_Form_Type {
         }
 
         if (!$this->emptyTimeArray($time) && !$this->checktime($time['hour'], $time['minute'], $time['second'])) {
-            $message = _("Please enter a valid time.");
+            $message = $this->_dict->t("Please enter a valid time.");
             return false;
         } elseif ($this->emptyTimeArray($time) && $var->isRequired()) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -2207,9 +2220,9 @@ class Horde_Form_Type_hourminutesecond extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Time selection"),
+            'name' => $this->_dict->t("Time selection"),
             'params' => array(
-                'seconds' => array('label' => _("Show seconds?"),
+                'seconds' => array('label' => $this->_dict->t("Show seconds?"),
                                   'type'  => 'boolean')));
     }
 
@@ -2241,7 +2254,7 @@ class Horde_Form_Type_monthyear extends Horde_Form_Type {
 
         if (!$vars->get($this->getMonthVar($var)) ||
             !$vars->get($this->getYearVar($var))) {
-            $message = _("Please enter a month and a year.");
+            $message = $this->_dict->t("Please enter a month and a year.");
             return false;
         }
 
@@ -2263,11 +2276,11 @@ class Horde_Form_Type_monthyear extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Month and year"),
+        return array('name' => $this->_dict->t("Month and year"),
                      'params' => array(
-                         'start_year' => array('label' => _("Start year"),
+                         'start_year' => array('label' => $this->_dict->t("Start year"),
                                                'type'  => 'int'),
-                         'end_year'   => array('label' => _("End year"),
+                         'end_year'   => array('label' => $this->_dict->t("End year"),
                                                'type'  => 'int')));
     }
 
@@ -2316,13 +2329,13 @@ class Horde_Form_Type_monthdayyear extends Horde_Form_Type {
         $empty = $this->emptyDateArray($date);
 
         if ($empty == 1 && $var->isRequired()) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         } elseif ($empty == 0 && !checkdate($date['month'], $date['day'], $date['year'])) {
-            $message = _("Please enter a valid date, check the number of days in the month.");
+            $message = $this->_dict->t("Please enter a valid date, check the number of days in the month.");
             return false;
         } elseif ($empty == -1) {
-            $message = _("Select all date components.");
+            $message = $this->_dict->t("Select all date components.");
             return false;
         }
 
@@ -2467,17 +2480,17 @@ class Horde_Form_Type_monthdayyear extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Date selection"),
+            'name' => $this->_dict->t("Date selection"),
             'params' => array(
-                'start_year' => array('label' => _("Start year"),
+                'start_year' => array('label' => $this->_dict->t("Start year"),
                                       'type'  => 'int'),
-                'end_year'   => array('label' => _("End year"),
+                'end_year'   => array('label' => $this->_dict->t("End year"),
                                       'type'  => 'int'),
-                'picker'     => array('label' => _("Show picker?"),
+                'picker'     => array('label' => $this->_dict->t("Show picker?"),
                                       'type'  => 'boolean'),
-                'format_in'  => array('label' => _("Storage format"),
+                'format_in'  => array('label' => $this->_dict->t("Storage format"),
                                       'type'  => 'text'),
-                'format_out' => array('label' => _("Display format"),
+                'format_out' => array('label' => $this->_dict->t("Display format"),
                                       'type'  => 'text')));
     }
 
@@ -2606,19 +2619,19 @@ class Horde_Form_Type_datetime extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Date and time selection"),
+            'name' => $this->_dict->t("Date and time selection"),
             'params' => array(
-                'start_year' => array('label' => _("Start year"),
+                'start_year' => array('label' => $this->_dict->t("Start year"),
                                       'type'  => 'int'),
-                'end_year'   => array('label' => _("End year"),
+                'end_year'   => array('label' => $this->_dict->t("End year"),
                                       'type'  => 'int'),
-                'picker'     => array('label' => _("Show picker?"),
+                'picker'     => array('label' => $this->_dict->t("Show picker?"),
                                       'type'  => 'boolean'),
-                'format_in'  => array('label' => _("Storage format"),
+                'format_in'  => array('label' => $this->_dict->t("Storage format"),
                                       'type'  => 'text'),
-                'format_out' => array('label' => _("Display format"),
+                'format_out' => array('label' => $this->_dict->t("Display format"),
                                       'type'  => 'text'),
-                'seconds'    => array('label' => _("Show seconds?"),
+                'seconds'    => array('label' => $this->_dict->t("Show seconds?"),
                                       'type'  => 'boolean')));
     }
 
@@ -2629,7 +2642,7 @@ class Horde_Form_Type_colorpicker extends Horde_Form_Type {
     function isValid($var, $vars, $value, &$message)
     {
         if ($var->isRequired() && empty($value)) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -2637,7 +2650,7 @@ class Horde_Form_Type_colorpicker extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("This field must contain a color code in the RGB Hex format, for example '#1234af'.");
+        $message = $this->_dict->t("This field must contain a color code in the RGB Hex format, for example '#1234af'.");
         return false;
     }
 
@@ -2646,7 +2659,7 @@ class Horde_Form_Type_colorpicker extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Colour selection"));
+        return array('name' => $this->_dict->t("Colour selection"));
     }
 
 }
@@ -2707,13 +2720,13 @@ class Horde_Form_Type_sorter extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Sort order selection"),
+            'name' => $this->_dict->t("Sort order selection"),
             'params' => array(
-                'values' => array('label' => _("Values"),
+                'values' => array('label' => $this->_dict->t("Values"),
                                   'type'  => 'stringlist'),
-                'size'   => array('label' => _("Size"),
+                'size'   => array('label' => $this->_dict->t("Size"),
                                   'type'  => 'int'),
-                'header' => array('label' => _("Header"),
+                'header' => array('label' => $this->_dict->t("Header"),
                                   'type'  => 'text')));
     }
 
@@ -2754,7 +2767,7 @@ class Horde_Form_Type_selectfiles extends Horde_Form_Type {
     {
         $this->_selectid = $selectid;
         if (is_null($link_text)) {
-            $link_text = _("Select Files");
+            $link_text = $this->_dict->t("Select Files");
         }
         $this->_link_text = $link_text;
         $this->_link_style = $link_style;
@@ -2775,15 +2788,15 @@ class Horde_Form_Type_selectfiles extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("File selection"),
+            'name' => $this->_dict->t("File selection"),
             'params' => array(
-                'selectid'   => array('label' => _("Id"),
+                'selectid'   => array('label' => $this->_dict->t("Id"),
                                       'type' => 'text'),
-                'link_text'  => array('label' => _("Link text"),
+                'link_text'  => array('label' => $this->_dict->t("Link text"),
                                       'type' => 'text'),
-                'link_style' => array('label' => _("Link style"),
+                'link_style' => array('label' => $this->_dict->t("Link style"),
                                       'type' => 'text'),
-                'icon'       => array('label' => _("Show icon?"),
+                'icon'       => array('label' => $this->_dict->t("Show icon?"),
                                       'type' => 'boolean')));
     }
 
@@ -2886,19 +2899,19 @@ class Horde_Form_Type_assign extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Assignment columns"),
+            'name' => $this->_dict->t("Assignment columns"),
             'params' => array(
-                'leftValues'  => array('label' => _("Left values"),
+                'leftValues'  => array('label' => $this->_dict->t("Left values"),
                                        'type'  => 'stringlist'),
-                'rightValues' => array('label' => _("Right values"),
+                'rightValues' => array('label' => $this->_dict->t("Right values"),
                                        'type'  => 'stringlist'),
-                'leftHeader'  => array('label' => _("Left header"),
+                'leftHeader'  => array('label' => $this->_dict->t("Left header"),
                                        'type'  => 'text'),
-                'rightHeader' => array('label' => _("Right header"),
+                'rightHeader' => array('label' => $this->_dict->t("Right header"),
                                        'type'  => 'text'),
-                'size'        => array('label' => _("Size"),
+                'size'        => array('label' => $this->_dict->t("Size"),
                                        'type'  => 'int'),
-                'width'       => array('label' => _("Width in CSS units"),
+                'width'       => array('label' => $this->_dict->t("Width in CSS units"),
                                        'type'  => 'text')));
     }
 
@@ -2909,7 +2922,7 @@ class Horde_Form_Type_creditcard extends Horde_Form_Type {
     function isValid($var, $vars, $value, &$message)
     {
         if (empty($value) && $var->isRequired()) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -2917,7 +2930,7 @@ class Horde_Form_Type_creditcard extends Horde_Form_Type {
             /* getCardType() will also verify the checksum. */
             $type = $this->getCardType($value);
             if ($type === false || $type == 'unknown') {
-                $message = _("This does not seem to be a valid card number.");
+                $message = $this->_dict->t("This does not seem to be a valid card number.");
                 return false;
             }
         }
@@ -3001,7 +3014,7 @@ class Horde_Form_Type_creditcard extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Credit card number"));
+        return array('name' => $this->_dict->t("Credit card number"));
     }
 
 }
@@ -3018,7 +3031,7 @@ class Horde_Form_Type_obrowser extends Horde_Form_Type {
      */
     function about()
     {
-        return array('name' => _("Relationship browser"));
+        return array('name' => $this->_dict->t("Relationship browser"));
     }
 
 }
@@ -3055,13 +3068,13 @@ class Horde_Form_Type_dblookup extends Horde_Form_Type_enum {
     function about()
     {
         return array(
-            'name' => _("Database lookup"),
+            'name' => $this->_dict->t("Database lookup"),
             'params' => array(
-                'dsn' => array('label' => _("DSN (see http://pear.php.net/manual/en/package.database.db.intro-dsn.php)"),
+                'dsn' => array('label' => $this->_dict->t("DSN (see http://pear.php.net/manual/en/package.database.db.intro-dsn.php)"),
                                'type'  => 'text'),
-                'sql' => array('label' => _("SQL statement for value lookups"),
+                'sql' => array('label' => $this->_dict->t("SQL statement for value lookups"),
                                'type'  => 'text'),
-                'prompt' => array('label' => _("Prompt text"),
+                'prompt' => array('label' => $this->_dict->t("Prompt text"),
                                   'type'  => 'text'))
             );
     }
@@ -3082,12 +3095,12 @@ class Horde_Form_Type_figlet extends Horde_Form_Type {
     function isValid($var, $vars, $value, &$message)
     {
         if (empty($value) && $var->isRequired()) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
         if (Horde_String::lower($value) != Horde_String::lower($this->_text)) {
-            $message = _("The text you entered did not match the text on the screen.");
+            $message = $this->_dict->t("The text you entered did not match the text on the screen.");
             return false;
         }
 
@@ -3100,11 +3113,11 @@ class Horde_Form_Type_figlet extends Horde_Form_Type {
     function about()
     {
         return array(
-            'name' => _("Figlet CAPTCHA"),
+            'name' => $this->_dict->t("Figlet CAPTCHA"),
             'params' => array(
-                'text' => array('label' => _("Text"),
+                'text' => array('label' => $this->_dict->t("Text"),
                                 'type'  => 'text'),
-                'font' => array('label' => _("Figlet font"),
+                'font' => array('label' => $this->_dict->t("Figlet font"),
                                 'type'  => 'text'))
             );
     }
@@ -3570,7 +3583,7 @@ class Horde_Form_Variable {
             $vals = $this->getValue($vars);
             if (!is_array($vals)) {
                 if ($this->required) {
-                    $message = _("This field is required.");
+                    $message = $this->_dict->t("This field is required.");
                     return false;
                 } else {
                     return true;
@@ -3578,7 +3591,7 @@ class Horde_Form_Variable {
             }
             foreach ($vals as $i => $value) {
                 if ($value === null && $this->required) {
-                    $message = _("This field is required.");
+                    $message = $this->_dict->t("This field is required.");
                     return false;
                 } else {
                     if (!$this->type->isValid($this, $vars, $value, $message)) {
index ca8f5b4..428ff4f 100644 (file)
@@ -42,14 +42,29 @@ abstract class Horde_Form_Renderer {
     var $_encodeTitle = true;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Construct a new Horde_Form_Renderer::.
      *
      * @param array $params  This is a hash of renderer-specific parameters.
-     *                       Possible keys:<code>
-     *                       'encode_title': @see $_encodeTitle</code>
+     *                       Possible keys:
+     *                       - 'encode_title': @see $_encodeTitle
+     *                       - 'translation': (object) A translation handler
+     *                                        implementing Horde_Translation.
      */
     function __construct($params = array())
     {
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Model', dirname(__FILE__) . '/../../../locale');
+        }
+
         if (isset($params['encode_title'])) {
             $this->encodeTitle($params['encode_title']);
         }
@@ -63,14 +78,14 @@ abstract class Horde_Form_Renderer {
     {
         if ($submit === true || is_null($submit) || empty($submit)) {
             /* Default to 'Submit'. */
-            $submit = array(_("Submit"));
+            $submit = array($this->_dict->t("Submit"));
         } elseif (!is_array($submit)) {
             /* Default to array if not passed. */
             $submit = array($submit);
         }
         /* Only if $reset is strictly true insert default 'Reset'. */
         if ($reset === true) {
-            $reset = _("Reset");
+            $reset = $this->_dict->t("Reset");
         }
 
         $this->_submit = $submit;
index 5d0d4ce..351e697 100644 (file)
@@ -276,10 +276,10 @@ try {
     function submit($submit = null, $reset = false)
     {
         if (is_null($submit) || empty($submit)) {
-            $submit = _("Submit");
+            $submit = $this->_dict->t("Submit");
         }
         if ($reset === true) {
-            $reset = _("Reset");
+            $reset = $this->_dict->t("Reset");
         }
         $this->_renderSubmit($submit, $reset);
     }
@@ -295,7 +295,7 @@ try {
         }
         if ($this->_requiredLegend) {
             echo '<div class="form-error-example">' . $this->_requiredMarker
-                . ' &#61; ' . _("Required Field") . '</div>'."\n";
+                . ' &#61; ' . $this->_dict->t("Required Field") . '</div>'."\n";
         }
     }
 
index 0cf892d..356a034 100644 (file)
@@ -5,17 +5,32 @@
  * @author  Robert E. Coyle <robertecoyle@hotmail.com>
  * @package Horde_Form
  */
-abstract class Horde_Form_Type {
-
+abstract class Horde_Form_Type
+{
     protected $_properties = array();
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Type constructor. Takes a hash of key/value parameters.
      *
      * @param array $properties Any type properties to initialize.
+     * @param Horde_Translation $dict  A translation handler implementing
+     *                                 Horde_Translation.
      */
-    public function __construct($properties = array())
+    public function __construct($properties = array(), $dict = null)
     {
+        if ($dict) {
+            $this->_dict = $dict;
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Model', dirname(__FILE__) . '/../../../locale');
+        }
+
         $this->_properties = array();
         $vars = array_keys(get_object_vars($this));
         foreach ($vars as $var) {
index 383a16a..538eaee 100644 (file)
@@ -7,7 +7,7 @@ class Horde_Form_Type_Color extends Horde_Form_Type {
     function isValid($var, $vars, $value, &$message)
     {
         if ($var->required && empty($value)) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -15,7 +15,7 @@ class Horde_Form_Type_Color extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("This field must contain a color code in the RGB Hex format, for example '#1234af'.");
+        $message = $this->_dict->t("This field must contain a color code in the RGB Hex format, for example '#1234af'.");
         return false;
     }
 
index 294834c..6ed0c5c 100644 (file)
@@ -7,7 +7,7 @@ class Horde_Form_Type_creditcard extends Horde_Form_Type {
     function isValid($var, $vars, $value, &$message)
     {
         if (empty($value) && $var->required) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -15,7 +15,7 @@ class Horde_Form_Type_creditcard extends Horde_Form_Type {
             /* getCardType() will also verify the checksum. */
             $type = $this->getCardType($value);
             if ($type === false || $type == 'unknown') {
-                $message = _("This does not seem to be a valid card number.");
+                $message = $this->_dict->t("This does not seem to be a valid card number.");
                 return false;
             }
         }
index c4415e7..db80653 100644 (file)
@@ -14,7 +14,7 @@ class Horde_Form_Type_Date extends Horde_Form_Type {
             $valid = strlen(trim($value)) > 0;
 
             if (!$valid) {
-                $message = _("This field is required.");
+                $message = $this->_dict->t("This field is required.");
             }
         }
 
@@ -43,15 +43,15 @@ class Horde_Form_Type_Date extends Horde_Form_Type {
                                                    date('j'), date('n'),
                                                    date('Y'));
         if ($ago < -1) {
-            return sprintf(_(" (%s days ago)"), $diffdays);
+            return sprintf($this->_dict->t(" (%s days ago)"), $diffdays);
         } elseif ($ago == -1) {
-            return _(" (yesterday)");
+            return $this->_dict->t(" (yesterday)");
         } elseif ($ago == 0) {
-            return _(" (today)");
+            return $this->_dict->t(" (today)");
         } elseif ($ago == 1) {
-            return _(" (tomorrow)");
+            return $this->_dict->t(" (tomorrow)");
         } else {
-            return sprintf(_(" (in %s days)"), $diffdays);
+            return sprintf($this->_dict->t(" (in %s days)"), $diffdays);
         }
     }
 
index c395468..83f70a7 100644 (file)
@@ -74,7 +74,7 @@ class Horde_Form_Type_Email extends Horde_Form_Type {
 
         // Check for too many.
         if (!$this->_allow_multi && count($emails) > 1) {
-            $message = _("Only one email address is allowed.");
+            $message = $this->_dict->t("Only one email address is allowed.");
             return false;
         }
 
@@ -85,7 +85,7 @@ class Horde_Form_Type_Email extends Horde_Form_Type {
                 continue;
             }
             if (!$this->validateEmailAddress($email)) {
-                $message = sprintf(_("\"%s\" is not a valid email address."), $email);
+                $message = sprintf($this->_dict->t("\"%s\" is not a valid email address."), $email);
                 return false;
             }
             ++$nonEmpty;
@@ -93,9 +93,9 @@ class Horde_Form_Type_Email extends Horde_Form_Type {
 
         if (!$nonEmpty && $var->required) {
             if ($this->_allow_multi) {
-                $message = _("You must enter at least one email address.");
+                $message = $this->_dict->t("You must enter at least one email address.");
             } else {
-                $message = _("You must enter an email address.");
+                $message = $this->_dict->t("You must enter an email address.");
             }
             return false;
         }
@@ -421,12 +421,12 @@ class Horde_Form_Type_EmailConfirm extends Horde_Form_Type {
     public function isValid($var, $vars, $value, &$message)
     {
         if ($var->required && empty($value['original'])) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
         if ($value['original'] != $value['confirm']) {
-            $message = _("Email addresses must match.");
+            $message = $this->_dict->t("Email addresses must match.");
             return false;
         } else {
             try {
@@ -438,11 +438,11 @@ class Horde_Form_Type_EmailConfirm extends Horde_Form_Type {
                 return false;
             }
             if (count($parsed_email) > 1) {
-                $message = _("Only one email address allowed.");
+                $message = $this->_dict->t("Only one email address allowed.");
                 return false;
             }
             if (empty($parsed_email[0]->mailbox)) {
-                $message = _("You did not enter a valid email address.");
+                $message = $this->_dict->t("You did not enter a valid email address.");
                 return false;
             }
         }
index c5e638e..ff8a0d4 100644 (file)
@@ -25,7 +25,7 @@ class Horde_Form_Type_Enum extends Horde_Form_Type {
     public function isValid($var, $vars, $value, &$message)
     {
         if ($var->required && $value == '' && !isset($this->_values[$value])) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -34,7 +34,7 @@ class Horde_Form_Type_Enum extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("Invalid data.");
+        $message = $this->_dict->t("Invalid data.");
         return false;
     }
 
index 31375a7..d2dbbb5 100644 (file)
@@ -7,7 +7,7 @@ class Horde_Form_Type_Int extends Horde_Form_Type {
     public function isValid($var, $vars, $value, &$message)
     {
         if ($var->required && empty($value) && ((string)(int)$value !== $value)) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -15,7 +15,7 @@ class Horde_Form_Type_Int extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("This field may only contain integers.");
+        $message = $this->_dict->t("This field may only contain integers.");
         return false;
     }
 
index d4a3a9d..5990f4f 100644 (file)
@@ -11,7 +11,7 @@ class Horde_Form_Type_Number extends Horde_Form_Type {
     public function isValid($var, $vars, $value, &$message)
     {
         if ($var->required && empty($value) && ((string)(double)$value !== $value)) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         } elseif (empty($value)) {
             return true;
@@ -22,7 +22,7 @@ class Horde_Form_Type_Number extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("This field must be a valid number.");
+        $message = $this->_dict->t("This field must be a valid number.");
         return false;
     }
 
index 111cdb7..b5c3777 100644 (file)
@@ -7,7 +7,7 @@ class Horde_Form_Type_Octal extends Horde_Form_Type {
     function isValid($var, $vars, $value, &$message)
     {
         if ($var->required && empty($value) && ((string)(int)$value !== $value)) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -15,7 +15,7 @@ class Horde_Form_Type_Octal extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("This field may only contain octal values.");
+        $message = $this->_dict->t("This field may only contain octal values.");
         return false;
     }
 
index a47a178..a82a3ff 100644 (file)
@@ -12,7 +12,7 @@ class Horde_Form_Type_Password extends Horde_Form_Type {
             $valid = strlen(trim($value)) > 0;
 
             if (!$valid) {
-                $message = _("This field is required.");
+                $message = $this->_dict->t("This field is required.");
             }
         }
 
@@ -30,12 +30,12 @@ class Horde_Form_Type_passwordConfirm extends Horde_Form_Type {
     public function isValid($var, $vars, $value, &$message)
     {
         if ($var->required && empty($value['original'])) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
         if ($value['original'] != $value['confirm']) {
-            $message = _("Passwords must match.");
+            $message = $this->_dict->t("Passwords must match.");
             return false;
         }
 
index 488fa57..c51e440 100644 (file)
@@ -11,12 +11,12 @@ class Horde_Form_Type_Phone extends Horde_Form_Type {
         if ($var->required) {
             $valid = strlen(trim($value)) > 0;
             if (!$valid) {
-                $message = _("This field is required.");
+                $message = $this->_dict->t("This field is required.");
             }
         } else {
             $valid = preg_match('/^\+?[\d()\-\/ ]*$/', $value);
             if (!$valid) {
-                $message = _("You must enter a valid phone number, digits only with an optional '+' for the international dialing prefix.");
+                $message = $this->_dict->t("You must enter a valid phone number, digits only with an optional '+' for the international dialing prefix.");
             }
         }
 
index db805ad..9e19b47 100644 (file)
@@ -27,7 +27,7 @@ class Horde_Form_Type_Set extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("Invalid data.");
+        $message = $this->_dict->t("Invalid data.");
         return false;
     }
 
@@ -48,7 +48,7 @@ class Horde_Form_Type_multienum extends Horde_Form_Type_enum {
 
         if (empty($value) && ((string)(int)$value !== $value)) {
             if ($var->required) {
-                $message = _("This field is required.");
+                $message = $this->_dict->t("This field is required.");
                 return false;
             } else {
                 return true;
@@ -59,7 +59,7 @@ class Horde_Form_Type_multienum extends Horde_Form_Type_enum {
             return true;
         }
 
-        $message = _("Invalid data.");
+        $message = $this->_dict->t("Invalid data.");
         return false;
     }
 
index 66432c5..f87f192 100644 (file)
@@ -26,14 +26,14 @@ class Horde_Form_Type_String extends Horde_Form_Type {
 
         if (!empty($this->_maxlength) && Horde_String::length($value) > $this->_maxlength) {
             $valid = false;
-            $message = sprintf(_("Value is over the maximum length of %s."), $this->_maxlength);
+            $message = sprintf($this->_dict->t("Value is over the maximum length of %s."), $this->_maxlength);
         } elseif ($var->required && empty($this->_regex)) {
             if (!($valid = strlen(trim($value)) > 0)) {
-                $message = _("This field is required.");
+                $message = $this->_dict->t("This field is required.");
             }
         } elseif (strlen($this->_regex)) {
             if (!($valid = preg_match($this->_regex, $value))) {
-                $message = _("You must enter a valid value.");
+                $message = $this->_dict->t("You must enter a valid value.");
             }
         }
 
index 3b26133..e5ccdfc 100644 (file)
@@ -7,7 +7,7 @@ class Horde_Form_Type_Time extends Horde_Form_Type {
     public function isValid($var, $vars, $value, &$message)
     {
         if ($var->required && empty($value) && ((string)(double)$value !== $value)) {
-            $message = _("This field is required.");
+            $message = $this->_dict->t("This field is required.");
             return false;
         }
 
@@ -15,7 +15,7 @@ class Horde_Form_Type_Time extends Horde_Form_Type {
             return true;
         }
 
-        $message = _("This field may only contain numbers and the colon.");
+        $message = $this->_dict->t("This field may only contain numbers and the colon.");
         return false;
     }
 
index 387f3f4..cfc8f9c 100644 (file)
@@ -15,6 +15,25 @@ class Horde_Form_VarRenderer_Xhtml extends Horde_Form_VarRenderer
     protected $_onLoadJS = array();
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
+     * Constructor.
+     */
+    public function __construct($params = array())
+    {
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Model', dirname(__FILE__) . '/../../../../locale');
+        }
+    }
+
+    /**
      * Handles the end of rendering of variables; writes onload JavaScript.
      *
      * @access public
@@ -178,8 +197,8 @@ class Horde_Form_VarRenderer_Xhtml extends Horde_Form_VarRenderer
                     'Horde_Html_Helper.iconlist' => $icon_list
                 ));
 
-                $html .= Horde::link('#', _("Emoticons"), '', '', 'Horde_Html_Helper.open(\'emoticons\', \'' . $var->getVarName() . '\'); return false;')
-                    . Horde::img('emoticons/smile.png', _("Emoticons"), 'id="' . $imgId . '" align="middle"')
+                $html .= Horde::link('#', $this->_dict->t("Emoticons"), '', '', 'Horde_Html_Helper.open(\'emoticons\', \'' . $var->getVarName() . '\'); return false;')
+                    . Horde::img('emoticons/smile.png', $this->_dict->t("Emoticons"), 'id="' . $imgId . '" align="middle"')
                     . '</a>'."\n";
             }
             $html .= '</div><div id="htmlhelper_' . $var->getVarName()
@@ -237,7 +256,7 @@ class Horde_Form_VarRenderer_Xhtml extends Horde_Form_VarRenderer
         $time = $var->type->getTimeParts($var->getValue($vars));
 
         /* Output hours. */
-        $hours = array('' => _("hh"));
+        $hours = array('' => $this->_dict->t("hh"));
         for ($i = 0; $i <= 23; $i++) {
             $hours[sprintf('%02d', $i)] = $i;
         }
@@ -247,7 +266,7 @@ class Horde_Form_VarRenderer_Xhtml extends Horde_Form_VarRenderer
                         $this->_getActionScripts($form, $var));
 
         /* Output minutes. */
-        $minutes = array('' => _("mm"));
+        $minutes = array('' => $this->_dict->t("mm"));
         for ($i = 0; $i <= 59; $i++) {
             $minutes[sprintf('%02d', $i)] = $i;
         }
@@ -259,7 +278,7 @@ class Horde_Form_VarRenderer_Xhtml extends Horde_Form_VarRenderer
         /* Return if seconds are not required. */
         if ($var->type->show_seconds) {
             /* Output seconds. */
-            $seconds = array('' => _("ss"));
+            $seconds = array('' => $this->_dict->t("ss"));
             for ($i = 0; $i <= 59; $i++) {
                 $seconds[sprintf('%02d', $i)] = $i;
             }
@@ -275,20 +294,20 @@ class Horde_Form_VarRenderer_Xhtml extends Horde_Form_VarRenderer
     function _renderVarInput_monthyear($form, $var, $vars)
     {
         $dates = array();
-        $dates['month'] = array('' => _("MM"),
-                                1 => _("January"),
-                                2 => _("February"),
-                                3 => _("March"),
-                                4 => _("April"),
-                                5 => _("May"),
-                                6 => _("June"),
-                                7 => _("July"),
-                                8 => _("August"),
-                                9 => _("September"),
-                                10 => _("October"),
-                                11 => _("November"),
-                                12 => _("December"));
-        $dates['year'] = array('' => _("YYYY"));
+        $dates['month'] = array('' => $this->_dict->t("MM"),
+                                1 => $this->_dict->t("January"),
+                                2 => $this->_dict->t("February"),
+                                3 => $this->_dict->t("March"),
+                                4 => $this->_dict->t("April"),
+                                5 => $this->_dict->t("May"),
+                                6 => $this->_dict->t("June"),
+                                7 => $this->_dict->t("July"),
+                                8 => $this->_dict->t("August"),
+                                9 => $this->_dict->t("September"),
+                                10 => $this->_dict->t("October"),
+                                11 => $this->_dict->t("November"),
+                                12 => $this->_dict->t("December"));
+        $dates['year'] = array('' => $this->_dict->t("YYYY"));
         if ($var->type->start_year > $var->type->end_year) {
             for ($i = $var->type->start_year; $i >= $var->type->end_year; $i--) {
                 $dates['year'][$i] = $i;
@@ -314,24 +333,24 @@ class Horde_Form_VarRenderer_Xhtml extends Horde_Form_VarRenderer
     function _renderVarInput_monthdayyear($form, $var, $vars)
     {
         $dates = array();
-        $dates['month'] = array(''   => _("MM"),
-                                '1'  => _("January"),
-                                '2'  => _("February"),
-                                '3'  => _("March"),
-                                '4'  => _("April"),
-                                '5'  => _("May"),
-                                '6'  => _("June"),
-                                '7'  => _("July"),
-                                '8'  => _("August"),
-                                '9'  => _("September"),
-                                '10' => _("October"),
-                                '11' => _("November"),
-                                '12' => _("December"));
-        $dates['day'] = array('' => _("DD"));
+        $dates['month'] = array(''   => $this->_dict->t("MM"),
+                                '1'  => $this->_dict->t("January"),
+                                '2'  => $this->_dict->t("February"),
+                                '3'  => $this->_dict->t("March"),
+                                '4'  => $this->_dict->t("April"),
+                                '5'  => $this->_dict->t("May"),
+                                '6'  => $this->_dict->t("June"),
+                                '7'  => $this->_dict->t("July"),
+                                '8'  => $this->_dict->t("August"),
+                                '9'  => $this->_dict->t("September"),
+                                '10' => $this->_dict->t("October"),
+                                '11' => $this->_dict->t("November"),
+                                '12' => $this->_dict->t("December"));
+        $dates['day'] = array('' => $this->_dict->t("DD"));
         for ($i = 1; $i <= 31; $i++) {
             $dates['day'][$i] = $i;
         }
-        $dates['year'] = array('' => _("YYYY"));
+        $dates['year'] = array('' => $this->_dict->t("YYYY"));
         if ($var->type->start_year > $var->type->end_year) {
             for ($i = $var->type->start_year; $i >= $var->type->end_year; $i--) {
                 $dates['year'][$i] = $i;
@@ -376,8 +395,8 @@ class Horde_Form_VarRenderer_Xhtml extends Horde_Form_VarRenderer
             $html .= Horde::img('blank.gif', '', array('class' => 'form-colorpicker-preview',
                                                        'id' => 'colordemo_' . $var->getVarName(),
                                                        'style' => 'background:' . $var->getValue($vars)))
-                . Horde::link('#', _("Color Picker"), '', '', 'openColorPicker(\''. $var->getVarName() .'\'); return false;')
-                . Horde::img('colorpicker.png', _("Color Picker")) . '</a>'
+                . Horde::link('#', $this->_dict->t("Color Picker"), '', '', 'openColorPicker(\''. $var->getVarName() .'\'); return false;')
+                . Horde::img('colorpicker.png', $this->_dict->t("Color Picker")) . '</a>'
                 . '<div id="colorpicker_' . $var->getVarName() . '" class="form-colorpicker-palette"></div>';
         }
 
@@ -400,11 +419,11 @@ class Horde_Form_VarRenderer_Xhtml extends Horde_Form_VarRenderer
             . '[list]" onchange="' . $instance . '.deselectHeader();" '
             . ' id="'. $varname . '-list-">'
             . $var->type->getOptions($var->getValue($vars)) . '    </select><div class="leftFloat">'
-            . Horde::link('#', _("Move up"), '', '', $instance . '.moveColumnUp(); return false;')
-                . Horde::img('nav/up.png', _("Move up"))
+            . Horde::link('#', $this->_dict->t("Move up"), '', '', $instance . '.moveColumnUp(); return false;')
+                . Horde::img('nav/up.png', $this->_dict->t("Move up"))
                 . '</a><br />'
-            . Horde::link('#', _("Move up"), '', '', $instance . '.moveColumnDown(); return false;')
-                . Horde::img('nav/down.png', _("Move down"))
+            . Horde::link('#', $this->_dict->t("Move up"), '', '', $instance . '.moveColumnDown(); return false;')
+                . Horde::img('nav/down.png', $this->_dict->t("Move down"))
                 . '</a></div>'
             . '<script type="text/javascript">' . "\n"
             . sprintf('%1$s = new Horde_Form_Sorter(\'%1$s\', \'%2$s\', \'%3$s\');' . "\n",
@@ -434,10 +453,10 @@ class Horde_Form_VarRenderer_Xhtml extends Horde_Form_VarRenderer
              . $var->type->getOptions(0, $fname)
              . '    </select>'
              . '<div><a href="" onclick="Horde_Form_Assign.move(\''. $fname .'\', 0); return false;">'
-             . Horde::img('rhand.png', _("Add column"))
+             . Horde::img('rhand.png', $this->_dict->t("Add column"))
              . '</a><br /><a href="" onclick="Horde_Form_Assign.move(\''
              . $fname . '\', 1); return false;">'
-             . Horde::img('lhand.png', _("Remove column"))
+             . Horde::img('lhand.png', $this->_dict->t("Remove column"))
              . '</a></div>'
              . sprintf('    <select name="%s__right" multiple="multiple" size="%d" style="width:%s"%s>',
                      $name, $size, $width,
@@ -529,7 +548,7 @@ class Horde_Form_VarRenderer_Xhtml extends Horde_Form_VarRenderer
                         $this->_getActionScripts($form, $var),
                         $this->_multiSelectOptions($values, $selected));
         return $html . '<p class="form-hint">'
-            . _("To select multiple items, hold down the Control (PC) or Command (Mac) key while clicking.")
+            . $this->_dict->t("To select multiple items, hold down the Control (PC) or Command (Mac) key while clicking.")
             . "</p>\n";
     }
 
@@ -557,9 +576,9 @@ class Horde_Form_VarRenderer_Xhtml extends Horde_Form_VarRenderer
             $form_name = $form->getName();
             $var_name = $var->getVarName() . '[]';
             $function_name = 'select'  . $form_name . $var->getVarName();
-            $enable = _("Select all");
-            $disable = _("Select none");
-            $invert = _("Invert selection");
+            $enable = $this->_dict->t("Select all");
+            $disable = $this->_dict->t("Select none");
+            $invert = $this->_dict->t("Invert selection");
             $html .= <<<EOT
 <script type="text/javascript">
 function $function_name()
@@ -628,7 +647,7 @@ EOT;
                 $html .= sprintf('    <select%s name="%s[n][r]"><option value="">%s</option>%s    </select><br />'."\n",
                        ' id="'. $varname .'-n--r-"',
                        $varname,
-                       _("-- select --"),
+                       $this->_dict->t("-- select --"),
                        $this->_selectOptions($new_input, $var_array['n']['r']));
             } elseif ($new_input == true) {
                 $html .= sprintf('    <input%s type="text" name="%s[n][r]" value="%s" />',
@@ -755,7 +774,7 @@ EOT;
         if ($GLOBALS['browser']->hasFeature('javascript')) {
             $imgId = $varname .'goto';
             $html .= '<div id="goto" class="headerbox" style="position:absolute;visibility:hidden;padding:0"></div>';
-            $html .= Horde::link('#', _("Select an object"), '', '', 'obrowserWindow = ' . Horde::popupJs($GLOBALS['registry']->get('webroot', 'horde') . '/services/obrowser/') . 'obrowserWindowName = obrowserWindow.name; return false;') . Horde::img('tree/leaf.png', _("Object"), 'id="' . $imgId . '" align="middle"') . "</a>\n";
+            $html .= Horde::link('#', $this->_dict->t("Select an object"), '', '', 'obrowserWindow = ' . Horde::popupJs($GLOBALS['registry']->get('webroot', 'horde') . '/services/obrowser/') . 'obrowserWindowName = obrowserWindow.name; return false;') . Horde::img('tree/leaf.png', $this->_dict->t("Object"), 'id="' . $imgId . '" align="middle"') . "</a>\n";
         }
 
         return $html;
@@ -772,7 +791,7 @@ EOT;
                        $var->getVarName(),
                        strlen($var->type->text),
                        htmlspecialchars($var->getValue($vars))) .
-            '<p class="form-input-figlet">' . _("Enter the letters below:") . '</p>' .
+            '<p class="form-input-figlet">' . $this->_dict->t("Enter the letters below:") . '</p>' .
             $this->_renderVarDisplay_figlet($form, $var, $vars);
     }
 
@@ -843,7 +862,7 @@ EOT;
 
     function _renderVarDisplay_boolean($form, $var, $vars)
     {
-        return $var->getValue($vars) ? _("Yes") : _("No");
+        return $var->getValue($vars) ? $this->_dict->t("Yes") : $this->_dict->t("No");
     }
 
     function _renderVarDisplay_enum($form, $var, $vars)
@@ -851,7 +870,7 @@ EOT;
         $values = $var->getValues();
         $value = $var->getValue($vars);
         if (count($values) == 0) {
-            return _("No values");
+            return $this->_dict->t("No values");
         } elseif (isset($values[$value]) && $value != '') {
             return htmlspecialchars($values[$value]);
         }
@@ -861,7 +880,7 @@ EOT;
     {
         $values = $var->getValues();
         if (count($values) == 0) {
-            return _("No values");
+            return $this->_dict->t("No values");
         } elseif (isset($values[$var->getValue($vars)])) {
             return htmlspecialchars($values[$var->getValue($vars)]);
         }
@@ -872,7 +891,7 @@ EOT;
         $values = $var->getValues();
         $on = $var->getValue($vars);
         if (!count($values) || !count($on)) {
-            return _("No values");
+            return $this->_dict->t("No values");
         } else {
             $display = array();
             foreach ($values as $value => $name) {
@@ -889,7 +908,7 @@ EOT;
         $values = $var->getValues();
         $on = $var->getValue($vars);
         if (!count($values) || !count($on)) {
-            return _("No values");
+            return $this->_dict->t("No values");
         } else {
             $display = array();
             foreach ($values as $value => $name) {
@@ -910,7 +929,7 @@ EOT;
 
         if ($number && $registry->hasMethod('telephony/dial')) {
             $url = $registry->call('telephony/dial', array($number));
-            $label = sprintf(_("Dial %s"), $number);
+            $label = sprintf($this->_dict->t("Dial %s"), $number);
             $html .= ' ' . Horde::link($url, $label) . Horde::img('phone.png', $label) . '</a>';
         }
 
@@ -926,7 +945,7 @@ EOT;
         $number = $var->getValue($vars);
         if ($number && $registry->hasMethod('sms/compose')) {
             $url = $registry->link('sms/compose', array('to' => $number));
-            $html .= ' ' . Horde::link($url, _("Send SMS")) . Horde::img('mobile.png', _("Send SMS")) . '</a>';
+            $html .= ' ' . Horde::link($url, $this->_dict->t("Send SMS")) . Horde::img('mobile.png', $this->_dict->t("Send SMS")) . '</a>';
         }
 
         return $html;
@@ -942,13 +961,13 @@ EOT;
             /* UK postcode detected. */
             /* Multimap.co.uk generated map */
             $mapurl = 'http://www.multimap.com/map/browse.cgi?pc=' . urlencode($postcode[1]);
-            $desc = _("Multimap UK map");
+            $desc = $this->_dict->t("Multimap UK map");
             $icon = 'map.png';
         } elseif (preg_match('/ACT|NSW|NT|QLD|SA|TAS|VIC|WA/', $address)) {
             /* Australian state detected. */
             /* Whereis.com.au generated map */
             $mapurl = 'http://www.whereis.com.au/whereis/mapping/geocodeAddress.do?';
-            $desc = _("Whereis Australia map");
+            $desc = $this->_dict->t("Whereis Australia map");
             $icon = 'map.png';
             /* Split out the address, line-by-line. */
             $addressLines = explode("\n", $address);
@@ -971,7 +990,7 @@ EOT;
             /* American/Canadian address style. */
             /* Mapquest generated map */
             $mapurl = 'http://www.mapquest.com/maps/map.adp?size=big&zoom=7';
-            $desc = _("MapQuest map");
+            $desc = $this->_dict->t("MapQuest map");
             $icon = 'map.png';
             $country = null;
             if (!empty($addressParts[4]) && preg_match('|[a-zA-Z]\d[a-zA-Z]\s?\d[a-zA-Z]\d|', $addressParts[4])) {
@@ -995,7 +1014,7 @@ EOT;
 
             /* Yahoo! generated map. */
             $mapurl2 = 'http://us.rd.yahoo.com/maps/home/submit_a/*-http://maps.yahoo.com/maps?srchtype=a&getmap=Get+Map&';
-            $desc2 = _("Yahoo! map");
+            $desc2 = $this->_dict->t("Yahoo! map");
             $icon2 = 'map.png';
             if (!empty($addressParts[1])) {
                 $mapurl2 .= '&addr=' . urlencode($addressParts[1]);
@@ -1015,7 +1034,7 @@ EOT;
 
             /* Google generated map. */
             $mapurl3 = 'http://maps.google.com/maps?q=' . urlencode($addressParts[0]) . '&hl=en';
-            $desc3 = _("Google Maps");
+            $desc3 = $this->_dict->t("Google Maps");
             $icon3 = 'map.png';
 
         } elseif (preg_match('/(.*?)\r?\n([A-Z]{1,3})-(\d{5})\s+(.*)/i', $address, $addressParts)) {
@@ -1040,7 +1059,7 @@ EOT;
                     $mirror = 'uk';
                 }
                 $mapurl = 'http://www.' . $mirror . '.map24.com/source/address/v2.0.0/cnt_nav_maplet.php?cid=validateaddr&country=' . $country;
-                $desc = _("Map24 map");
+                $desc = $this->_dict->t("Map24 map");
                 $icon = 'map_eu.png';
                 if (!empty($addressParts[1])) {
                     $mapurl .= '&street=' . urlencode($addressParts[1]);
@@ -1055,7 +1074,7 @@ EOT;
 
             /* Mapquest generated map. */
             $mapurl2 = 'http://www.mapquest.com/maps/map.adp?country=' . Horde_String::upper($country);
-            $desc2 = _("MapQuest map");
+            $desc2 = $this->_dict->t("MapQuest map");
             $icon2 = 'map_eu.png';
             if (!empty($addressParts[1])) {
                 $mapurl2 .= '&address=' . urlencode($addressParts[1]);
@@ -1196,7 +1215,7 @@ EOT;
                     if ($GLOBALS['registry']->hasMethod('files/getViewLink')) {
                         $filename = basename($filename);
                         $url = $GLOBALS['registry']->call('files/getViewLink', array($dir, $filename));
-                        $filename = Horde::link($url, _("Preview"), null, 'form_file_view') . htmlspecialchars(Horde_Util::realPath($dir . '/' . $filename), ENT_QUOTES, $this->_charset) . '</a>';
+                        $filename = Horde::link($url, $this->_dict->t("Preview"), null, 'form_file_view') . htmlspecialchars(Horde_Util::realPath($dir . '/' . $filename), ENT_QUOTES, $this->_charset) . '</a>';
                     } else {
                         if (!empty($dir) && ($dir != '.')) {
                             $filename = $dir . '/' . $filename;
index 3c2f050..a88c4ca 100644 (file)
@@ -65,6 +65,13 @@ class Net_IMSP {
     var $_logBuffer                  = array();
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor function.
      *
      * @param array $params Hash containing server parameters.
@@ -74,11 +81,14 @@ class Net_IMSP {
         if (is_array($params) && !empty($params['server'])) {
             $this->imsp_server = $params['server'];
         }
-
         if (is_array($params) && !empty($params['port'])) {
             $this->imsp_port = $params['port'];
         }
-
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Net_IMSP', dirname(__FILE__) . '/locale');
+        }
     }
 
     /**
@@ -445,7 +455,7 @@ class Net_IMSP {
             return new $class($params);
         }
 
-         throw new Horde_Exception(sprintf(_("Unable to load the definition of %s."), $class));
+         throw new Horde_Exception(sprintf($this->_dict->t("Unable to load the definition of %s."), $class));
     }
 
     /**
index 62a880b..7ca6069 100644 (file)
@@ -27,6 +27,29 @@ class Net_IMSP_Auth {
      */
     var $_imsp;
 
+    /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
+     * Constructor function.
+     *
+     * @param array $params  Hash with configuration data. Possible values:
+     *                       - 'translation': A translation handler
+     *                                        implementing Horde_Translation.
+     */
+    public function __construct($params = array())
+    {
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Net_IMSP', dirname(__FILE__) . '/../locale');
+        }
+    }
+
      /**
      * Attempts to login to IMSP server.
      *
@@ -118,7 +141,7 @@ class Net_IMSP_Auth {
             return new $class();
         }
 
-        throw new Horde_Exception(sprintf(_("Unable to load the definition of %s."), $class));
+        throw new Horde_Exception(sprintf($this->_dict->t("Unable to load the definition of %s."), $class));
     }
 
     /**
index 15edb68..82ae4f9 100644 (file)
@@ -50,6 +50,13 @@ class Net_IMSP_Book {
     var $_params;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor function.
      *
      * @param array $params Hash containing IMSP parameters.
@@ -57,6 +64,11 @@ class Net_IMSP_Book {
     function Net_IMSP_Book($params)
     {
         $this->_params = $params;
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Net_IMSP', dirname(__FILE__) . '/../locale');
+        }
     }
 
     /**
@@ -1293,7 +1305,7 @@ class Net_IMSP_Book {
         if (isset($this->_imsp)) {
             return $this->_imsp->setLogger($params);
         } else {
-            return PEAR::raiseError(_("The IMSP log could not be initialized."));
+            return PEAR::raiseError($this->_dict->t("The IMSP log could not be initialized."));
         }
     }
 
index ec9493a..911ed77 100644 (file)
  *
  * @package Horde_Nls
  */
+$dict = new Horde_Translation_Gettext('Horde_Nls', dirname(__FILE__) . '/../../../locale');
+
 $countries = array(
-    'AF' => _("Afghanistan"),
-    'AL' => _("Albania"),
-    'DZ' => _("Algeria"),
-    'AS' => _("American Samoa"),
-    'AD' => _("Andorra"),
-    'AO' => _("Angola"),
-    'AI' => _("Anguilla"),
-    'AQ' => _("Antarctica"),
-    'AG' => _("Antigua and Barbuda"),
-    'AR' => _("Argentina"),
-    'AM' => _("Armenia"),
-    'AW' => _("Aruba"),
-    'AU' => _("Australia"),
-    'AT' => _("Austria"),
-    'AZ' => _("Azerbaijan"),
-    'BS' => _("Bahamas"),
-    'BH' => _("Bahrain"),
-    'BD' => _("Bangladesh"),
-    'BB' => _("Barbados"),
-    'BY' => _("Belarus"),
-    'BE' => _("Belgium"),
-    'BZ' => _("Belize"),
-    'BJ' => _("Benin"),
-    'BM' => _("Bermuda"),
-    'BT' => _("Bhutan"),
-    'BO' => _("Bolivia"),
-    'BA' => _("Bosnia and Herzegovina"),
-    'BW' => _("Botswana"),
-    'BV' => _("Bouvet Island"),
-    'BR' => _("Brazil"),
-    'IO' => _("British Indian Ocean Territory"),
-    'BN' => _("Brunei Darussalam"),
-    'BG' => _("Bulgaria"),
-    'BF' => _("Burkina Faso"),
-    'BI' => _("Burundi"),
-    'KH' => _("Cambodia"),
-    'CM' => _("Cameroon"),
-    'CA' => _("Canada"),
-    'CV' => _("Cape Verde"),
-    'KY' => _("Cayman Islands"),
-    'CF' => _("Central African Republic"),
-    'TD' => _("Chad"),
-    'CL' => _("Chile"),
-    'CN' => _("China"),
-    'CX' => _("Christmas Island"),
-    'CC' => _("Cocos (Keeling) Islands"),
-    'CO' => _("Colombia"),
-    'KM' => _("Comoros"),
-    'CG' => _("Congo"),
-    'CD' => _("Congo, The Democratic Republic of the"),
-    'CK' => _("Cook Islands"),
-    'CR' => _("Costa Rica"),
-    'CI' => _("Cote d'Ivoire"),
-    'HR' => _("Croatia"),
-    'CU' => _("Cuba"),
-    'CY' => _("Cyprus"),
-    'CZ' => _("Czech Republic"),
-    'DK' => _("Denmark"),
-    'DJ' => _("Djibouti"),
-    'DM' => _("Dominica"),
-    'DO' => _("Dominican Republic"),
-    'EC' => _("Ecuador"),
-    'EG' => _("Egypt"),
-    'SV' => _("El Salvador"),
-    'GQ' => _("Equatorial Guinea"),
-    'ER' => _("Eritrea"),
-    'EE' => _("Estonia"),
-    'ET' => _("Ethiopia"),
-    'FK' => _("Falkland Islands (Malvinas)"),
-    'FO' => _("Faroe Islands"),
-    'FJ' => _("Fiji"),
-    'FI' => _("Finland"),
-    'FR' => _("France"),
-    'GF' => _("French Guiana"),
-    'PF' => _("French Polynesia"),
-    'TF' => _("French Southern Territories"),
-    'GA' => _("Gabon"),
-    'GM' => _("Gambia"),
-    'GE' => _("Georgia"),
-    'DE' => _("Germany"),
-    'GH' => _("Ghana"),
-    'GI' => _("Gibraltar"),
-    'GR' => _("Greece"),
-    'GL' => _("Greenland"),
-    'GD' => _("Grenada"),
-    'GP' => _("Guadeloupe"),
-    'GU' => _("Guam"),
-    'GT' => _("Guatemala"),
-    'GN' => _("Guinea"),
-    'GW' => _("Guinea-Bissau"),
-    'GY' => _("Guyana"),
-    'HT' => _("Haiti"),
-    'HM' => _("Heard Island and McDonald Islands"),
-    'VA' => _("Holy See (Vatican City State)"),
-    'HN' => _("Honduras"),
-    'HK' => _("Hong Kong"),
-    'HU' => _("Hungary"),
-    'IS' => _("Iceland"),
-    'IN' => _("India"),
-    'ID' => _("Indonesia"),
-    'IR' => _("Iran, Islamic Republic of"),
-    'IQ' => _("Iraq"),
-    'IE' => _("Ireland"),
-    'IL' => _("Israel"),
-    'IT' => _("Italy"),
-    'JM' => _("Jamaica"),
-    'JP' => _("Japan"),
-    'JO' => _("Jordan"),
-    'KZ' => _("Kazakhstan"),
-    'KE' => _("Kenya"),
-    'KI' => _("Kiribati"),
-    'KP' => _("Korea, Democratic People's Republic of"),
-    'KR' => _("Korea, Republic of"),
-    'KW' => _("Kuwait"),
-    'KG' => _("Kyrgyzstan"),
-    'LA' => _("Lao People's Democratic Republic"),
-    'LV' => _("Latvia"),
-    'LB' => _("Lebanon"),
-    'LS' => _("Lesotho"),
-    'LR' => _("Liberia"),
-    'LY' => _("Libyan Arab Jamahiriya"),
-    'LI' => _("Liechtenstein"),
-    'LT' => _("Lithuania"),
-    'LU' => _("Luxembourg"),
-    'MO' => _("Macao"),
-    'MK' => _("Macedonia, The Former Yugoslav Republic of"),
-    'MG' => _("Madagascar"),
-    'MW' => _("Malawi"),
-    'MY' => _("Malaysia"),
-    'MV' => _("Maldives"),
-    'ML' => _("Mali"),
-    'MT' => _("Malta"),
-    'MH' => _("Marshall Islands"),
-    'MQ' => _("Martinique"),
-    'MR' => _("Mauritania"),
-    'MU' => _("Mauritius"),
-    'YT' => _("Mayotte"),
-    'MX' => _("Mexico"),
-    'FM' => _("Micronesia, Federated States of"),
-    'MD' => _("Moldova, Republic of"),
-    'MC' => _("Monaco"),
-    'MN' => _("Mongolia"),
-    'MS' => _("Montserrat"),
-    'MA' => _("Morocco"),
-    'MZ' => _("Mozambique"),
-    'MM' => _("Myanmar"),
-    'NA' => _("Namibia"),
-    'NR' => _("Nauru"),
-    'NP' => _("Nepal"),
-    'NL' => _("Netherlands"),
-    'AN' => _("Netherlands Antilles"),
-    'NC' => _("New Caledonia"),
-    'NZ' => _("New Zealand"),
-    'NI' => _("Nicaragua"),
-    'NE' => _("Niger"),
-    'NG' => _("Nigeria"),
-    'NU' => _("Niue"),
-    'NF' => _("Norfolk Island"),
-    'MP' => _("Northern Mariana Islands"),
-    'NO' => _("Norway"),
-    'OM' => _("Oman"),
-    'PK' => _("Pakistan"),
-    'PW' => _("Palau"),
-    'PS' => _("Palestinian Territory, Occupied"),
-    'PA' => _("Panama"),
-    'PG' => _("Papua New Guinea"),
-    'PY' => _("Paraguay"),
-    'PE' => _("Peru"),
-    'PH' => _("Philippines"),
-    'PN' => _("Pitcairn"),
-    'PL' => _("Poland"),
-    'PT' => _("Portugal"),
-    'PR' => _("Puerto Rico"),
-    'QA' => _("Qatar"),
-    'RE' => _("Reunion"),
-    'RO' => _("Romania"),
-    'RU' => _("Russian Federation"),
-    'RW' => _("Rwanda"),
-    'SH' => _("Saint Helena"),
-    'KN' => _("Saint Kitts and Nevis"),
-    'LC' => _("Saint Lucia"),
-    'PM' => _("Saint Pierre and Miquelon"),
-    'VC' => _("Saint Vincent and the Grenadines"),
-    'WS' => _("Samoa"),
-    'SM' => _("San Marino"),
-    'ST' => _("Sao Tome and Principe"),
-    'SA' => _("Saudi Arabia"),
-    'SN' => _("Senegal"),
-    'CS' => _("Serbia and Montenegro"),
-    'SC' => _("Seychelles"),
-    'SL' => _("Sierra Leone"),
-    'SG' => _("Singapore"),
-    'SK' => _("Slovakia"),
-    'SI' => _("Slovenia"),
-    'SB' => _("Solomon Islands"),
-    'SO' => _("Somalia"),
-    'ZA' => _("South Africa"),
-    'GS' => _("South Georgia and the South Sandwich Islands"),
-    'ES' => _("Spain"),
-    'LK' => _("Sri Lanka"),
-    'SD' => _("Sudan"),
-    'SR' => _("Suriname"),
-    'SJ' => _("Svalbard and Jan Mayen"),
-    'SZ' => _("Swaziland"),
-    'SE' => _("Sweden"),
-    'CH' => _("Switzerland"),
-    'SY' => _("Syrian Arab Republic"),
-    'TW' => _("Taiwan, Province of China"),
-    'TJ' => _("Tajikistan"),
-    'TZ' => _("Tanzania, United Republic of"),
-    'TH' => _("Thailand"),
-    'TL' => _("Timor-Leste"),
-    'TG' => _("Togo"),
-    'TK' => _("Tokelau"),
-    'TO' => _("Tonga"),
-    'TT' => _("Trinidad and Tobago"),
-    'TN' => _("Tunisia"),
-    'TR' => _("Turkey"),
-    'TM' => _("Turkmenistan"),
-    'TC' => _("Turks and Caicos Islands"),
-    'TV' => _("Tuvalu"),
-    'UG' => _("Uganda"),
-    'UA' => _("Ukraine"),
-    'AE' => _("United Arab Emirates"),
-    'GB' => _("United Kingdom"),
-    'US' => _("United States"),
-    'UM' => _("United States Minor Outlying Islands"),
-    'UY' => _("Uruguay"),
-    'UZ' => _("Uzbekistan"),
-    'VU' => _("Vanuatu"),
-    'VE' => _("Venezuela"),
-    'VN' => _("Viet Nam"),
-    'VG' => _("Virgin Islands, British"),
-    'VI' => _("Virgin Islands, U.S."),
-    'WF' => _("Wallis and Futuna"),
-    'EH' => _("Western Sahara"),
-    'YE' => _("Yemen"),
-    'ZM' => _("Zambia"),
-    'ZW' => _("Zimbabwe")
+    'AF' => $dict->t("Afghanistan"),
+    'AL' => $dict->t("Albania"),
+    'DZ' => $dict->t("Algeria"),
+    'AS' => $dict->t("American Samoa"),
+    'AD' => $dict->t("Andorra"),
+    'AO' => $dict->t("Angola"),
+    'AI' => $dict->t("Anguilla"),
+    'AQ' => $dict->t("Antarctica"),
+    'AG' => $dict->t("Antigua and Barbuda"),
+    'AR' => $dict->t("Argentina"),
+    'AM' => $dict->t("Armenia"),
+    'AW' => $dict->t("Aruba"),
+    'AU' => $dict->t("Australia"),
+    'AT' => $dict->t("Austria"),
+    'AZ' => $dict->t("Azerbaijan"),
+    'BS' => $dict->t("Bahamas"),
+    'BH' => $dict->t("Bahrain"),
+    'BD' => $dict->t("Bangladesh"),
+    'BB' => $dict->t("Barbados"),
+    'BY' => $dict->t("Belarus"),
+    'BE' => $dict->t("Belgium"),
+    'BZ' => $dict->t("Belize"),
+    'BJ' => $dict->t("Benin"),
+    'BM' => $dict->t("Bermuda"),
+    'BT' => $dict->t("Bhutan"),
+    'BO' => $dict->t("Bolivia"),
+    'BA' => $dict->t("Bosnia and Herzegovina"),
+    'BW' => $dict->t("Botswana"),
+    'BV' => $dict->t("Bouvet Island"),
+    'BR' => $dict->t("Brazil"),
+    'IO' => $dict->t("British Indian Ocean Territory"),
+    'BN' => $dict->t("Brunei Darussalam"),
+    'BG' => $dict->t("Bulgaria"),
+    'BF' => $dict->t("Burkina Faso"),
+    'BI' => $dict->t("Burundi"),
+    'KH' => $dict->t("Cambodia"),
+    'CM' => $dict->t("Cameroon"),
+    'CA' => $dict->t("Canada"),
+    'CV' => $dict->t("Cape Verde"),
+    'KY' => $dict->t("Cayman Islands"),
+    'CF' => $dict->t("Central African Republic"),
+    'TD' => $dict->t("Chad"),
+    'CL' => $dict->t("Chile"),
+    'CN' => $dict->t("China"),
+    'CX' => $dict->t("Christmas Island"),
+    'CC' => $dict->t("Cocos (Keeling) Islands"),
+    'CO' => $dict->t("Colombia"),
+    'KM' => $dict->t("Comoros"),
+    'CG' => $dict->t("Congo"),
+    'CD' => $dict->t("Congo, The Democratic Republic of the"),
+    'CK' => $dict->t("Cook Islands"),
+    'CR' => $dict->t("Costa Rica"),
+    'CI' => $dict->t("Cote d'Ivoire"),
+    'HR' => $dict->t("Croatia"),
+    'CU' => $dict->t("Cuba"),
+    'CY' => $dict->t("Cyprus"),
+    'CZ' => $dict->t("Czech Republic"),
+    'DK' => $dict->t("Denmark"),
+    'DJ' => $dict->t("Djibouti"),
+    'DM' => $dict->t("Dominica"),
+    'DO' => $dict->t("Dominican Republic"),
+    'EC' => $dict->t("Ecuador"),
+    'EG' => $dict->t("Egypt"),
+    'SV' => $dict->t("El Salvador"),
+    'GQ' => $dict->t("Equatorial Guinea"),
+    'ER' => $dict->t("Eritrea"),
+    'EE' => $dict->t("Estonia"),
+    'ET' => $dict->t("Ethiopia"),
+    'FK' => $dict->t("Falkland Islands (Malvinas)"),
+    'FO' => $dict->t("Faroe Islands"),
+    'FJ' => $dict->t("Fiji"),
+    'FI' => $dict->t("Finland"),
+    'FR' => $dict->t("France"),
+    'GF' => $dict->t("French Guiana"),
+    'PF' => $dict->t("French Polynesia"),
+    'TF' => $dict->t("French Southern Territories"),
+    'GA' => $dict->t("Gabon"),
+    'GM' => $dict->t("Gambia"),
+    'GE' => $dict->t("Georgia"),
+    'DE' => $dict->t("Germany"),
+    'GH' => $dict->t("Ghana"),
+    'GI' => $dict->t("Gibraltar"),
+    'GR' => $dict->t("Greece"),
+    'GL' => $dict->t("Greenland"),
+    'GD' => $dict->t("Grenada"),
+    'GP' => $dict->t("Guadeloupe"),
+    'GU' => $dict->t("Guam"),
+    'GT' => $dict->t("Guatemala"),
+    'GN' => $dict->t("Guinea"),
+    'GW' => $dict->t("Guinea-Bissau"),
+    'GY' => $dict->t("Guyana"),
+    'HT' => $dict->t("Haiti"),
+    'HM' => $dict->t("Heard Island and McDonald Islands"),
+    'VA' => $dict->t("Holy See (Vatican City State)"),
+    'HN' => $dict->t("Honduras"),
+    'HK' => $dict->t("Hong Kong"),
+    'HU' => $dict->t("Hungary"),
+    'IS' => $dict->t("Iceland"),
+    'IN' => $dict->t("India"),
+    'ID' => $dict->t("Indonesia"),
+    'IR' => $dict->t("Iran, Islamic Republic of"),
+    'IQ' => $dict->t("Iraq"),
+    'IE' => $dict->t("Ireland"),
+    'IL' => $dict->t("Israel"),
+    'IT' => $dict->t("Italy"),
+    'JM' => $dict->t("Jamaica"),
+    'JP' => $dict->t("Japan"),
+    'JO' => $dict->t("Jordan"),
+    'KZ' => $dict->t("Kazakhstan"),
+    'KE' => $dict->t("Kenya"),
+    'KI' => $dict->t("Kiribati"),
+    'KP' => $dict->t("Korea, Democratic People's Republic of"),
+    'KR' => $dict->t("Korea, Republic of"),
+    'KW' => $dict->t("Kuwait"),
+    'KG' => $dict->t("Kyrgyzstan"),
+    'LA' => $dict->t("Lao People's Democratic Republic"),
+    'LV' => $dict->t("Latvia"),
+    'LB' => $dict->t("Lebanon"),
+    'LS' => $dict->t("Lesotho"),
+    'LR' => $dict->t("Liberia"),
+    'LY' => $dict->t("Libyan Arab Jamahiriya"),
+    'LI' => $dict->t("Liechtenstein"),
+    'LT' => $dict->t("Lithuania"),
+    'LU' => $dict->t("Luxembourg"),
+    'MO' => $dict->t("Macao"),
+    'MK' => $dict->t("Macedonia, The Former Yugoslav Republic of"),
+    'MG' => $dict->t("Madagascar"),
+    'MW' => $dict->t("Malawi"),
+    'MY' => $dict->t("Malaysia"),
+    'MV' => $dict->t("Maldives"),
+    'ML' => $dict->t("Mali"),
+    'MT' => $dict->t("Malta"),
+    'MH' => $dict->t("Marshall Islands"),
+    'MQ' => $dict->t("Martinique"),
+    'MR' => $dict->t("Mauritania"),
+    'MU' => $dict->t("Mauritius"),
+    'YT' => $dict->t("Mayotte"),
+    'MX' => $dict->t("Mexico"),
+    'FM' => $dict->t("Micronesia, Federated States of"),
+    'MD' => $dict->t("Moldova, Republic of"),
+    'MC' => $dict->t("Monaco"),
+    'MN' => $dict->t("Mongolia"),
+    'MS' => $dict->t("Montserrat"),
+    'MA' => $dict->t("Morocco"),
+    'MZ' => $dict->t("Mozambique"),
+    'MM' => $dict->t("Myanmar"),
+    'NA' => $dict->t("Namibia"),
+    'NR' => $dict->t("Nauru"),
+    'NP' => $dict->t("Nepal"),
+    'NL' => $dict->t("Netherlands"),
+    'AN' => $dict->t("Netherlands Antilles"),
+    'NC' => $dict->t("New Caledonia"),
+    'NZ' => $dict->t("New Zealand"),
+    'NI' => $dict->t("Nicaragua"),
+    'NE' => $dict->t("Niger"),
+    'NG' => $dict->t("Nigeria"),
+    'NU' => $dict->t("Niue"),
+    'NF' => $dict->t("Norfolk Island"),
+    'MP' => $dict->t("Northern Mariana Islands"),
+    'NO' => $dict->t("Norway"),
+    'OM' => $dict->t("Oman"),
+    'PK' => $dict->t("Pakistan"),
+    'PW' => $dict->t("Palau"),
+    'PS' => $dict->t("Palestinian Territory, Occupied"),
+    'PA' => $dict->t("Panama"),
+    'PG' => $dict->t("Papua New Guinea"),
+    'PY' => $dict->t("Paraguay"),
+    'PE' => $dict->t("Peru"),
+    'PH' => $dict->t("Philippines"),
+    'PN' => $dict->t("Pitcairn"),
+    'PL' => $dict->t("Poland"),
+    'PT' => $dict->t("Portugal"),
+    'PR' => $dict->t("Puerto Rico"),
+    'QA' => $dict->t("Qatar"),
+    'RE' => $dict->t("Reunion"),
+    'RO' => $dict->t("Romania"),
+    'RU' => $dict->t("Russian Federation"),
+    'RW' => $dict->t("Rwanda"),
+    'SH' => $dict->t("Saint Helena"),
+    'KN' => $dict->t("Saint Kitts and Nevis"),
+    'LC' => $dict->t("Saint Lucia"),
+    'PM' => $dict->t("Saint Pierre and Miquelon"),
+    'VC' => $dict->t("Saint Vincent and the Grenadines"),
+    'WS' => $dict->t("Samoa"),
+    'SM' => $dict->t("San Marino"),
+    'ST' => $dict->t("Sao Tome and Principe"),
+    'SA' => $dict->t("Saudi Arabia"),
+    'SN' => $dict->t("Senegal"),
+    'CS' => $dict->t("Serbia and Montenegro"),
+    'SC' => $dict->t("Seychelles"),
+    'SL' => $dict->t("Sierra Leone"),
+    'SG' => $dict->t("Singapore"),
+    'SK' => $dict->t("Slovakia"),
+    'SI' => $dict->t("Slovenia"),
+    'SB' => $dict->t("Solomon Islands"),
+    'SO' => $dict->t("Somalia"),
+    'ZA' => $dict->t("South Africa"),
+    'GS' => $dict->t("South Georgia and the South Sandwich Islands"),
+    'ES' => $dict->t("Spain"),
+    'LK' => $dict->t("Sri Lanka"),
+    'SD' => $dict->t("Sudan"),
+    'SR' => $dict->t("Suriname"),
+    'SJ' => $dict->t("Svalbard and Jan Mayen"),
+    'SZ' => $dict->t("Swaziland"),
+    'SE' => $dict->t("Sweden"),
+    'CH' => $dict->t("Switzerland"),
+    'SY' => $dict->t("Syrian Arab Republic"),
+    'TW' => $dict->t("Taiwan, Province of China"),
+    'TJ' => $dict->t("Tajikistan"),
+    'TZ' => $dict->t("Tanzania, United Republic of"),
+    'TH' => $dict->t("Thailand"),
+    'TL' => $dict->t("Timor-Leste"),
+    'TG' => $dict->t("Togo"),
+    'TK' => $dict->t("Tokelau"),
+    'TO' => $dict->t("Tonga"),
+    'TT' => $dict->t("Trinidad and Tobago"),
+    'TN' => $dict->t("Tunisia"),
+    'TR' => $dict->t("Turkey"),
+    'TM' => $dict->t("Turkmenistan"),
+    'TC' => $dict->t("Turks and Caicos Islands"),
+    'TV' => $dict->t("Tuvalu"),
+    'UG' => $dict->t("Uganda"),
+    'UA' => $dict->t("Ukraine"),
+    'AE' => $dict->t("United Arab Emirates"),
+    'GB' => $dict->t("United Kingdom"),
+    'US' => $dict->t("United States"),
+    'UM' => $dict->t("United States Minor Outlying Islands"),
+    'UY' => $dict->t("Uruguay"),
+    'UZ' => $dict->t("Uzbekistan"),
+    'VU' => $dict->t("Vanuatu"),
+    'VE' => $dict->t("Venezuela"),
+    'VN' => $dict->t("Viet Nam"),
+    'VG' => $dict->t("Virgin Islands, British"),
+    'VI' => $dict->t("Virgin Islands, U.S."),
+    'WF' => $dict->t("Wallis and Futuna"),
+    'EH' => $dict->t("Western Sahara"),
+    'YE' => $dict->t("Yemen"),
+    'ZM' => $dict->t("Zambia"),
+    'ZW' => $dict->t("Zimbabwe")
 );
 
 asort($countries, SORT_LOCALE_STRING);
index 156b6d8..d4fa911 100644 (file)
@@ -76,12 +76,26 @@ class Horde_Nls_Geoip
     protected $_fh;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor.
      *
-     * @param string $datafile  The location of the GeoIP database.
+     * @param string $datafile         The location of the GeoIP database.
+     * @param Horde_Translation $dict  A translation handler implementing
+     *                                 Horde_Translation.
      */
-    public function __construct($datafile)
+    public function __construct($datafile, $dict = null)
     {
+        if ($dict) {
+            $this->_dict = $dict;
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Nls', dirname(__FILE__) . '/../../../locale');
+        }
         $this->_datafile = $datafile;
     }
 
@@ -321,11 +335,11 @@ class Horde_Nls_Geoip
         $code = Horde_String::upper($code);
 
         $geoip_codes = array(
-            'AP' => _("Asia/Pacific Region"),
-            'EU' => _("Europe"),
-            'A1' => _("Anonymous Proxy"),
-            'A2' => _("Satellite Provider"),
-            'O1' => _("Other")
+            'AP' => $this->_dict->t("Asia/Pacific Region"),
+            'EU' => $this->_dict->t("Europe"),
+            'A1' => $this->_dict->t("Anonymous Proxy"),
+            'A2' => $this->_dict->t("Satellite Provider"),
+            'O1' => $this->_dict->t("Other")
         );
 
         return isset($geoip_codes[$code])
index 5c60416..b9a1ef1 100644 (file)
  *
  * @package Horde_Nls
  */
+$dict = new Horde_Translation_Gettext('Horde_Nls', dirname(__FILE__) . '/../../../locale');
+
 $tld = array(
-    'ac' => _("Ascension Island"),
-    'ad' => _("Andorra"),
-    'ae' => _("United Arab Emirates"),
-    'af' => _("Afghanistan"),
-    'ag' => _("Antigua and Barbuda"),
-    'ai' => _("Anguilla"),
-    'al' => _("Albania"),
-    'am' => _("Armenia"),
-    'an' => _("Netherlands Antilles"),
-    'ao' => _("Angola"),
-    'aq' => _("Antarctica"),
-    'ar' => _("Argentina"),
-    'as' => _("American Samoa"),
-    'at' => _("Austria"),
-    'au' => _("Australia"),
-    'aw' => _("Aruba"),
-    'ax' => _("Aland Islands"),
-    'az' => _("Azerbaijan"),
-    'ba' => _("Bosnia and Herzegovina"),
-    'bb' => _("Barbados"),
-    'bd' => _("Bangladesh"),
-    'be' => _("Belgium"),
-    'bf' => _("Burkina Faso"),
-    'bg' => _("Bulgaria"),
-    'bh' => _("Bahrain"),
-    'bi' => _("Burundi"),
-    'bj' => _("Benin"),
-    'bm' => _("Bermuda"),
-    'bn' => _("Brunei Darussalam"),
-    'bo' => _("Bolivia"),
-    'br' => _("Brazil"),
-    'bs' => _("Bahamas"),
-    'bt' => _("Bhutan"),
-    'bv' => _("Bouvet Island"),
-    'bw' => _("Botswana"),
-    'by' => _("Belarus"),
-    'bz' => _("Belize"),
-    'ca' => _("Canada"),
-    'cc' => _("Cocos (Keeling) Islands"),
-    'cd' => _("Congo, The Democratic Republic of the"),
-    'cf' => _("Central African Republic"),
-    'cg' => _("Congo, Republic of"),
-    'ch' => _("Switzerland"),
-    'ci' => _("Cote d'Ivoire"),
-    'ck' => _("Cook Islands"),
-    'cl' => _("Chile"),
-    'cm' => _("Cameroon"),
-    'cn' => _("China"),
-    'co' => _("Colombia"),
-    'cr' => _("Costa Rica"),
-    'cu' => _("Cuba"),
-    'cv' => _("Cape Verde"),
-    'cx' => _("Christmas Island"),
-    'cy' => _("Cyprus"),
-    'cz' => _("Czech Republic"),
-    'de' => _("Germany"),
-    'dj' => _("Djibouti"),
-    'dk' => _("Denmark"),
-    'dm' => _("Dominica"),
-    'do' => _("Dominican Republic"),
-    'dz' => _("Algeria"),
-    'ec' => _("Ecuador"),
-    'ee' => _("Estonia"),
-    'eg' => _("Egypt"),
-    'eh' => _("Western Sahara"),
-    'er' => _("Eritrea"),
-    'es' => _("Spain"),
-    'et' => _("Ethiopia"),
-    'eu' => _("European Union"),
-    'fi' => _("Finland"),
-    'fj' => _("Fiji"),
-    'fk' => _("Falkland Islands (Malvinas)"),
-    'fm' => _("Micronesia, Federated States of"),
-    'fo' => _("Faroe Islands"),
-    'fr' => _("France"),
-    'ga' => _("Gabon"),
-    'gb' => _("United Kingdom"),
-    'gd' => _("Grenada"),
-    'ge' => _("Georgia"),
-    'gf' => _("French Guiana"),
-    'gg' => _("Guernsey"),
-    'gh' => _("Ghana"),
-    'gi' => _("Gibraltar"),
-    'gl' => _("Greenland"),
-    'gm' => _("Gambia"),
-    'gn' => _("Guinea"),
-    'gp' => _("Guadeloupe"),
-    'gq' => _("Equatorial Guinea"),
-    'gr' => _("Greece"),
-    'gs' => _("South Georgia and the South Sandwich Islands"),
-    'gt' => _("Guatemala"),
-    'gu' => _("Guam"),
-    'gw' => _("Guinea-Bissau"),
-    'gy' => _("Guyana"),
-    'hk' => _("Hong Kong"),
-    'hm' => _("Heard and McDonald Islands"),
-    'hn' => _("Honduras"),
-    'hr' => _("Croatia/Hrvatska"),
-    'ht' => _("Haiti"),
-    'hu' => _("Hungary"),
-    'id' => _("Indonesia"),
-    'ie' => _("Ireland"),
-    'il' => _("Israel"),
-    'im' => _("Isle of Man"),
-    'in' => _("India"),
-    'io' => _("British Indian Ocean Territory"),
-    'iq' => _("Iraq"),
-    'ir' => _("Iran, Islamic Republic of"),
-    'is' => _("Iceland"),
-    'it' => _("Italy"),
-    'je' => _("Jersey"),
-    'jm' => _("Jamaica"),
-    'jo' => _("Jordan"),
-    'jp' => _("Japan"),
-    'ke' => _("Kenya"),
-    'kg' => _("Kyrgyzstan"),
-    'kh' => _("Cambodia"),
-    'ki' => _("Kiribati"),
-    'km' => _("Comoros"),
-    'kn' => _("Saint Kitts and Nevis"),
-    'kp' => _("Korea, Democratic People's Republic of"),
-    'kr' => _("Korea, Republic of"),
-    'kw' => _("Kuwait"),
-    'ky' => _("Cayman Islands"),
-    'kz' => _("Kazakhstan"),
-    'la' => _("Lao People's Democratic Republic"),
-    'lb' => _("Lebanon"),
-    'lc' => _("Saint Lucia"),
-    'li' => _("Liechtenstein"),
-    'lk' => _("Sri Lanka"),
-    'lr' => _("Liberia"),
-    'ls' => _("Lesotho"),
-    'lt' => _("Lithuania"),
-    'lu' => _("Luxembourg"),
-    'lv' => _("Latvia"),
-    'ly' => _("Libyan Arab Jamahiriya"),
-    'ma' => _("Morocco"),
-    'mc' => _("Monaco"),
-    'md' => _("Moldova, Republic of"),
-    'me' => _("Montenegro"),
-    'mg' => _("Madagascar"),
-    'mh' => _("Marshall Islands"),
-    'mk' => _("Macedonia, The Former Yugoslav Republic of"),
-    'ml' => _("Mali"),
-    'mm' => _("Myanmar"),
-    'mn' => _("Mongolia"),
-    'mo' => _("Macao"),
-    'mp' => _("Northern Mariana Islands"),
-    'mq' => _("Martinique"),
-    'mr' => _("Mauritania"),
-    'ms' => _("Montserrat"),
-    'mt' => _("Malta"),
-    'mu' => _("Mauritius"),
-    'mv' => _("Maldives"),
-    'mw' => _("Malawi"),
-    'mx' => _("Mexico"),
-    'my' => _("Malaysia"),
-    'mz' => _("Mozambique"),
-    'na' => _("Namibia"),
-    'nc' => _("New Caledonia"),
-    'ne' => _("Niger"),
-    'nf' => _("Norfolk Island"),
-    'ng' => _("Nigeria"),
-    'ni' => _("Nicaragua"),
-    'nl' => _("Netherlands"),
-    'no' => _("Norway"),
-    'np' => _("Nepal"),
-    'nr' => _("Nauru"),
-    'nu' => _("Niue"),
-    'nz' => _("New Zealand"),
-    'om' => _("Oman"),
-    'pa' => _("Panama"),
-    'pe' => _("Peru"),
-    'pf' => _("French Polynesia"),
-    'pg' => _("Papua New Guinea"),
-    'ph' => _("Philippines"),
-    'pk' => _("Pakistan"),
-    'pl' => _("Poland"),
-    'pm' => _("Saint Pierre and Miquelon"),
-    'pn' => _("Pitcairn Island"),
-    'pr' => _("Puerto Rico"),
-    'ps' => _("Palestinian Territory, Occupied"),
-    'pt' => _("Portugal"),
-    'pw' => _("Palau"),
-    'py' => _("Paraguay"),
-    'qa' => _("Qatar"),
-    're' => _("Reunion Island"),
-    'ro' => _("Romania"),
-    'rs' => _("Serbia"),
-    'ru' => _("Russian Federation"),
-    'rw' => _("Rwanda"),
-    'sa' => _("Saudi Arabia"),
-    'sb' => _("Solomon Islands"),
-    'sc' => _("Seychelles"),
-    'sd' => _("Sudan"),
-    'se' => _("Sweden"),
-    'sg' => _("Singapore"),
-    'sh' => _("Saint Helena"),
-    'si' => _("Slovenia"),
-    'sj' => _("Svalbard and Jan Mayen Islands"),
-    'sk' => _("Slovakia"),
-    'sl' => _("Sierra Leone"),
-    'sm' => _("San Marino"),
-    'sn' => _("Senegal"),
-    'so' => _("Somalia"),
-    'sr' => _("Suriname"),
-    'st' => _("Sao Tome and Principe"),
-    'su' => _("Soviet Union"),
-    'sv' => _("El Salvador"),
-    'sy' => _("Syrian Arab Republic"),
-    'sz' => _("Swaziland"),
-    'tc' => _("Turks and Caicos Islands"),
-    'td' => _("Chad"),
-    'tf' => _("French Southern Territories"),
-    'tg' => _("Togo"),
-    'th' => _("Thailand"),
-    'tj' => _("Tajikistan"),
-    'tk' => _("Tokelau"),
-    'tl' => _("Timor-Leste"),
-    'tm' => _("Turkmenistan"),
-    'tn' => _("Tunisia"),
-    'to' => _("Tonga"),
-    'tp' => _("East Timor"),
-    'tr' => _("Turkey"),
-    'tt' => _("Trinidad and Tobago"),
-    'tv' => _("Tuvalu"),
-    'tw' => _("Taiwan"),
-    'tz' => _("Tanzania, United Republic of"),
-    'ua' => _("Ukraine"),
-    'ug' => _("Uganda"),
-    'uk' => _("United Kingdom"),
-    'um' => _("United States Minor Outlying Islands"),
-    'us' => _("United States"),
-    'uy' => _("Uruguay"),
-    'uz' => _("Uzbekistan"),
-    'va' => _("Holy See (Vatican City State)"),
-    'vc' => _("Saint Vincent and the Grenadines"),
-    've' => _("Venezuela"),
-    'vg' => _("Virgin Islands, British"),
-    'vi' => _("Virgin Islands, U.S."),
-    'vn' => _("Viet Nam"),
-    'vu' => _("Vanuatu"),
-    'wf' => _("Wallis and Futuna Islands"),
-    'ws' => _("Samoa"),
-    'ye' => _("Yemen"),
-    'yt' => _("Mayotte"),
-    'yu' => _("Yugoslavia"),
-    'za' => _("South Africa"),
-    'zm' => _("Zambia"),
-    'zw' => _("Zimbabwe")
+    'ac' => $dict->t("Ascension Island"),
+    'ad' => $dict->t("Andorra"),
+    'ae' => $dict->t("United Arab Emirates"),
+    'af' => $dict->t("Afghanistan"),
+    'ag' => $dict->t("Antigua and Barbuda"),
+    'ai' => $dict->t("Anguilla"),
+    'al' => $dict->t("Albania"),
+    'am' => $dict->t("Armenia"),
+    'an' => $dict->t("Netherlands Antilles"),
+    'ao' => $dict->t("Angola"),
+    'aq' => $dict->t("Antarctica"),
+    'ar' => $dict->t("Argentina"),
+    'as' => $dict->t("American Samoa"),
+    'at' => $dict->t("Austria"),
+    'au' => $dict->t("Australia"),
+    'aw' => $dict->t("Aruba"),
+    'ax' => $dict->t("Aland Islands"),
+    'az' => $dict->t("Azerbaijan"),
+    'ba' => $dict->t("Bosnia and Herzegovina"),
+    'bb' => $dict->t("Barbados"),
+    'bd' => $dict->t("Bangladesh"),
+    'be' => $dict->t("Belgium"),
+    'bf' => $dict->t("Burkina Faso"),
+    'bg' => $dict->t("Bulgaria"),
+    'bh' => $dict->t("Bahrain"),
+    'bi' => $dict->t("Burundi"),
+    'bj' => $dict->t("Benin"),
+    'bm' => $dict->t("Bermuda"),
+    'bn' => $dict->t("Brunei Darussalam"),
+    'bo' => $dict->t("Bolivia"),
+    'br' => $dict->t("Brazil"),
+    'bs' => $dict->t("Bahamas"),
+    'bt' => $dict->t("Bhutan"),
+    'bv' => $dict->t("Bouvet Island"),
+    'bw' => $dict->t("Botswana"),
+    'by' => $dict->t("Belarus"),
+    'bz' => $dict->t("Belize"),
+    'ca' => $dict->t("Canada"),
+    'cc' => $dict->t("Cocos (Keeling) Islands"),
+    'cd' => $dict->t("Congo, The Democratic Republic of the"),
+    'cf' => $dict->t("Central African Republic"),
+    'cg' => $dict->t("Congo, Republic of"),
+    'ch' => $dict->t("Switzerland"),
+    'ci' => $dict->t("Cote d'Ivoire"),
+    'ck' => $dict->t("Cook Islands"),
+    'cl' => $dict->t("Chile"),
+    'cm' => $dict->t("Cameroon"),
+    'cn' => $dict->t("China"),
+    'co' => $dict->t("Colombia"),
+    'cr' => $dict->t("Costa Rica"),
+    'cu' => $dict->t("Cuba"),
+    'cv' => $dict->t("Cape Verde"),
+    'cx' => $dict->t("Christmas Island"),
+    'cy' => $dict->t("Cyprus"),
+    'cz' => $dict->t("Czech Republic"),
+    'de' => $dict->t("Germany"),
+    'dj' => $dict->t("Djibouti"),
+    'dk' => $dict->t("Denmark"),
+    'dm' => $dict->t("Dominica"),
+    'do' => $dict->t("Dominican Republic"),
+    'dz' => $dict->t("Algeria"),
+    'ec' => $dict->t("Ecuador"),
+    'ee' => $dict->t("Estonia"),
+    'eg' => $dict->t("Egypt"),
+    'eh' => $dict->t("Western Sahara"),
+    'er' => $dict->t("Eritrea"),
+    'es' => $dict->t("Spain"),
+    'et' => $dict->t("Ethiopia"),
+    'eu' => $dict->t("European Union"),
+    'fi' => $dict->t("Finland"),
+    'fj' => $dict->t("Fiji"),
+    'fk' => $dict->t("Falkland Islands (Malvinas)"),
+    'fm' => $dict->t("Micronesia, Federated States of"),
+    'fo' => $dict->t("Faroe Islands"),
+    'fr' => $dict->t("France"),
+    'ga' => $dict->t("Gabon"),
+    'gb' => $dict->t("United Kingdom"),
+    'gd' => $dict->t("Grenada"),
+    'ge' => $dict->t("Georgia"),
+    'gf' => $dict->t("French Guiana"),
+    'gg' => $dict->t("Guernsey"),
+    'gh' => $dict->t("Ghana"),
+    'gi' => $dict->t("Gibraltar"),
+    'gl' => $dict->t("Greenland"),
+    'gm' => $dict->t("Gambia"),
+    'gn' => $dict->t("Guinea"),
+    'gp' => $dict->t("Guadeloupe"),
+    'gq' => $dict->t("Equatorial Guinea"),
+    'gr' => $dict->t("Greece"),
+    'gs' => $dict->t("South Georgia and the South Sandwich Islands"),
+    'gt' => $dict->t("Guatemala"),
+    'gu' => $dict->t("Guam"),
+    'gw' => $dict->t("Guinea-Bissau"),
+    'gy' => $dict->t("Guyana"),
+    'hk' => $dict->t("Hong Kong"),
+    'hm' => $dict->t("Heard and McDonald Islands"),
+    'hn' => $dict->t("Honduras"),
+    'hr' => $dict->t("Croatia/Hrvatska"),
+    'ht' => $dict->t("Haiti"),
+    'hu' => $dict->t("Hungary"),
+    'id' => $dict->t("Indonesia"),
+    'ie' => $dict->t("Ireland"),
+    'il' => $dict->t("Israel"),
+    'im' => $dict->t("Isle of Man"),
+    'in' => $dict->t("India"),
+    'io' => $dict->t("British Indian Ocean Territory"),
+    'iq' => $dict->t("Iraq"),
+    'ir' => $dict->t("Iran, Islamic Republic of"),
+    'is' => $dict->t("Iceland"),
+    'it' => $dict->t("Italy"),
+    'je' => $dict->t("Jersey"),
+    'jm' => $dict->t("Jamaica"),
+    'jo' => $dict->t("Jordan"),
+    'jp' => $dict->t("Japan"),
+    'ke' => $dict->t("Kenya"),
+    'kg' => $dict->t("Kyrgyzstan"),
+    'kh' => $dict->t("Cambodia"),
+    'ki' => $dict->t("Kiribati"),
+    'km' => $dict->t("Comoros"),
+    'kn' => $dict->t("Saint Kitts and Nevis"),
+    'kp' => $dict->t("Korea, Democratic People's Republic of"),
+    'kr' => $dict->t("Korea, Republic of"),
+    'kw' => $dict->t("Kuwait"),
+    'ky' => $dict->t("Cayman Islands"),
+    'kz' => $dict->t("Kazakhstan"),
+    'la' => $dict->t("Lao People's Democratic Republic"),
+    'lb' => $dict->t("Lebanon"),
+    'lc' => $dict->t("Saint Lucia"),
+    'li' => $dict->t("Liechtenstein"),
+    'lk' => $dict->t("Sri Lanka"),
+    'lr' => $dict->t("Liberia"),
+    'ls' => $dict->t("Lesotho"),
+    'lt' => $dict->t("Lithuania"),
+    'lu' => $dict->t("Luxembourg"),
+    'lv' => $dict->t("Latvia"),
+    'ly' => $dict->t("Libyan Arab Jamahiriya"),
+    'ma' => $dict->t("Morocco"),
+    'mc' => $dict->t("Monaco"),
+    'md' => $dict->t("Moldova, Republic of"),
+    'me' => $dict->t("Montenegro"),
+    'mg' => $dict->t("Madagascar"),
+    'mh' => $dict->t("Marshall Islands"),
+    'mk' => $dict->t("Macedonia, The Former Yugoslav Republic of"),
+    'ml' => $dict->t("Mali"),
+    'mm' => $dict->t("Myanmar"),
+    'mn' => $dict->t("Mongolia"),
+    'mo' => $dict->t("Macao"),
+    'mp' => $dict->t("Northern Mariana Islands"),
+    'mq' => $dict->t("Martinique"),
+    'mr' => $dict->t("Mauritania"),
+    'ms' => $dict->t("Montserrat"),
+    'mt' => $dict->t("Malta"),
+    'mu' => $dict->t("Mauritius"),
+    'mv' => $dict->t("Maldives"),
+    'mw' => $dict->t("Malawi"),
+    'mx' => $dict->t("Mexico"),
+    'my' => $dict->t("Malaysia"),
+    'mz' => $dict->t("Mozambique"),
+    'na' => $dict->t("Namibia"),
+    'nc' => $dict->t("New Caledonia"),
+    'ne' => $dict->t("Niger"),
+    'nf' => $dict->t("Norfolk Island"),
+    'ng' => $dict->t("Nigeria"),
+    'ni' => $dict->t("Nicaragua"),
+    'nl' => $dict->t("Netherlands"),
+    'no' => $dict->t("Norway"),
+    'np' => $dict->t("Nepal"),
+    'nr' => $dict->t("Nauru"),
+    'nu' => $dict->t("Niue"),
+    'nz' => $dict->t("New Zealand"),
+    'om' => $dict->t("Oman"),
+    'pa' => $dict->t("Panama"),
+    'pe' => $dict->t("Peru"),
+    'pf' => $dict->t("French Polynesia"),
+    'pg' => $dict->t("Papua New Guinea"),
+    'ph' => $dict->t("Philippines"),
+    'pk' => $dict->t("Pakistan"),
+    'pl' => $dict->t("Poland"),
+    'pm' => $dict->t("Saint Pierre and Miquelon"),
+    'pn' => $dict->t("Pitcairn Island"),
+    'pr' => $dict->t("Puerto Rico"),
+    'ps' => $dict->t("Palestinian Territory, Occupied"),
+    'pt' => $dict->t("Portugal"),
+    'pw' => $dict->t("Palau"),
+    'py' => $dict->t("Paraguay"),
+    'qa' => $dict->t("Qatar"),
+    're' => $dict->t("Reunion Island"),
+    'ro' => $dict->t("Romania"),
+    'rs' => $dict->t("Serbia"),
+    'ru' => $dict->t("Russian Federation"),
+    'rw' => $dict->t("Rwanda"),
+    'sa' => $dict->t("Saudi Arabia"),
+    'sb' => $dict->t("Solomon Islands"),
+    'sc' => $dict->t("Seychelles"),
+    'sd' => $dict->t("Sudan"),
+    'se' => $dict->t("Sweden"),
+    'sg' => $dict->t("Singapore"),
+    'sh' => $dict->t("Saint Helena"),
+    'si' => $dict->t("Slovenia"),
+    'sj' => $dict->t("Svalbard and Jan Mayen Islands"),
+    'sk' => $dict->t("Slovakia"),
+    'sl' => $dict->t("Sierra Leone"),
+    'sm' => $dict->t("San Marino"),
+    'sn' => $dict->t("Senegal"),
+    'so' => $dict->t("Somalia"),
+    'sr' => $dict->t("Suriname"),
+    'st' => $dict->t("Sao Tome and Principe"),
+    'su' => $dict->t("Soviet Union"),
+    'sv' => $dict->t("El Salvador"),
+    'sy' => $dict->t("Syrian Arab Republic"),
+    'sz' => $dict->t("Swaziland"),
+    'tc' => $dict->t("Turks and Caicos Islands"),
+    'td' => $dict->t("Chad"),
+    'tf' => $dict->t("French Southern Territories"),
+    'tg' => $dict->t("Togo"),
+    'th' => $dict->t("Thailand"),
+    'tj' => $dict->t("Tajikistan"),
+    'tk' => $dict->t("Tokelau"),
+    'tl' => $dict->t("Timor-Leste"),
+    'tm' => $dict->t("Turkmenistan"),
+    'tn' => $dict->t("Tunisia"),
+    'to' => $dict->t("Tonga"),
+    'tp' => $dict->t("East Timor"),
+    'tr' => $dict->t("Turkey"),
+    'tt' => $dict->t("Trinidad and Tobago"),
+    'tv' => $dict->t("Tuvalu"),
+    'tw' => $dict->t("Taiwan"),
+    'tz' => $dict->t("Tanzania, United Republic of"),
+    'ua' => $dict->t("Ukraine"),
+    'ug' => $dict->t("Uganda"),
+    'uk' => $dict->t("United Kingdom"),
+    'um' => $dict->t("United States Minor Outlying Islands"),
+    'us' => $dict->t("United States"),
+    'uy' => $dict->t("Uruguay"),
+    'uz' => $dict->t("Uzbekistan"),
+    'va' => $dict->t("Holy See (Vatican City State)"),
+    'vc' => $dict->t("Saint Vincent and the Grenadines"),
+    've' => $dict->t("Venezuela"),
+    'vg' => $dict->t("Virgin Islands, British"),
+    'vi' => $dict->t("Virgin Islands, U.S."),
+    'vn' => $dict->t("Viet Nam"),
+    'vu' => $dict->t("Vanuatu"),
+    'wf' => $dict->t("Wallis and Futuna Islands"),
+    'ws' => $dict->t("Samoa"),
+    'ye' => $dict->t("Yemen"),
+    'yt' => $dict->t("Mayotte"),
+    'yu' => $dict->t("Yugoslavia"),
+    'za' => $dict->t("South Africa"),
+    'zm' => $dict->t("Zambia"),
+    'zw' => $dict->t("Zimbabwe")
 );
index 4ec0e72..628d930 100644 (file)
@@ -166,14 +166,19 @@ class Horde_Perms
      * Given a permission name, returns the title for that permission by
      * looking it up in the applications's permission api.
      *
-     * @param string $name  The permissions's name.
+     * @param string $name             The permissions's name.
+     * @param Horde_Translation $dict  A translation handler implementing
+     *                                 Horde_Translation.
      *
      * @return string  The title for the permission.
      */
-    public function getTitle($name)
+    public function getTitle($name, $dict = null)
     {
         if ($name === self::ROOT) {
-            return _("All Permissions");
+            if (!$dict) {
+                $dict = new Horde_Translation_Gettext('Horde_Perms', dirname(__FILE__) . '/../../locale');
+            }
+            return $dict->t("All Permissions");
         }
 
         $levels = explode(':', $name);
@@ -504,15 +509,22 @@ class Horde_Perms
     /**
      * Returns an hash of the available permissions.
      *
+     * @param Horde_Translation $dict  A translation handler implementing
+     *                                 Horde_Translation.
+     *
      * @return array  The available permissions as a hash.
      */
-    static public function getPermsArray()
+    static public function getPermsArray($dict = null)
     {
+        if (!$dict) {
+            $dict = new Horde_Translation_Gettext('Horde_Perms', dirname(__FILE__) . '/../../locale');
+        }
+
         return array(
-            self::SHOW => _("Show"),
-            self::READ => _("Read"),
-            self::EDIT => _("Edit"),
-            self::DELETE => _("Delete")
+            self::SHOW => $dict->t("Show"),
+            self::READ => $dict->t("Read"),
+            self::EDIT => $dict->t("Edit"),
+            self::DELETE => $dict->t("Delete")
         );
     }
 
index 9282f0a..e322621 100644 (file)
@@ -99,26 +99,32 @@ class Horde_Prefs implements ArrayAccess
     protected $_hooks = array();
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Attempts to return a concrete instance based on $driver.
      *
      * @param mixed $driver  The type of concrete subclass to return.
      * @param string $scope  The scope for this set of preferences.
      * @param array $opts    Additional options:
-     * <pre>
-     * 'cache' - (boolean) Should caching be used?
-     *           DEFAULT: false
-     * 'charset' - (string) Default charset. [REQUIRED]
-     * 'logger' - (Horde_Log_Logger) Logging object.
-     *            DEFAULT: NONE
-     * 'password' - (string) The password associated with 'user'.
-     *              DEFAULT: NONE
-     * 'sizecallback' - (callback) If set, called when setting a value in
-     *                  the backend.
-     *                  DEFAULT: NONE
-     * 'user' - (string) The name of the user who owns this set of
-     *          preferences.
-     *          DEFAULT: NONE
-     * </pre>
+     *                       - 'cache': (boolean) Should caching be used?
+     *                                  DEFAULT: false
+     *                       - 'charset': (string) Default charset. [REQUIRED]
+     *                       - 'logger': (Horde_Log_Logger) Logging object.
+     *                                   DEFAULT: NONE
+     *                       - 'password': (string) The password associated
+     *                                     with 'user'. DEFAULT: NONE
+     *                       - 'sizecallback': (callback) If set, called when
+     *                                         setting a value in the backend.
+     *                                         DEFAULT: NONE
+     *                       - 'user': (string) The name of the user who owns
+     *                                 this set of preferences. DEFAULT: NONE
+     *                       - 'translation': (object) A translation handler
+     *                                        implementing Horde_Translation.
      * @param array $params  A hash containing any additional configuration
      *                       or connection parameters a subclass might need.
      *
@@ -163,6 +169,12 @@ class Horde_Prefs implements ArrayAccess
         $this->_params = $params;
         $this->_scope = $scope;
 
+        if (isset($this->_opts['translation'])) {
+            $this->_dict = $this->_opts['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Prefs', dirname(__FILE__) . '/../../locale');
+        }
+
         // Create a unique key that's safe to use for caching even if we want
         // another user's preferences later, then register the cache array in
         // $_SESSION.
index ba06033..aa61fec 100644 (file)
@@ -33,8 +33,11 @@ class Horde_Prefs_CategoryManager
     /**
      * TODO
      */
-    static public function getSelect($id, $current = null)
+    static public function getSelect($id, $current = null, $dict = null)
     {
+        if (!$dict) {
+            $dict = new Horde_Translation_Gettext('Horde_Prefs', dirname(__FILE__) . '/../../../locale');
+        }
         $categories = self::get();
         $colors = self::colors();
         $fgcolors = self::fgColors();
@@ -45,13 +48,13 @@ class Horde_Prefs_CategoryManager
         if (!in_array($current, $categories) && !empty($current)) {
             $curr_html = htmlspecialchars($current);
             $html .= '<option value="*new*' . $curr_html . '">'
-                . sprintf(_("Use Current: %s"), $curr_html)
+                . sprintf($dict->t("Use Current: %s"), $curr_html)
                 . '</option>'
                 . '<option value="" disabled="disabled">- - - - - - - - -</option>';
         }
 
         if (!$GLOBALS['prefs']->isLocked('categories')) {
-            $html .= '<option value="*new*">' . _("New Category")
+            $html .= '<option value="*new*">' . $dict->t("New Category")
                 . "</option>\n"
                 . '<option value="" disabled="disabled">- - - - - - - - -</option>';
         }
@@ -60,7 +63,7 @@ class Horde_Prefs_CategoryManager
         $html .= '<option value="" style="background:'
             . $colors['_unfiled_'] . ';color:' . $fgcolors['_unfiled_'] . '"'
             . (empty($current) ? ' selected="selected">' : '>')
-            . htmlspecialchars(_("Unfiled")) . '</option>';
+            . htmlspecialchars($dict->t("Unfiled")) . '</option>';
 
         foreach ($categories as $name) {
             $name_html = htmlspecialchars($name);
@@ -77,10 +80,13 @@ class Horde_Prefs_CategoryManager
     /**
      * TODO
      */
-    static public function getJavaScript($formname, $elementname)
+    static public function getJavaScript($formname, $elementname, $dict = null)
     {
-        $prompt = addslashes(_("Please type the new category name:"));
-        $error = addslashes(_("You must type a new category name."));
+        if (!$dict) {
+            $dict = new Horde_Translation_Gettext('Horde_Prefs', dirname(__FILE__) . '/../../../locale');
+        }
+        $prompt = addslashes($dict->t("Please type the new category name:"));
+        $error = addslashes($dict->t("You must type a new category name."));
 
         return <<<JAVASCRIPT
 
index fc3dc76..92b3909 100644 (file)
@@ -59,27 +59,38 @@ class Horde_Prefs_Identity
     protected $_prefs;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor.
      *
      * @param array $params  Parameters:
-     * <pre>
-     * 'default_identity' - (string) The preference name for the default
-     *                      identity.
-     *                      DEFAULT: 'default_identity'
-     * 'from_addr' - (string) The preference name for the user's from e-mail
-     *               address.
-     *               DEFAULT: 'from_addr'
-     * 'fullname' - (string) The preference name for the user's full name.
-     *              DEFAULT: 'fullname'
-     * 'id' - (string) The preference name for the identity name.
-     *        DEFAULT: 'id'
-     * 'identities' - (string) The preference name for the identity store.
-     *                DEFAULT: 'identities'
-     * 'prefs' - (Horde_Prefs) [REQUIRED] The prefs object to use.
-     * 'properties' - (array) The list of properties for the identity.
-     *                DEFAULT: array('from_addr', 'fullname', 'id')
-     * 'user' - (string) [REQUIRED] The user whose prefs we are handling.
-     * </pre>
+     *                       - 'default_identity': (string) The preference name
+     *                                             for the default identity.
+     *                                             DEFAULT: 'default_identity'
+     *                       - 'from_addr': (string) The preference name for
+     *                                      the user's from e-mail address.
+     *                                      DEFAULT: 'from_addr'
+     *                       - 'fullname': (string) The preference name for the
+     *                                     user's full name. DEFAULT: 'fullname'
+     *                       - 'id': (string) The preference name for the
+     *                               identity name. DEFAULT: 'id'
+     *                       - 'identities': (string) The preference name for
+     *                                       the identity store.
+     *                                       DEFAULT: 'identities'
+     *                       - 'prefs': (Horde_Prefs) [REQUIRED] The prefs
+     *                                  object to use.
+     *                       - 'properties': (array) The list of properties for
+                                             the identity.
+     *                                       DEFAULT: array('from_addr', 'fullname', 'id')
+     *                       - 'user': (string) [REQUIRED] The user whose prefs
+     *                                 we are handling.
+     *                       - 'translation': (object) A translation handler
+     *                                        implementing Horde_Translation.
      */
     public function __construct($params = array())
     {
@@ -91,7 +102,13 @@ class Horde_Prefs_Identity
         $this->_prefs = $params['prefs'];
         $this->_user = $params['user'];
 
-        if (!($this->_identities = unserialize($this->_prefs->getValue($this->_prefnames['identities'], false)))) {
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Prefs', dirname(__FILE__) . '/../../../locale');
+        }
+
+        if (!($this->_identities = @unserialize($this->_prefs->getValue($this->_prefnames['identities'], false)))) {
             $this->_identities = $this->_prefs->getDefault($this->_prefnames['identities']);
         } elseif (is_array($this->_identities)) {
             $this->_identities = $this->_prefs->convertFromDriver($this->_identities);
@@ -111,7 +128,7 @@ class Horde_Prefs_Identity
                 $identity[$key] = $this->_prefs->getValue($key);
             }
             if (empty($identity['id'])) {
-                $identity['id'] = _("Default Identity");
+                $identity['id'] = $this->_dict->t("Default Identity");
             }
 
             $this->_identities = array($identity);
@@ -332,7 +349,7 @@ class Horde_Prefs_Identity
         }
 
         if (!$this->getValue('id', $identity)) {
-            $this->setValue('id', _("Unnamed"), $identity);
+            $this->setValue('id', $this->_dict->t("Unnamed"), $identity);
         }
 
         /* RFC 2822 [3.2.5] does not allow the '\' character to be used in the
index e773045..8a04c5a 100644 (file)
@@ -139,7 +139,7 @@ class Horde_Prefs_Ldap extends Horde_Prefs
                 if ($this->_opts['logger']) {
                     $this->_opts['logger']->log(sprintf('Setting referral callback failed: [%d] %s', @ldap_errno($conn), @ldap_error($conn)), 'WARN');
                 }
-                throw new Horde_Prefs_Exception(_("Internal LDAP error.  Details have been logged for the administrator."), @ldap_errno($conn));
+                throw new Horde_Prefs_Exception($this->_dict->t("Internal LDAP error.  Details have been logged for the administrator."), @ldap_errno($conn));
             }
         }
 
index 547f824..166cbf6 100644 (file)
@@ -64,17 +64,30 @@ class Horde_Rpc
     protected $_logger;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * RPC server constructor.
      *
      * @param Horde_Controller_Request_Http  The request object
      *
-     * @param array $config  A hash containing any additional configuration or
+     * @param array $params  A hash containing any additional configuration or
      *                       connection parameters a subclass might need.
      *
      * @return Horde_Rpc  An RPC server instance.
      */
     public function __construct($request, $params = array())
     {
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Rpc', dirname(__FILE__) . '/../../locale');
+        }
+
         // Create a stub if we don't have a useable logger.
         if (isset($params['logger'])
             && is_callable(array($params['logger'], 'log'))) {
index c0c8536..a73cf52 100644 (file)
@@ -77,8 +77,8 @@ class Horde_Rpc_Phpgw extends Horde_Rpc
         $method = str_replace('.', '/', 'phpgw.' . $method);
 
         if (!$registry->hasMethod($method)) {
-            Horde::logMessage(sprintf(_("Method \"%s\" is not defined"), $method), 'NOTICE');
-            return sprintf(_("Method \"%s\" is not defined"), $method);
+            Horde::logMessage(sprintf($this->_dict->t("Method \"%s\" is not defined"), $method), 'NOTICE');
+            return sprintf($this->_dict->t("Method \"%s\" is not defined"), $method);
         }
 
         // Try to resume a session
@@ -96,7 +96,7 @@ class Horde_Rpc_Phpgw extends Horde_Rpc
             Horde::logMessage("rpc call $method allowed", 'NOTICE');
             return $registry->call($method, $params);
         } else {
-            return PEAR::raiseError(_("You did not authenticate."), 'horde.error');
+            return PEAR::raiseError($this->_dict->t("You did not authenticate."), 'horde.error');
             // return parent::authorize();
             // error 9 "access denied"
         }
@@ -155,9 +155,9 @@ class Horde_Rpc_Phpgw extends Horde_Rpc
         if (is_a($result, 'PEAR_Error')) {
             throw new Horde_Rpc_Exception($result);
         } elseif ($http->getResponseCode() != 200) {
-            throw new Horde_Rpc_Exception(_("Request couldn't be answered. Returned errorcode: ") . $http->getResponseCode());
+            throw new Horde_Rpc_Exception($this->_dict->t("Request couldn't be answered. Returned errorcode: ") . $http->getResponseCode());
         } elseif (strpos($http->getResponseBody(), '<?xml') === false) {
-            throw new Horde_Rpc_Exception(_("No valid XML data returned:") . "\n" . $http->getResponseBody());
+            throw new Horde_Rpc_Exception($this->_dict->t("No valid XML data returned:") . "\n" . $http->getResponseBody());
         } else {
             $response = @xmlrpc_decode(substr($http->getResponseBody(), strpos($http->getResponseBody(), '<?xml')));
             if (is_array($response) && isset($response['faultString'])) {
index 34ca8dd..5c46ec0 100644 (file)
@@ -203,7 +203,7 @@ class Horde_Rpc_Soap_Caller {
 
         if (!empty($this->_params['allowedMethods']) &&
             !in_array($method, $this->_params['allowedMethods'])) {
-            return sprintf(_("Method \"%s\" is not defined"), $method);
+            return sprintf($this->_dict->t("Method \"%s\" is not defined"), $method);
         }
 
         $GLOBALS['__horde_rpc_PhpSoap']['lastMethodCalled'] = $method;
@@ -211,7 +211,7 @@ class Horde_Rpc_Soap_Caller {
             !empty($params) ? $params : array();
 
         if (!$GLOBALS['registry']->hasMethod($method)) {
-            return sprintf(_("Method \"%s\" is not defined"), $method);
+            return sprintf($this->_dict->t("Method \"%s\" is not defined"), $method);
         }
 
         return $GLOBALS['registry']->call($method, $params);
index 157cad4..42ca893 100644 (file)
@@ -344,7 +344,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc
         $pieces = explode('/', trim($this->path, '/'), 2);
 
         if (count($pieces) != 2) {
-            Horde::logMessage(sprintf(_("Error deleting from path %s; must be [app]/[path]", $options['path'])), 'INFO');
+            Horde::logMessage(sprintf($this->_dict->t("Error deleting from path %s; must be [app]/[path]", $options['path'])), 'INFO');
             return '403 Must supply a resource within the application to delete.';
         }
 
@@ -405,7 +405,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc
         // Take the module name from the path
         $pieces = explode('/', $path, 2);
         if (count($pieces) != 2) {
-            Horde::logMessage(sprintf(_("Unable to create directory %s; must be [app]/[path]"), $path), 'INFO');
+            Horde::logMessage(sprintf($this->_dict->t("Unable to create directory %s; must be [app]/[path]"), $path), 'INFO');
             return '403 Must specify a resource within an application.  MKCOL disallowed at top level.';
         }
 
@@ -440,7 +440,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc
         // Take the module name from the path
         $sourcePieces = explode('/', $path, 2);
         if (count($sourcePieces) != 2) {
-            Horde::logMessage(sprintf(_("Unable to rename %s; must be [app]/[path] and within the same application."), $path), 'INFO');
+            Horde::logMessage(sprintf($this->_dict->t("Unable to rename %s; must be [app]/[path] and within the same application."), $path), 'INFO');
             return '403 Must specify a resource within an application.  MOVE disallowed at top level.';
         }
 
index 55ab2d1..cd025ab 100644 (file)
@@ -23,13 +23,21 @@ class Horde_Service_Facebook_Request
      * @param string                 $method
      * @param Horde_Http_Client      $http_client
      * @param array                  $params
+     * @param Horde_Translation      $dict  A translation handler implementing
+     *                                      Horde_Translation.
      */
-    public function __construct($facebook, $method, $http_client, $params = array())
+    public function __construct($facebook, $method, $http_client,
+                                $params = array(), $dict = null)
     {
         $this->_facebook = $facebook;
         $this->_http = $http_client;
         $this->_method = $method;
         $this->_params = $params;
+        if ($dict) {
+            $this->_dict = $dict;
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Service_Facebook', dirname(__FILE__) . '/../../../../locale');
+        }
     }
 
     /**
@@ -83,7 +91,7 @@ class Horde_Service_Facebook_Request
         } catch (Exception $e) {
             // Not much we can do about a client exception - rethrow it as
             // temporarily unavailable.
-            throw new Horde_Service_Facebook_Exception(_("Service is unavailable. Please try again later."));
+            throw new Horde_Service_Facebook_Exception($this->_dict->t("Service is unavailable. Please try again later."));
         }
         return $result->getBody();
     }
index b0f519c..20b8433 100644 (file)
@@ -25,10 +25,13 @@ class Horde_Service_Facebook_UploadRequest extends Horde_Service_Facebook_Reques
      * @param Horde_Http_Client      $http_client
      * @param string                 $file
      * @param array                  $params
+     * @param Horde_Translation      $dict  A translation handler implementing
+     *                                      Horde_Translation.
      */
-    public function __construct($facebook, $method, $http_client, $file, $params = array())
+    public function __construct($facebook, $method, $http_client, $file,
+                                $params = array(), $dict = null)
     {
-        parent::__construct($facebook, $method, $http_client, $params);
+        parent::__construct($facebook, $method, $http_client, $params, $dict);
         $this->_filename = $file;
     }
 
@@ -88,7 +91,7 @@ class Horde_Service_Facebook_UploadRequest extends Horde_Service_Facebook_Reques
                                             array('Content-Type' => $content_type,
                                                   'Content-Length' => strlen($content)));
         } catch (Exception $e) {
-            throw new Horde_Service_Facebook_Exception(sprintf(_("Upload failed: %s"), $e->getMessage()));
+            throw new Horde_Service_Facebook_Exception(sprintf($this->_dict->t("Upload failed: %s"), $e->getMessage()));
         }
 
         return $result->getBody();
index 3ac6679..c268bcc 100644 (file)
@@ -6,6 +6,34 @@ class Horde_Block_Horde_Scribd extends Horde_Block {
 
     var $_app = 'horde';
 
+    /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_localDict;
+
+    /**
+     * Constructor.
+     *
+     * @param array|boolean $params  Any parameters the block needs. If false,
+     *                               the default parameter will be used.
+     * @param integer $row           The block row.
+     * @param integer $col           The block column.
+     * @param Horde_Translation $dict  A translation handler implementing
+     *                                 Horde_Translation.
+     */
+    public function __construct($params = array(), $row = null, $col = null,
+                                $dict = null)
+    {
+        parent::__construct($params, $row, $col, $dict);
+        if ($dict) {
+            $this->_localDict = $dict;
+        } else {
+            $this->_localDict = new Horde_Translation_Gettext('Horde_Service_Scribd', dirname(__FILE__) . '/../../../locale');
+        }
+    }
+
     function _params()
     {
     }
@@ -17,7 +45,7 @@ class Horde_Block_Horde_Scribd extends Horde_Block {
      */
     function _title()
     {
-        return _("Scribd Documents");
+        return $this->_localDict->t("Scribd Documents");
     }
 
     /**
index 16aa12b..150e4ff 100644 (file)
@@ -78,13 +78,28 @@ class Horde_Share
     protected $_permsObject;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor.
      *
-     * @param string $app  The application that the shares belong to.
-     * @param Horde_Perms  The permissions object
+     * @param string $app              The application that the shares belong
+     *                                 to.
+     * @param Horde_Perms $perms       The permissions object
+     * @param Horde_Translation $dict  A translation handler implementing
+     *                                 Horde_Translation.
      */
-    public function __construct($app, Horde_Perms $perms)
+    public function __construct($app, Horde_Perms $perms, $dict = null)
     {
+        if ($dict) {
+            $this->_dict = $dict;
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Share', dirname(__FILE__) . '/../../locale');
+        }
         $this->_app = $app;
         $this->_permsObject = $perms;
         $this->__wakeup();
index d40301c..613d39a 100644 (file)
@@ -78,7 +78,7 @@ class Horde_Share_kolab extends Horde_Share
         case 'nag':
             return 'task';
         default:
-            throw new Horde_Share_Exception(sprintf(_("The Horde/Kolab integration engine does not support \"%s\""), $app));
+            throw new Horde_Share_Exception(sprintf($this->_dict->t("The Horde/Kolab integration engine does not support \"%s\""), $app));
         }
     }
 
@@ -114,7 +114,7 @@ class Horde_Share_kolab extends Horde_Share
 
         /** Does the folder exist? */
         if (!$folder->exists()) {
-            throw new Horde_Share_Exception(sprintf(_("Share \"%s\" does not exist."), $object));
+            throw new Horde_Share_Exception(sprintf($this->_dict->t("Share \"%s\" does not exist."), $object));
         }
 
         /** Create the object from the folder */
index b50b9de..f932774 100644 (file)
@@ -45,14 +45,29 @@ class Horde_Share_Object_Kolab extends Horde_Share_Object
     private $_session;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor.
      *
      * Sets the folder name.
      *
      * @param string $id  The share id.
+     * @param Horde_Translation $dict  A translation handler implementing
+     *                                 Horde_Translation.
      */
-    public function __construct($id, $type)
+    public function __construct($id, $type, $dict = null)
     {
+        if ($dict) {
+            $this->_dict = $dict;
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Share', dirname(__FILE__) . '/../../../../locale');
+        }
+
         // We actually ignore the random id string that all horde apps provide
         // as initial name and wait for a set('name', 'xyz') call. But we want
         // to know if we should create a default share.
@@ -109,17 +124,17 @@ class Horde_Share_Object_Kolab extends Horde_Share_Object
     {
         switch ($this->_type) {
         case 'contact':
-            return _("Contacts");
+            return $this->_dict->t("Contacts");
         case 'note':
-            return _("Notes");
+            return $this->_dict->t("Notes");
         case 'event':
-            return _("Calendar");
+            return $this->_dict->t("Calendar");
         case 'task':
-            return _("Tasks");
+            return $this->_dict->t("Tasks");
         case 'filter':
-            return _("Filters");
+            return $this->_dict->t("Filters");
         case 'h-prefs':
-            return _("Preferences");
+            return $this->_dict->t("Preferences");
         }
     }
 
@@ -135,7 +150,7 @@ class Horde_Share_Object_Kolab extends Horde_Share_Object
             $this->_folder = &$folder;
             $this->_folder_name = $folder->name;
         } else {
-           throw new Horde_Share_Exception(_("The share has already been initialized!"));
+           throw new Horde_Share_Exception($this->_dict->t("The share has already been initialized!"));
         }
     }
 
@@ -355,6 +370,6 @@ class Horde_Share_Object_Kolab extends Horde_Share_Object
      */
     protected function _folderError()
     {
-        throw new Horde_Share_Exception(_("The Kolab share object has not been initialized yet!"));
+        throw new Horde_Share_Exception($this->_dict->t("The Kolab share object has not been initialized yet!"));
     }
 }
index 1efa1c9..eb9b235 100644 (file)
@@ -207,7 +207,7 @@ class Horde_Share_Sql extends Horde_Share
             Horde::logMessage($data, 'ERR');
             throw new Horde_Share_Exception($data->getMessage());
         } elseif (empty($data)) {
-            throw new Horde_Share_Exception(sprintf(_("Share \"%s\" does not exist."), $name));
+            throw new Horde_Share_Exception(sprintf($this->_dict->t("Share \"%s\" does not exist."), $name));
         }
         $stmt->free();
         $results->free();
@@ -269,7 +269,7 @@ class Horde_Share_Sql extends Horde_Share
             Horde::logMessage($data, 'ERR');
             throw new Horde_Share_Exception($data->getMessage());
         } elseif (empty($data)) {
-            throw new Horde_Share_Exception(sprintf(_("Share ID %d does not exist."), $id));
+            throw new Horde_Share_Exception(sprintf($this->_dict->t("Share ID %d does not exist."), $id));
         }
 
         $stmt->free();
index ce630c7..8322cf5 100644 (file)
@@ -544,7 +544,7 @@ class Horde_Share_Sql_Hierarchical extends Horde_Share_Sql
      */
     public function getShare($name)
     {
-        throw new Horde_Share_Exception(_("Share names are not supported in this driver"));
+        throw new Horde_Share_Exception($this->_dict->t("Share names are not supported in this driver"));
     }
 
     /**
index f98de3d..f3a0279 100644 (file)
@@ -252,6 +252,13 @@ class SyncML_Backend {
     var $_backendMode;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    public $dict;
+
+    /**
      * Constructor.
      *
      * Sets up the default logging mechanism.
@@ -268,6 +275,8 @@ class SyncML_Backend {
      *                                      debug_dir.
      *                       - log_level:   Only log entries with at least
      *                                      this level. Defaults to 'INFO'.
+     *                       - 'translation': A translation handler
+     *                                        implementing Horde_Translation.
      */
     function SyncML_Backend($params)
     {
@@ -278,6 +287,11 @@ class SyncML_Backend {
         if (isset($params['log_level'])) {
             $this->_logLevel = $params['log_level'];
         }
+        if (isset($params['translation'])) {
+            $this->dict = $params['translation'];
+        } else {
+            $this->dict = new Horde_Translation_Gettext('SyncML', dirname(__FILE__) . '/../locale');
+        }
 
         $this->logMessage('Backend of class ' . get_class($this) . ' created', 'DEBUG');
      }
index c2f69c1..b55b478 100644 (file)
@@ -611,7 +611,7 @@ class SyncML_Device_sync4j extends SyncML_Device {
             $components = $iCal->getComponents();
             if (!is_array($components) || count($components) == 0) {
                 $a = array(
-                    'Body' => _("Error converting notes."));
+                    'Body' => $GLOBALS['backend']->t("Error converting notes."));
             } else {
                 $a = array(
                     'Body' => $components[0]->getAttribute('BODY'),
index b07829e..a911b1d 100644 (file)
@@ -308,6 +308,8 @@ class Horde_Template
 
     /**
      * Parses gettext tags.
+     *
+     * @todo Convert to use Horde_Translation.
      */
     protected function _parseGettext()
     {
index 691b011..0fa3870 100644 (file)
@@ -24,12 +24,24 @@ class Horde_Text_Filter_Base
     protected $_params = array();
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor.
      *
      * @param array $params  Any parameters that the filter instance needs.
      */
     public function __construct($params = array())
     {
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_Text_Filter', dirname(__FILE__) . '/../../../../locale');
+        }
         $this->_params = array_merge($this->_params, $params);
     }
 
index a824d14..0906771 100644 (file)
@@ -120,8 +120,8 @@ class Horde_Text_Filter_Html2text extends Horde_Text_Filter_Base
 
         /* Add link list. */
         if (!empty($this->_linkList)) {
-            $text .= "\n\n" . _("Links") . ":\n" .
-                str_repeat('-', Horde_String::length(_("Links")) + 1) . "\n";
+            $text .= "\n\n" . $this->_dict->t("Links") . ":\n" .
+                str_repeat('-', Horde_String::length($this->_dict->t("Links")) + 1) . "\n";
             foreach ($this->_linkList as $key => $val) {
                 $text .= '[' . ($key + 1) . '] ' . $val . "\n";
             }
index d8fc0fd..23e0cd5 100644 (file)
@@ -84,6 +84,13 @@ class VFS
     protected $_vfsSize = null;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Attempts to return a concrete instance based on $driver.
      *
      * @param mixed $driver  The type of concrete subclass to return. This
@@ -114,6 +121,11 @@ class VFS
      */
     public function __construct($params = array())
     {
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('Horde_VFS', dirname(__FILE__) . '/../locale');
+        }
         $this->setParams(array(
             'user' => '',
             'vfs_quotalimit' => -1,
index 22c97f8..fc54b42 100644 (file)
@@ -570,10 +570,10 @@ class VFS_smb extends VFS
         foreach ($out as $line) {
             if (strpos($line, 'NT_STATUS_NO_SUCH_FILE') !== false ||
                 strpos($line, 'NT_STATUS_OBJECT_NAME_NOT_FOUND') !== false) {
-                $err = _("No such file");
+                $err = $this->_dict->t("No such file");
                 break;
             } elseif (strpos($line, 'NT_STATUS_ACCESS_DENIED') !== false) {
-                $err = _("Permission Denied");
+                $err = $this->_dict->t("Permission Denied");
                 break;
             }
         }
index 39a3126..0604fc9 100644 (file)
@@ -261,7 +261,7 @@ class VFS_sql_file extends VFS_file
 
         if (!@rename($this->_getNativePath($oldpath, $oldname), $this->_getNativePath($newpath, $newname))) {
             $this->_db->query(sprintf('UPDATE %s SET vfs_path = ?, vfs_name = ? WHERE vfs_path = ? AND vfs_name = ?', $this->_params['table']), array($oldpath, $oldname, $newpath, $newname));
-            return PEAR::raiseError(_("Unable to rename VFS file."));
+            return PEAR::raiseError($this->_dict->t("Unable to rename VFS file."));
         }
     }
 
index 45cfaaa..a199ec4 100644 (file)
@@ -10,7 +10,8 @@
  * @author  Jason M. Felice <jason.m.felice@gmail.com>
  * @package VFS_ISO
  */
-class VFS_ISOWriter {
+abstract class VFS_ISOWriter
+{
 
     /**
      * A VFS object used for reading the source files
@@ -34,6 +35,13 @@ class VFS_ISOWriter {
     var $_params = array();
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructs a new VFS_ISOWriter object
      *
      * @param array $params  A hash containing parameters.
@@ -43,19 +51,19 @@ class VFS_ISOWriter {
         $this->_sourceVfs = &$sourceVfs;
         $this->_targetVfs = &$targetVfs;
         $this->_params = $params;
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('VFS_ISOWriter', dirname(__FILE__) . '/locale');
+        }
     }
 
     /**
      * Create the ISO image
      *
-     * @abstract
-     *
      * @return mixed  Null or PEAR_Error on failure.
      */
-    function process()
-    {
-        return PEAR::raiseError(_("Not implemented."));
-    }
+    abstract public function process();
 
     /**
      * Attempt to create a concrete VFS_ISOWriter subclass.
@@ -82,7 +90,7 @@ class VFS_ISOWriter {
     function &factory(&$sourceVfs, &$targetVfs, $params)
     {
         if (empty($params['targetFile'])) {
-            return PEAR::raiseError(_("Cannot proceed without 'targetFile' parameter."));
+            return PEAR::raiseError($this->_dict->t("Cannot proceed without 'targetFile' parameter."));
         }
         if (empty($params['sourceRoot'])) {
             $params['sourceRoot'] = '/';
@@ -97,7 +105,7 @@ class VFS_ISOWriter {
             return $isowriter;
         }
 
-        return PEAR::raiseError(_("No available strategy for making ISO images."));
+        return PEAR::raiseError($this->_dict->t("No available strategy for making ISO images."));
     }
 
 }
index 78aa685..6861a28 100644 (file)
@@ -11,7 +11,7 @@
  * @author  Jason M. Felice <jason.m.felice@gmail.com>
  * @package VFS_ISO
  */
-class VFS_ISOWriter_RealInputStrategy {
+abstract class VFS_ISOWriter_RealInputStrategy {
 
     /**
      * A reference to the source VFS we want to read.
@@ -21,39 +21,43 @@ class VFS_ISOWriter_RealInputStrategy {
     var $_sourceVfs = null;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * The root directory within the source VFS
      *
      * @var string
      */
     var $_sourceRoot;
 
-    function VFS_ISOWriter_RealInputStrategy(&$sourceVfs, $sourceRoot)
+    function VFS_ISOWriter_RealInputStrategy(&$sourceVfs, $sourceRoot, $params = array())
     {
         $this->_sourceVfs = &$sourceVfs;
         $this->_sourceRoot = &$sourceRoot;
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('VFS_ISOWriter', dirname(__FILE__) . '/../locale');
+        }
     }
 
     /**
      * Get a real path to the input tree.
      *
-     * @abstract
      * @return mixed    A string with the real path, or PEAR_Error on failure.
      */
-    function getRealPath()
-    {
-        return PEAR::raiseError(_("Not implemented."));
-    }
+    abstract public function getRealPath();
 
     /**
      * Indicate we are finished with this input strategy.
      *
-     * @abstract
      * @return mixed        Null or PEAR_Error on failure.
      */
-    function finished()
-    {
-        return PEAR::raiseError(_("Not implemented."));
-    }
+    abstract public function finished();
 
     /**
      * Decide which strategy to use to get a real FS and create it.
@@ -78,7 +82,7 @@ class VFS_ISOWriter_RealInputStrategy {
         if (class_exists($class)) {
             $strategy = new $class($sourceVfs, $sourceRoot);
         } else {
-            $strategy = PEAR::raiseError(sprintf(_("Could not load strategy \"%s\"."),
+            $strategy = PEAR::raiseError(sprintf($this->_dict->t("Could not load strategy \"%s\"."),
                                                  $method));
         }
 
index e37a5b2..ae8eef2 100644 (file)
@@ -39,7 +39,7 @@ class VFS_ISOWriter_RealInputStrategy_copy extends VFS_ISOWriter_RealInputStrate
             }
 
             if (empty($tmp)) {
-                return PEAR::raiseError(_("Cannot find a temporary directory."));
+                return PEAR::raiseError($this->_dict->t("Cannot find a temporary directory."));
             }
 
             $this->_tempPath = tempnam($tmp, 'isod');
@@ -63,7 +63,7 @@ class VFS_ISOWriter_RealInputStrategy_copy extends VFS_ISOWriter_RealInputStrate
     {
         $dh = @opendir($path);
         if (!is_resource($dh)) {
-            return PEAR::raiseError(sprintf(_("Could not open directory \"%s\"."),
+            return PEAR::raiseError(sprintf($this->_dict->t("Could not open directory \"%s\"."),
                                             $path));
         }
         while (($ent = readdir($dh)) !== false) {
@@ -79,7 +79,7 @@ class VFS_ISOWriter_RealInputStrategy_copy extends VFS_ISOWriter_RealInputStrate
                 }
             } else {
                 if (!@unlink($full)) {
-                    return PEAR::raiseError(sprintf(_("Could not unlink \"%s\"."),
+                    return PEAR::raiseError(sprintf($this->_dict->t("Could not unlink \"%s\"."),
                                                     $full));
                 }
             }
@@ -87,7 +87,7 @@ class VFS_ISOWriter_RealInputStrategy_copy extends VFS_ISOWriter_RealInputStrate
         closedir($dh);
 
         if (!@rmdir($path)) {
-            return PEAR::raiseError(sprintf(_("Could not rmdir \"%s\"."), $full));
+            return PEAR::raiseError(sprintf($this->_dict->t("Could not rmdir \"%s\"."), $full));
         }
     }
 
@@ -103,7 +103,7 @@ class VFS_ISOWriter_RealInputStrategy_copy extends VFS_ISOWriter_RealInputStrate
                 $target = sprintf('%s/%s', $this->_tempPath, $dir);
             }
             if (!@mkdir($target)) {
-                return PEAR::raiseError(sprintf(_("Could not mkdir \"%s\"."), $target));
+                return PEAR::raiseError(sprintf($this->_dict->t("Could not mkdir \"%s\"."), $target));
             }
 
             $sourcePath = $this->_sourceRoot;
@@ -132,10 +132,10 @@ class VFS_ISOWriter_RealInputStrategy_copy extends VFS_ISOWriter_RealInputStrate
                     $targetFile = sprintf('%s/%s', $target, $entry['name']);
                     $fh = @fopen($targetFile, 'w');
                     if (!is_resource($fh)) {
-                        return PEAR::raiseError(sprintf(_("Could not open \"%s\" for writing."), $targetFile));
+                        return PEAR::raiseError(sprintf($this->_dict->t("Could not open \"%s\" for writing."), $targetFile));
                     }
                     if (fwrite($fh, $data) != strlen($data)) {
-                        return PEAR::raiseError(sprintf(_("Error writing \"%s\"."), $targetFile));
+                        return PEAR::raiseError(sprintf($this->_dict->t("Error writing \"%s\"."), $targetFile));
                     }
                     fclose($fh);
                 }
index db39b16..ce3b6dc 100644 (file)
@@ -10,7 +10,7 @@
  * @author  Jason M. Felice <jason.m.felice@gmail.com>
  * @package VFS_ISO
  */
-class VFS_ISOWriter_RealOutputStrategy {
+abstract class VFS_ISOWriter_RealOutputStrategy {
 
     /**
      * The VFS to which we will write the file.
@@ -27,16 +27,31 @@ class VFS_ISOWriter_RealOutputStrategy {
     var $_targetFile;
 
     /**
+     * Translation provider.
+     *
+     * @var Horde_Translation
+     */
+    protected $_dict;
+
+    /**
      * Constructor
      *
      * @param object &$targetVfs        The VFS to which we will write the
      *                                  file.
      * @param string $targetFile        The path and name of file to write.
+     * @param array $params  Hash with configuration data. Possible values:
+     *                       - 'translation': A translation handler
+     *                                        implementing Horde_Translation.
      */
-    function VFS_ISOWriter_RealOutputStrategy(&$targetVfs, $targetFile)
+    function VFS_ISOWriter_RealOutputStrategy(&$targetVfs, $targetFile, $params = array())
     {
         $this->_targetVfs = &$targetVfs;
         $this->_targetFile = $targetFile;
+        if (isset($params['translation'])) {
+            $this->_dict = $params['translation'];
+        } else {
+            $this->_dict = new Horde_Translation_Gettext('VFS_ISOWriter', dirname(__FILE__) . '/../locale');
+        }
     }
 
     /**
@@ -62,7 +77,7 @@ class VFS_ISOWriter_RealOutputStrategy {
         if (class_exists($class)) {
             $strategy = new $class($targetVfs, $targetFile);
         } else {
-            $strategy = PEAR::raiseError(sprintf(_("Could not load strategy \"%s\"."),
+            $strategy = PEAR::raiseError(sprintf($this->_dict->t("Could not load strategy \"%s\"."),
                                                  $method));
         }
 
@@ -72,23 +87,14 @@ class VFS_ISOWriter_RealOutputStrategy {
     /**
      * Get a real filesystem filename we can write to.
      *
-     * @abstract
      * @return string   The filename or PEAR_Error on failure.
      */
-    function getRealFilename()
-    {
-        return PEAR::raiseError(_("Not implemented."));
-    }
+    abstract public function getRealFilename();
 
     /**
      * Indicate that we're done writing to the real file.
      *
-     * @abstract
      * @return mixed    Null or PEAR_Error on failure.
      */
-    function finished()
-    {
-        return PEAR::raiseError(_("Not implemented."));
-    }
-
+    abstract public function finished();
 }
index b2e29d2..5e0be19 100644 (file)
@@ -45,7 +45,7 @@ class VFS_ISOWriter_RealOutputStrategy_copy extends VFS_ISOWriter_RealOutputStra
             }
 
             if (empty($tmp)) {
-                return PEAR::raiseError(_("Cannot find a temporary directory."));
+                return PEAR::raiseError($this->_dict->t("Cannot find a temporary directory."));
             }
 
             $this->_tempFilename = tempnam($tmp, 'iso');
index a6082b2..3b2621e 100644 (file)
@@ -23,7 +23,7 @@ class VFS_ISOWriter_RealOutputStrategy_direct extends VFS_ISOWriter_RealOutputSt
         $dir = dirname($filename);
         while (!@is_dir($dir)) {
             if (!@mkdir($dir, 0755)) {
-                return PEAR::raiseError(sprintf(_("Could not mkdir \"%s\"."),
+                return PEAR::raiseError(sprintf($this->_dict->t("Could not mkdir \"%s\"."),
                                                 $dir));
             }
             $dir = dirname($dir);
index a872e2c..93f6b3c 100644 (file)
@@ -43,10 +43,10 @@ class VFS_ISOWriter_mkisofs extends VFS_ISOWriter {
         }
 
         if ($res === false) {
-            return PEAR::raiseError(_("Unable to run 'mkisofs'."));
+            return PEAR::raiseError($this->_dict->t("Unable to run 'mkisofs'."));
         }
         if ($ec != 0) {
-            return PEAR::raiseError(sprintf(_("mkisofs error code %d while making ISO."), $ec));
+            return PEAR::raiseError(sprintf($this->_dict->t("mkisofs error code %d while making ISO."), $ec));
         }
     }
 
index 8e1daba..3705ac0 100755 (executable)
@@ -30,9 +30,9 @@ if ($live) {
     $values = array($scope, $name);
     try {
         if ($db->delete($sql, $values)) {
-            $cli->writeln(sprintf(_("Preferences \"%s\" deleted in scope \"%s\"."), $name, $scope));
+            $cli->writeln(sprintf('Preferences "%s" deleted in scope "%s".'), $name, $scope));
         } else {
-            $cli->writeln(sprintf(_("No preference \"%s\" found in scope \"%s\"."), $name, $scope));
+            $cli->writeln(sprintf('No preference "%s" found in scope "%s".'), $name, $scope));
         }
     } catch (Horde_Db_Exception $e) {
         print_r($e);
@@ -44,7 +44,7 @@ if ($live) {
         if ($result = $db->selectAll($sql, $values)) {
             var_dump($result);
         } else {
-            $cli->writeln(sprintf(_("No preference \"%s\" found in scope \"%s\"."), $name, $scope));
+            $cli->writeln(sprintf('No preference "%s" found in scope "%s".'), $name, $scope));
         }
     } catch (Horde_Db_Exception $e) {
         print_r($e);