From 1526c4e2f0121646bf75285f8b25fdb3865aa60c Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Tue, 12 Oct 2010 19:00:07 +0200 Subject: [PATCH] Use Horde_Translation to provide translations for framework packages. --- framework/Alarm/lib/Horde/Alarm/Handler.php | 16 +- .../Alarm/lib/Horde/Alarm/Handler/Desktop.php | 3 +- framework/Alarm/lib/Horde/Alarm/Handler/Mail.php | 6 +- framework/Alarm/lib/Horde/Alarm/Handler/Notify.php | 6 +- .../lib/Horde/Argv/AmbiguousOptionException.php | 2 +- .../Argv/lib/Horde/Argv/BadOptionException.php | 2 +- framework/Argv/lib/Horde/Argv/HelpFormatter.php | 17 +- .../Argv/lib/Horde/Argv/IndentedHelpFormatter.php | 2 +- framework/Argv/lib/Horde/Argv/Option.php | 31 +- framework/Argv/lib/Horde/Argv/OptionException.php | 2 +- framework/Argv/lib/Horde/Argv/Parser.php | 31 +- .../Argv/lib/Horde/Argv/TitledHelpFormatter.php | 2 +- framework/Block/lib/Horde/Block.php | 18 +- framework/Block/lib/Horde/Block/Collection.php | 21 +- framework/Block/lib/Horde/Block/Layout.php | 33 +- framework/Block/lib/Horde/Block/Layout/Manager.php | 16 +- framework/Block/lib/Horde/Block/Layout/View.php | 2 +- framework/Block/lib/Horde/Block/Ui.php | 22 +- framework/Browser/lib/Horde/Browser.php | 2 +- framework/Cli/lib/Horde/Cli.php | 24 +- framework/Compress/lib/Horde/Compress.php | 22 + framework/Compress/lib/Horde/Compress/Dbx.php | 6 +- framework/Compress/lib/Horde/Compress/Gzip.php | 6 +- framework/Compress/lib/Horde/Compress/Rar.php | 2 +- framework/Compress/lib/Horde/Compress/Tar.php | 2 +- framework/Compress/lib/Horde/Compress/Zip.php | 8 +- framework/Core/lib/Horde.php | 36 +- framework/Core/lib/Horde/Core/Ajax/Application.php | 3 +- framework/Core/lib/Horde/Core/Auth/Application.php | 11 +- framework/Core/lib/Horde/Core/Auth/Signup/Base.php | 25 +- framework/Core/lib/Horde/Core/Auth/Signup/Form.php | 20 +- framework/Core/lib/Horde/Core/Auth/Signup/Sql.php | 3 +- framework/Core/lib/Horde/Core/Factory/History.php | 3 +- framework/Core/lib/Horde/Core/Factory/Prefs.php | 12 +- framework/Core/lib/Horde/Core/Factory/Share.php | 3 +- framework/Core/lib/Horde/Core/Factory/Twitter.php | 3 +- framework/Core/lib/Horde/Core/Factory/Vfs.php | 3 +- .../Core/lib/Horde/Core/Mime/Viewer/Vcard.php | 91 ++-- .../Core/lib/Horde/Core/Notification/Status.php | 33 +- framework/Core/lib/Horde/Core/Perms/Ui.php | 60 +-- framework/Core/lib/Horde/Core/Prefs/Identity.php | 29 +- framework/Core/lib/Horde/Core/Prefs/Ui.php | 37 +- framework/Core/lib/Horde/Core/Prefs/Ui/Widgets.php | 33 +- framework/Core/lib/Horde/Core/Sidebar.php | 13 +- .../lib/Horde/Core/Text/Filter/Highlightquotes.php | 13 +- framework/Core/lib/Horde/Core/Ui/JsCalendar.php | 61 +-- framework/Core/lib/Horde/Core/Ui/Pager.php | 13 +- .../Core/lib/Horde/Core/Ui/VarRenderer/Html.php | 169 ++++--- .../lib/Horde/Core/Ui/VarRenderer/TablesetHtml.php | 6 +- framework/Core/lib/Horde/Help.php | 5 +- framework/Core/lib/Horde/Menu.php | 19 +- framework/Core/lib/Horde/Registry.php | 20 +- framework/Core/lib/Horde/Script/Files.php | 17 +- framework/Crypt/lib/Horde/Crypt.php | 24 +- framework/Crypt/lib/Horde/Crypt/Pgp.php | 66 +-- framework/Crypt/lib/Horde/Crypt/Smime.php | 132 +++--- framework/Data/lib/Horde/Data/Base.php | 26 +- framework/Data/lib/Horde/Data/Tsv.php | 2 +- framework/DataTree/DataTree.php | 2 +- framework/DataTree/DataTree/sql.php | 8 +- framework/Date/lib/Horde/Date/Recurrence.php | 16 +- framework/Date/lib/Horde/Date/Utils.php | 32 +- .../Exception/lib/Horde/Exception/NotFound.php | 15 +- .../lib/Horde/Exception/PermissionDenied.php | 15 +- framework/File_Csv/lib/Horde/File/Csv.php | 5 +- framework/Form/Form.php | 24 +- framework/Form/Form/Renderer.php | 29 +- framework/Form/Form/Type.php | 431 +++++++++--------- framework/Form/Form/Type/tableset.php | 8 +- framework/Form/Form/Variable.php | 23 +- framework/Icalendar/lib/Horde/Icalendar/Vevent.php | 3 +- framework/Image/lib/Horde/Image/Exif.php | 314 ++++++------- framework/Image/lib/Horde/Image/Exif/Base.php | 13 + framework/Image/lib/Horde/Image/Exif/Bundled.php | 30 +- .../Image/lib/Horde/Image/Exif/Parser/Base.php | 22 + .../Image/lib/Horde/Image/Exif/Parser/Canon.php | 220 ++++----- .../Image/lib/Horde/Image/Exif/Parser/Fujifilm.php | 140 +++--- .../Image/lib/Horde/Image/Exif/Parser/Nikon.php | 74 +-- .../Image/lib/Horde/Image/Exif/Parser/Olympus.php | 4 +- .../lib/Horde/Image/Exif/Parser/Panasonic.php | 174 +++---- .../Image/lib/Horde/Image/Exif/Parser/Sanyo.php | 6 +- framework/Itip/lib/Horde/Itip/Event/Vevent.php | 18 +- .../Itip/lib/Horde/Itip/Response/Type/Accept.php | 6 +- .../Itip/lib/Horde/Itip/Response/Type/Base.php | 21 +- .../Itip/lib/Horde/Itip/Response/Type/Decline.php | 6 +- .../lib/Horde/Itip/Response/Type/Tentative.php | 6 +- framework/Kolab/Kolab.php | 13 +- .../lib/Horde/Kolab/Filter/Content.php | 2 +- framework/Kolab_Format/lib/Horde/Kolab/Format.php | 2 +- .../Kolab_Format/lib/Horde/Kolab/Format/Xml.php | 25 +- .../lib/Horde/Kolab/FreeBusy/Driver/Base.php | 20 +- .../Horde/Kolab/FreeBusy/Driver/Freebusy/Base.php | 4 +- .../Horde/Kolab/FreeBusy/Driver/Freebusy/Kolab.php | 4 +- .../lib/Horde/Kolab/FreeBusy/Imap.php | 19 +- .../lib/Horde/Kolab/FreeBusy/Report.php | 25 +- .../lib/Horde/Kolab/FreeBusy/View.php | 24 +- .../Kolab_Resource/lib/Horde/Kolab/Resource.php | 30 +- .../Kolab_Storage/lib/Horde/Kolab/Storage/Data.php | 25 +- framework/LoginTasks/lib/Horde/LoginTasks.php | 19 +- framework/Mime/lib/Horde/Mime/Headers.php | 22 +- framework/Mime/lib/Horde/Mime/Mail.php | 21 +- framework/Mime/lib/Horde/Mime/Mdn.php | 20 +- .../Mime_Viewer/lib/Horde/Mime/Viewer/Base.php | 33 +- .../Mime_Viewer/lib/Horde/Mime/Viewer/Msword.php | 2 +- .../Mime_Viewer/lib/Horde/Mime/Viewer/Rar.php | 20 +- .../Mime_Viewer/lib/Horde/Mime/Viewer/Rfc822.php | 14 +- .../Mime_Viewer/lib/Horde/Mime/Viewer/Rtf.php | 2 +- .../Mime_Viewer/lib/Horde/Mime/Viewer/Tgz.php | 16 +- .../lib/Horde/Mime/Viewer/Wordperfect.php | 2 +- .../Mime_Viewer/lib/Horde/Mime/Viewer/Zip.php | 18 +- framework/Model/lib/Horde/Form.php | 347 +++++++------- framework/Model/lib/Horde/Form/Renderer.php | 23 +- framework/Model/lib/Horde/Form/Renderer/Xhtml.php | 6 +- framework/Model/lib/Horde/Form/Type.php | 21 +- framework/Model/lib/Horde/Form/Type/Color.php | 4 +- framework/Model/lib/Horde/Form/Type/CreditCard.php | 4 +- framework/Model/lib/Horde/Form/Type/Date.php | 12 +- framework/Model/lib/Horde/Form/Type/Email.php | 16 +- framework/Model/lib/Horde/Form/Type/Enum.php | 4 +- framework/Model/lib/Horde/Form/Type/Int.php | 4 +- framework/Model/lib/Horde/Form/Type/Number.php | 4 +- framework/Model/lib/Horde/Form/Type/Octal.php | 4 +- framework/Model/lib/Horde/Form/Type/Password.php | 6 +- framework/Model/lib/Horde/Form/Type/Phone.php | 4 +- framework/Model/lib/Horde/Form/Type/Set.php | 6 +- framework/Model/lib/Horde/Form/Type/String.php | 6 +- framework/Model/lib/Horde/Form/Type/Time.php | 4 +- .../Model/lib/Horde/Form/VarRenderer/Xhtml.php | 147 +++--- framework/Net_IMSP/IMSP.php | 16 +- framework/Net_IMSP/IMSP/Auth.php | 25 +- framework/Net_IMSP/IMSP/Book.php | 14 +- framework/Nls/lib/Horde/Nls/Countries.php | 480 ++++++++++---------- framework/Nls/lib/Horde/Nls/Geoip.php | 28 +- framework/Nls/lib/Horde/Nls/Tld.php | 502 +++++++++++---------- framework/Perms/lib/Horde/Perms.php | 28 +- framework/Prefs/lib/Horde/Prefs.php | 42 +- .../Prefs/lib/Horde/Prefs/CategoryManager.php | 20 +- framework/Prefs/lib/Horde/Prefs/Identity.php | 59 ++- framework/Prefs/lib/Horde/Prefs/Ldap.php | 2 +- framework/Rpc/lib/Horde/Rpc.php | 15 +- framework/Rpc/lib/Horde/Rpc/Phpgw.php | 10 +- framework/Rpc/lib/Horde/Rpc/Soap.php | 4 +- framework/Rpc/lib/Horde/Rpc/Webdav.php | 6 +- .../lib/Horde/Service/Facebook/Request.php | 12 +- .../lib/Horde/Service/Facebook/UploadRequest.php | 9 +- .../Service_Scribd/lib/Horde/Block/Scribd.php | 30 +- framework/Share/lib/Horde/Share.php | 21 +- framework/Share/lib/Horde/Share/Kolab.php | 4 +- framework/Share/lib/Horde/Share/Object/Kolab.php | 33 +- framework/Share/lib/Horde/Share/Sql.php | 4 +- .../Share/lib/Horde/Share/Sql/Hierarchical.php | 2 +- framework/SyncML/SyncML/Backend.php | 14 + framework/SyncML/SyncML/Device/Sync4j.php | 2 +- framework/Template/lib/Horde/Template.php | 2 + .../Text_Filter/lib/Horde/Text/Filter/Base.php | 12 + .../lib/Horde/Text/Filter/Html2text.php | 4 +- framework/VFS/lib/VFS.php | 12 + framework/VFS/lib/VFS/smb.php | 4 +- framework/VFS/lib/VFS/sql_file.php | 2 +- framework/VFS_ISOWriter/ISOWriter.php | 26 +- .../VFS_ISOWriter/ISOWriter/RealInputStrategy.php | 30 +- .../ISOWriter/RealInputStrategy/copy.php | 14 +- .../VFS_ISOWriter/ISOWriter/RealOutputStrategy.php | 34 +- .../ISOWriter/RealOutputStrategy/copy.php | 2 +- .../ISOWriter/RealOutputStrategy/direct.php | 2 +- framework/VFS_ISOWriter/ISOWriter/mkisofs.php | 4 +- framework/admintools/horde-remove-pref.php | 6 +- 167 files changed, 3267 insertions(+), 2233 deletions(-) diff --git a/framework/Alarm/lib/Horde/Alarm/Handler.php b/framework/Alarm/lib/Horde/Alarm/Handler.php index 7e7a5ca9a..8dafdca73 100644 --- a/framework/Alarm/lib/Horde/Alarm/Handler.php +++ b/framework/Alarm/lib/Horde/Alarm/Handler.php @@ -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. diff --git a/framework/Alarm/lib/Horde/Alarm/Handler/Desktop.php b/framework/Alarm/lib/Horde/Alarm/Handler/Desktop.php index b8c12b9ea..8198ab416 100644 --- a/framework/Alarm/lib/Horde/Alarm/Handler/Desktop.php +++ b/framework/Alarm/lib/Horde/Alarm/Handler/Desktop.php @@ -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)"); } } diff --git a/framework/Alarm/lib/Horde/Alarm/Handler/Mail.php b/framework/Alarm/lib/Horde/Alarm/Handler/Mail.php index dc5da334e..c35ee653d 100644 --- a/framework/Alarm/lib/Horde/Alarm/Handler/Mail.php +++ b/framework/Alarm/lib/Horde/Alarm/Handler/Mail.php @@ -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)); } } diff --git a/framework/Alarm/lib/Horde/Alarm/Handler/Notify.php b/framework/Alarm/lib/Horde/Alarm/Handler/Notify.php index f3ac2c764..90cd4ba01 100644 --- a/framework/Alarm/lib/Horde/Alarm/Handler/Notify.php +++ b/framework/Alarm/lib/Horde/Alarm/Handler/Notify.php @@ -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)); } } diff --git a/framework/Argv/lib/Horde/Argv/AmbiguousOptionException.php b/framework/Argv/lib/Horde/Argv/AmbiguousOptionException.php index ccfbd6419..465b7a824 100644 --- a/framework/Argv/lib/Horde/Argv/AmbiguousOptionException.php +++ b/framework/Argv/lib/Horde/Argv/AmbiguousOptionException.php @@ -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))); } } diff --git a/framework/Argv/lib/Horde/Argv/BadOptionException.php b/framework/Argv/lib/Horde/Argv/BadOptionException.php index 56783f4a7..319ad37dd 100644 --- a/framework/Argv/lib/Horde/Argv/BadOptionException.php +++ b/framework/Argv/lib/Horde/Argv/BadOptionException.php @@ -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)); } } diff --git a/framework/Argv/lib/Horde/Argv/HelpFormatter.php b/framework/Argv/lib/Horde/Argv/HelpFormatter.php index 1c554686e..772d9a7f9 100644 --- a/framework/Argv/lib/Horde/Argv/HelpFormatter.php +++ b/framework/Argv/lib/Horde/Argv/HelpFormatter.php @@ -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)) { diff --git a/framework/Argv/lib/Horde/Argv/IndentedHelpFormatter.php b/framework/Argv/lib/Horde/Argv/IndentedHelpFormatter.php index 42f09b502..bff6815d1 100644 --- a/framework/Argv/lib/Horde/Argv/IndentedHelpFormatter.php +++ b/framework/Argv/lib/Horde/Argv/IndentedHelpFormatter.php @@ -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) diff --git a/framework/Argv/lib/Horde/Argv/Option.php b/framework/Argv/lib/Horde/Argv/Option.php index 1e6e709fd..85dc9ed99 100644 --- a/framework/Argv/lib/Horde/Argv/Option.php +++ b/framework/Argv/lib/Horde/Argv/Option.php @@ -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 diff --git a/framework/Argv/lib/Horde/Argv/OptionException.php b/framework/Argv/lib/Horde/Argv/OptionException.php index 4d1516c91..1e77c4c88 100644 --- a/framework/Argv/lib/Horde/Argv/OptionException.php +++ b/framework/Argv/lib/Horde/Argv/OptionException.php @@ -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); } diff --git a/framework/Argv/lib/Horde/Argv/Parser.php b/framework/Argv/lib/Horde/Argv/Parser.php index f4dfffe72..149a45c05 100644 --- a/framework/Argv/lib/Horde/Argv/Parser.php +++ b/framework/Argv/lib/Horde/Argv/Parser.php @@ -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); diff --git a/framework/Argv/lib/Horde/Argv/TitledHelpFormatter.php b/framework/Argv/lib/Horde/Argv/TitledHelpFormatter.php index 6fcf72ae2..800fafb2b 100644 --- a/framework/Argv/lib/Horde/Argv/TitledHelpFormatter.php +++ b/framework/Argv/lib/Horde/Argv/TitledHelpFormatter.php @@ -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) diff --git a/framework/Block/lib/Horde/Block.php b/framework/Block/lib/Horde/Block.php index fcaf444da..006002f16 100644 --- a/framework/Block/lib/Horde/Block.php +++ b/framework/Block/lib/Horde/Block.php @@ -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. diff --git a/framework/Block/lib/Horde/Block/Collection.php b/framework/Block/lib/Horde/Block/Collection.php index 9e6b1f400..d958e3f6a 100644 --- a/framework/Block/lib/Horde/Block/Collection.php +++ b/framework/Block/lib/Horde/Block/Collection.php @@ -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); } /** diff --git a/framework/Block/lib/Horde/Block/Layout.php b/framework/Block/lib/Horde/Block/Layout.php index 963d8e7f3..2303a6670 100644 --- a/framework/Block/lib/Horde/Block/Layout.php +++ b/framework/Block/lib/Horde/Block/Layout.php @@ -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")) . ''; } 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")) . ''; } return $icons; diff --git a/framework/Block/lib/Horde/Block/Layout/Manager.php b/framework/Block/lib/Horde/Block/Layout/Manager.php index fc97da6ac..2b1682569 100644 --- a/framework/Block/lib/Horde/Block/Layout/Manager.php +++ b/framework/Block/lib/Horde/Block/Layout/Manager.php @@ -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; } diff --git a/framework/Block/lib/Horde/Block/Layout/View.php b/framework/Block/lib/Horde/Block/Layout/View.php index ef9f8348f..3dc51b973 100644 --- a/framework/Block/lib/Horde/Block/Layout/View.php +++ b/framework/Block/lib/Horde/Block/Layout/View.php @@ -95,7 +95,7 @@ class Horde_Block_Layout_View extends Horde_Block_Layout $html .= ' '; } } catch (Horde_Exception $e) { - $header = _("Error"); + $header = $this->_dict->t("Error"); $content = $e->getMessage(); ob_start(); include $tplDir . '/portal/block.inc'; diff --git a/framework/Block/lib/Horde/Block/Ui.php b/framework/Block/lib/Horde/Block/Ui.php index c6caf1499..6f9e0e80e 100644 --- a/framework/Block/lib/Horde/Block/Ui.php +++ b/framework/Block/lib/Horde/Block/Ui.php @@ -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'])) { diff --git a/framework/Browser/lib/Horde/Browser.php b/framework/Browser/lib/Horde/Browser.php index d5f6520b8..e25094ecd 100644 --- a/framework/Browser/lib/Horde/Browser.php +++ b/framework/Browser/lib/Horde/Browser.php @@ -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())) { diff --git a/framework/Cli/lib/Horde/Cli.php b/framework/Cli/lib/Horde/Cli.php index 978f7f6ed..219b089cc 100644 --- a/framework/Cli/lib/Horde/Cli.php +++ b/framework/Cli/lib/Horde/Cli.php @@ -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(); diff --git a/framework/Compress/lib/Horde/Compress.php b/framework/Compress/lib/Horde/Compress.php index c76ab87a0..eb9745760 100644 --- a/framework/Compress/lib/Horde/Compress.php +++ b/framework/Compress/lib/Horde/Compress.php @@ -14,6 +14,13 @@ 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. diff --git a/framework/Compress/lib/Horde/Compress/Dbx.php b/framework/Compress/lib/Horde/Compress/Dbx.php index e583878fd..04fd0beed 100644 --- a/framework/Compress/lib/Horde/Compress/Dbx.php +++ b/framework/Compress/lib/Horde/Compress/Dbx.php @@ -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. diff --git a/framework/Compress/lib/Horde/Compress/Gzip.php b/framework/Compress/lib/Horde/Compress/Gzip.php index c3f4d7f9b..1a1ff65fa 100644 --- a/framework/Compress/lib/Horde/Compress/Gzip.php +++ b/framework/Compress/lib/Horde/Compress/Gzip.php @@ -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; diff --git a/framework/Compress/lib/Horde/Compress/Rar.php b/framework/Compress/lib/Horde/Compress/Rar.php index 977d3e14f..80611b860 100644 --- a/framework/Compress/lib/Horde/Compress/Rar.php +++ b/framework/Compress/lib/Horde/Compress/Rar.php @@ -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); diff --git a/framework/Compress/lib/Horde/Compress/Tar.php b/framework/Compress/lib/Horde/Compress/Tar.php index 1bb866de9..edb130651 100644 --- a/framework/Compress/lib/Horde/Compress/Tar.php +++ b/framework/Compress/lib/Horde/Compress/Tar.php @@ -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; diff --git a/framework/Compress/lib/Horde/Compress/Zip.php b/framework/Compress/lib/Horde/Compress/Zip.php index 9391acc67..18c4b2868 100644 --- a/framework/Compress/lib/Horde/Compress/Zip.php +++ b/framework/Compress/lib/Horde/Compress/Zip.php @@ -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']); diff --git a/framework/Core/lib/Horde.php b/framework/Core/lib/Horde.php index 6b318960a..ab5cbc9dd 100644 --- a/framework/Core/lib/Horde.php +++ b/framework/Core/lib/Horde.php @@ -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 = '

' . _("A fatal error has occurred") . '

'; + $errortext = '

' . $dict->t("A fatal error has occurred") . '

'; 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 .= '
' . (string)$backtrace . '
'; if (is_object($error)) { - $errortext .= '

' . _("Details") . '

'; - $errortext .= '

' . _("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.") . '

'; + $errortext .= '

' . $dict->t("Details") . '

'; + $errortext .= '

' . $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.") . '

'; $errortext .= '
' . htmlspecialchars(print_r($error, true)) . '
'; } } elseif ($log) { - $errortext .= '

' . _("Details have been logged for the administrator.") . '

'; + $errortext .= '

' . $dict->t("Details have been logged for the administrator.") . '

'; } // 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( diff --git a/framework/Core/lib/Horde/Core/Ajax/Application.php b/framework/Core/lib/Horde/Core/Ajax/Application.php index 64dcb40cc..b41425c34 100644 --- a/framework/Core/lib/Horde/Core/Ajax/Application.php +++ b/framework/Core/lib/Horde/Core/Ajax/Application.php @@ -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( diff --git a/framework/Core/lib/Horde/Core/Auth/Application.php b/framework/Core/lib/Horde/Core/Auth/Application.php index c9428c3a7..2d4e0ecb1 100644 --- a/framework/Core/lib/Horde/Core/Auth/Application.php +++ b/framework/Core/lib/Horde/Core/Auth/Application.php @@ -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')) { diff --git a/framework/Core/lib/Horde/Core/Auth/Signup/Base.php b/framework/Core/lib/Horde/Core/Auth/Signup/Base.php index 6bfd76b29..3315d7050 100644 --- a/framework/Core/lib/Horde/Core/Auth/Signup/Base.php +++ b/framework/Core/lib/Horde/Core/Auth/Signup/Base.php @@ -17,6 +17,21 @@ 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'])); } } diff --git a/framework/Core/lib/Horde/Core/Auth/Signup/Form.php b/framework/Core/lib/Horde/Core/Auth/Signup/Form.php index 7b5ce9d31..2d2cd888a 100644 --- a/framework/Core/lib/Horde/Core/Auth/Signup/Form.php +++ b/framework/Core/lib/Horde/Core/Auth/Signup/Form.php @@ -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")); } } diff --git a/framework/Core/lib/Horde/Core/Auth/Signup/Sql.php b/framework/Core/lib/Horde/Core/Auth/Signup/Sql.php index ac5fd0b6a..6c8b9c6b1 100644 --- a/framework/Core/lib/Horde/Core/Auth/Signup/Sql.php +++ b/framework/Core/lib/Horde/Core/Auth/Signup/Sql.php @@ -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); diff --git a/framework/Core/lib/Horde/Core/Factory/History.php b/framework/Core/lib/Horde/Core/Factory/History.php index d8ea5036f..4d235c8e0 100644 --- a/framework/Core/lib/Horde/Core/Factory/History.php +++ b/framework/Core/lib/Horde/Core/Factory/History.php @@ -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']); diff --git a/framework/Core/lib/Horde/Core/Factory/Prefs.php b/framework/Core/lib/Horde/Core/Factory/Prefs.php index 6668e8411..153c71ec3 100644 --- a/framework/Core/lib/Horde/Core/Factory/Prefs.php +++ b/framework/Core/lib/Horde/Core/Factory/Prefs.php @@ -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; } diff --git a/framework/Core/lib/Horde/Core/Factory/Share.php b/framework/Core/lib/Horde/Core/Factory/Share.php index 6d56b9a8e..da0935497 100644 --- a/framework/Core/lib/Horde/Core/Factory/Share.php +++ b/framework/Core/lib/Horde/Core/Factory/Share.php @@ -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')); diff --git a/framework/Core/lib/Horde/Core/Factory/Twitter.php b/framework/Core/lib/Horde/Core/Factory/Twitter.php index bb3af490a..ad6227492 100644 --- a/framework/Core/lib/Horde/Core/Factory/Twitter.php +++ b/framework/Core/lib/Horde/Core/Factory/Twitter.php @@ -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")); } } } diff --git a/framework/Core/lib/Horde/Core/Factory/Vfs.php b/framework/Core/lib/Horde/Core/Factory/Vfs.php index bd701d173..02063266b 100644 --- a/framework/Core/lib/Horde/Core/Factory/Vfs.php +++ b/framework/Core/lib/Horde/Core/Factory/Vfs.php @@ -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') diff --git a/framework/Core/lib/Horde/Core/Mime/Viewer/Vcard.php b/framework/Core/lib/Horde/Core/Mime/Viewer/Vcard.php index 1d922a352..c16b05ab0 100644 --- a/framework/Core/lib/Horde/Core/Mime/Viewer/Vcard.php +++ b/framework/Core/lib/Horde/Core/Mime/Viewer/Vcard.php @@ -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"), '', 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"), '', false); } elseif ($this->_imageUrl) { - $html .= $this->_row(_("Photo"), + $html .= $this->_row($this->_coreDict->t("Photo"), '', 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"), '' . htmlspecialchars($url[0]) . '', @@ -403,9 +412,9 @@ class Horde_Core_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Base if (count($sources) > 1) { $html .= '' + . $this->_coreDict->t("Add to address book:") . '" />' . '' + . $this->_coreDict->t("Address Book") . '' . '' + . $this->_coreDict->t("Add to my address book") . '" />' . ''; } diff --git a/framework/Core/lib/Horde/Core/Notification/Status.php b/framework/Core/lib/Horde/Core/Notification/Status.php index 55ce913d5..acba9f840 100644 --- a/framework/Core/lib/Horde/Core/Notification/Status.php +++ b/framework/Core/lib/Horde/Core/Notification/Status.php @@ -14,6 +14,13 @@ 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 .= ' [' . _("Snooze...") . '