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.
*/
public function __construct(array $params = null)
{
+ parent::__construct($params);
/*
if (!isset($params['js_notify'])) {
throw new InvalidArgumentException('Parameter \'js_notify\' missing.');
*/
public function getDescription()
{
- return _("Desktop notification (with certain browsers)");
+ return $this->_dict->t("Desktop notification (with certain browsers)");
}
}
*/
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.');
*/
public function getDescription()
{
- return _("Email");
+ return $this->_dict->t("Email");
}
/**
return array(
'email' => array(
'type' => 'text',
- 'desc' => _("Email address (optional)"),
+ 'desc' => $this->_dict->t("Email address (optional)"),
'required' => false));
}
}
*/
public function __construct(array $params = null)
{
+ parent::__construct($params);
+
/*
if (!isset($params['notification'])) {
throw new Horde_Alarm_Exception('Parameter \'notification\' missing.');
*/
public function getDescription()
{
- return _("Inline");
+ return $this->_dict->t("Inline");
}
/**
return array(
'sound' => array(
'type' => 'sound',
- 'desc' => _("Play a sound?"),
+ 'desc' => $this->_dict->t("Play a sound?"),
'required' => false));
}
}
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)));
}
}
{
public function __construct($opt_str)
{
- parent::__construct(sprintf(_("no such option: %s"), $opt_str));
+ parent::__construct(sprintf('no such option: %s', $opt_str));
}
}
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)) {
public function formatUsage($usage)
{
- return sprintf(_("Usage:") . " %s\n", $usage);
+ return sprintf($this->_dict->t("Usage:") . " %s\n", $usage);
}
public function formatHeading($heading)
*/
public static $NO_DEFAULT = array('NO', 'DEFAULT');
+ /**
+ * Translation provider.
+ *
+ * @var Horde_Translation
+ */
+ protected $_dict;
+
public static function parseNumber($value)
{
if (!strlen($value)) {
$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));
}
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);
}
$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));
}
}
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();
}
}
+ /**
+ * 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
{
$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);
}
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,
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)
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
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) {
}
} 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;
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) {
$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);
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)
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.
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.
/**
* 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;
{
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);
}
/**
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.
$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;
}
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];
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;
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]) {
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;
}
$html .= '<td width="' . ($width * $colspan) . '%"> </td>';
}
} catch (Horde_Exception $e) {
- $header = _("Error");
+ $header = $this->_dict->t("Error");
$content = $e->getMessage();
ob_start();
include $tplDir . '/portal/block.inc';
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();
}
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. */
/* 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'])) {
public function wasFileUploaded($field, $name = null)
{
if (is_null($name)) {
- $name = _("file");
+ $name = 'file';
}
if (!($uploadSize = self::allowFileUploads())) {
);
/**
+ * 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) {
}
$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);
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.
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();
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
}
/**
+ * 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.
}
$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']);
$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'];
{
$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.
{
/* 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;
$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;
{
$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);
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;
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();
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']);
((($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));
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']);
{
$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'))) {
$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.
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']));
}
}
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."));
}
}
$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)));
}
$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 . '"';
$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(
}
$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(
);
/**
+ * Translation provider.
+ *
+ * @var Horde_Translation
+ */
+ protected $_coreDict;
+
+ /**
* Constructor.
*
* @param array $params Required parameters:
unset($params['base']);
}
+ $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../locale');
+
parent::__construct($params);
}
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')) {
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.
*
'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'],
// 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']));
}
}
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);
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;
$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"));
}
}
*/
public function __construct()
{
+ parent::__construct();
$this->_params = array_merge(
$this->_params,
array('table' => 'horde_signups'),
$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);
{
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']);
private $_injector;
/**
+ * Translation provider.
+ *
+ * @var Horde_Translation
+ */
+ protected $_coreDict;
+
+ /**
* Constructor.
*
* @param Horde_Injector $injector The injector to use.
public function __construct(Horde_Injector $injector)
{
$this->_injector = $injector;
+ $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../locale');
}
/**
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);
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;
}
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'));
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"));
}
}
}
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')
protected $_imageUrl;
/**
+ * Translation provider.
+ *
+ * @var Horde_Translation
+ */
+ protected $_coreDict;
+
+ /**
* Constructor.
*
* @param Horde_Mime_Part $mime_part The object with the data to be
*/
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',
$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') &&
$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),
$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) {}
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']) &&
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);
}
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']);
}
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));
}
}
}
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']);
}
}
}
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>',
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'))
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)) . '" />';
}
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
*/
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'
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) {
}
$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;
protected $_type = 'matrix';
/**
+ * Translation provider.
+ *
+ * @var Horde_Translation
+ */
+ protected $_coreDict;
+
+ /**
* Constructor.
*
* @param Horde_Perms $perms The object to display UI stuff for.
public function __construct($perms)
{
$this->_perms = $perms;
+ $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../locale');
}
/**
$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. */
? 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 {
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);
/* 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);
$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));
}
}
}
/* 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);
/* 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. */
/* 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. */
/* 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. */
/* 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
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"' : '';
/* 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();
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"' : '';
}
/* 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())));
}
/**
/* 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);
}
/**
{
$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;
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
$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);
$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');
$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');
}
/**
$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;
}
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');
}
/**
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();
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;
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;
}
}
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);
}
}
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);
}
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;
}
$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. */
);
}
$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));
$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');
}
$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;
}
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. */
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 {
*/
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. */
/**
));
}
- $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');
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);
Horde::addInlineJsVars(array(
'HordeAddressbooksPrefs.fields' => $js,
- 'HordeAddressbooksPrefs.nonetext' => _("No address book selected.")
+ 'HordeAddressbooksPrefs.nonetext' => $this->_coreDict->t("No address book selected.")
));
}
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;
}
}
{
global $injector, $registry;
+ $dict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../locale');
$isAdmin = $registry->isAdmin();
$menu = $parents = array();
// 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'
);
!($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'
);
$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')
);
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')
);
// 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.
*/
class Horde_Core_Text_Filter_Highlightquotes extends Horde_Text_Filter_Highlightquotes
{
+ /**
+ * Translation provider.
+ *
+ * @var Horde_Translation
+ */
+ protected $_coreDict;
+
/**
* Constructor.
*
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');
}
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>';
}
/**
static protected $_initRun = false;
/**
+ * Translation provider.
+ *
+ * @var Horde_Translation
+ */
+ static protected $_coreDict;
+
+ /**
* Output the necessary javascript code to allow display of the calendar
* widget.
*
}
self::$_initRun = true;
+ self::$_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../../../locale');
+
$params = array_merge(array(
'click_month' => false,
'click_week' => false,
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")
);
}
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"),
);
}
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")
);
}
class Horde_Core_Ui_Pager extends Horde_Core_Ui_Widget
{
/**
+ * Translation provider.
+ *
+ * @var Horde_Translation
+ */
+ protected $_coreDict;
+
+ /**
* Constructor.
*
* TODO
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']);
$prev_text = isset($this->_config['previousHTML'])
? $this->_config['previousHTML']
- : htmlspecialchars(_("<Previous"));
+ : htmlspecialchars($this->_coreDict->t("<Previous"));
$html .= Horde::link($link, '', 'prev') . $prev_text . '</a>';
}
$next_text = isset($this->_config['nextHTML'])
? $this->_config['nextHTML']
- : htmlspecialchars(_("Next>"));
+ : htmlspecialchars($this->_coreDict->t("Next>"));
$html .= ' ' . Horde::link($link, '', 'next') . $next_text . '</a>';
}
{
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 ' .
$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'])) {
}
/* 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,
/* 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')) {
$varname . '[keep_orig]',
$varname . '[keep_orig]',
!empty($image['keep_orig']) ? ' checked="checked"' : '',
- _("Keep original?"));
+ $this->_coreDict->t("Keep original?"));
}
/* The preview image element. */
'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";
}
$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;
}
$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;
}
/* Output seconds. */
- $seconds = array('' => _("ss"));
+ $seconds = array('' => $this->_coreDict->t("ss"));
for ($i = 0; $i <= 59; $i++) {
$s = sprintf('%02d', $i);
$seconds[$s] = $s;
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;
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;
$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;
$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);
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>';
}
'[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()) .
$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,
@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)
$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()
$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" />',
}
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;
$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);
}
$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);
}
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)
$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);
}
{
$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);
}
$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) {
$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) {
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>';
}
$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;
/* 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']) &&
/* 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']);
/* 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']);
$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']);
/* Google generated map. */
if ($address) {
- $html .= ' ' . 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 .= ' ' . 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;
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;
$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');
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>';
}
protected $_mask;
/**
+ * Translation provider.
+ *
+ * @var Horde_Translation
+ */
+ protected $_coreDict;
+
+ /**
* Constructor
*/
public function __construct($mask = self::MASK_ALL)
/* Location of the menufile. */
$this->_menufile = $GLOBALS['registry']->get('fileroot') . '/config/menu.php';
+
+ $this->_coreDict = new Horde_Translation_Gettext('Horde_Core', dirname(__FILE__) . '/../../locale');
}
/**
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. */
$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. */
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');
}
}
}
protected $_apis = array();
/**
+ * Translation provider.
+ *
+ * @var Horde_Translation
+ */
+ protected $_coreDict;
+
+ /**
* Hash storing information on each registry-aware application.
*
* @var array
/* 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
}
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);
}
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);
}
}
}
return ($parameter == 'name')
- ? _($pval)
+ ? $this->_coreDict->t($pval)
: $pval;
}
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));
}
/**
{
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)) {
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.
*
// 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');
}
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
* 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.');
}
/* 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);
}
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);
$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";
}
}
/* 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. */
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."));
}
/**
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() */
}
}
- 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."));
}
/**
} 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);
$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));
}
}
$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;
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. */
$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;
/* 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. */
}
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. */
{
/* 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;
$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
$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();
$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;
}
$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;
}
}
} 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')) {
$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);
/* 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;
$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);
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."));
}
/**
$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();
$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');
{
/* 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. */
}
}
- 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."));
}
/**
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. */
}
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);
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. */
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."));
}
/**
{
/* 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'];
/* 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])) {
/* 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])) {
}
/* Dates */
- $text .= "<strong>" . _("Validity") . ":</strong>\n";
- $text .= sprintf(" %s: %s\n", _("Not Before"), strftime("%x %X", $certificate['validity']['notbefore']));
- $text .= sprintf(" %s: %s\n", _("Not After"), strftime("%x %X", $certificate['validity']['notafter']));
+ $text .= "<strong>" . $this->_dict->t("Validity") . ":</strong>\n";
+ $text .= sprintf(" %s: %s\n", $this->_dict->t("Not Before"), strftime("%x %X", $certificate['validity']['notbefore']));
+ $text .= sprintf(" %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(" %s: %s\n", _("Public Key Algorithm"), $certificate['subjectPublicKeyInfo']['algorithm']);
+ $text .= "<strong>" . $this->_dict->t("Public Key Info") . ":</strong>\n";
+ $text .= sprintf(" %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'];
str_pad($modulus_hex, 256, '0', STR_PAD_RIGHT);
}
- $text .= " " . sprintf(_("RSA Public Key (%d bit)"), strlen($modulus_hex) * 4) . ":\n";
+ $text .= " " . sprintf($this->_dict->t("RSA Public Key (%d bit)"), strlen($modulus_hex) * 4) . ":\n";
$modulus_str = '';
$modulus_str .= substr($modulus_hex, $i, 2) . ':';
}
- $text .= sprintf(" %s: %s\n", _("Modulus"), $modulus_str);
+ $text .= sprintf(" %s: %s\n", $this->_dict->t("Modulus"), $modulus_str);
}
- $text .= sprintf(" %s: %s\n", _("Exponent"), $certificate['subjectPublicKeyInfo']['subjectPublicKey']['publicExponent']);
+ $text .= sprintf(" %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(" %s:\n %s\n", $fieldnames[$key], wordwrap($value, 40, "\n "));
}
/* Certificate Details */
- $text .= "<strong>" . _("Certificate Details") . ":</strong>\n";
- $text .= sprintf(" %s: %d\n", _("Version"), $certificate['version']);
- $text .= sprintf(" %s: %d\n", _("Serial Number"), $certificate['serialNumber']);
+ $text .= "<strong>" . $this->_dict->t("Certificate Details") . ":</strong>\n";
+ $text .= sprintf(" %s: %d\n", $this->_dict->t("Version"), $certificate['version']);
+ $text .= sprintf(" %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(" %s:\n %s\n", $label, $fingerprint_str);
}
- $text .= sprintf(" %s: %s\n", _("Signature Algorithm"), $cert_details['signatureAlgorithm']);
- $text .= sprintf(" %s:", _("Signature"));
+ $text .= sprintf(" %s: %s\n", $this->_dict->t("Signature Algorithm"), $cert_details['signatureAlgorithm']);
+ $text .= sprintf(" %s:", $this->_dict->t("Signature"));
$sig_str = '';
for ($i = 0, $s_len = strlen($cert_details['signature']); $i < $s_len; ++$i) {
}
$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;
}
}
*/
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"));
}
/**
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."));
}
}
$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']);
}
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. */
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));
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));
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
*/
$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');
+ }
}
/**
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;
/* 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);
}
$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);
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();
}
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'] .
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;
}
}
} else {
- return PEAR::raiseError(sprintf(_("Cannot remove, %d children exist."), count($children)));
+ return PEAR::raiseError(sprintf('Cannot remove, %d children exist.', count($children)));
}
}
*
* @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");
}
}
* @package Horde_Date
*/
-
/**
* @category Horde
* @package Horde_Date
* 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.
*
* @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);
}
*
* @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);
}
}
}
+ $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']);
}
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));
$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)
{
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;
$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.");
}
}
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. */
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);
}
$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");
}
}
* @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)
*/
function about()
{
- return array('name' => _("Spacer"));
+ return array('name' => $this->_dict->t("Spacer"));
}
}
*/
function about()
{
- return array('name' => _("Header"));
+ return array('name' => $this->_dict->t("Header"));
}
}
*/
function about()
{
- return array('name' => _("Description"));
+ return array('name' => $this->_dict->t("Description"));
}
}
*/
function about()
{
- return array('name' => _("HTML"));
+ return array('name' => $this->_dict->t("HTML"));
}
}
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;
return true;
}
- $message = _("This field must be a valid number.");
+ $message = $this->_dict->t("This field must be a valid number.");
return false;
}
*/
function about()
{
- return array('name' => _("Number"));
+ return array('name' => $this->_dict->t("Number"));
}
}
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;
}
return true;
}
- $message = _("This field may only contain integers.");
+ $message = $this->_dict->t("This field may only contain integers.");
return false;
}
*/
function about()
{
- return array('name' => _("Integer"));
+ return array('name' => $this->_dict->t("Integer"));
}
}
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;
}
return true;
}
- $message = _("This field may only contain octal values.");
+ $message = $this->_dict->t("This field may only contain octal values.");
return false;
}
*/
function about()
{
- return array('name' => _("Octal"));
+ return array('name' => $this->_dict->t("Octal"));
}
}
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;
}
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;
}
*/
function about()
{
- return array('name' => _("Integer list"));
+ return array('name' => $this->_dict->t("Integer list"));
}
}
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.");
}
}
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')));
}
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')),
);
}
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')),
);
}
{
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;
}
*/
function about()
{
- return array('name' => _("Phone number"));
+ return array('name' => $this->_dict->t("Phone number"));
}
}
*/
function about()
{
- return array('name' => _("Mobile phone number"));
+ return array('name' => $this->_dict->t("Mobile phone number"));
}
}
}
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;
*/
function about()
{
- return array('name' => _("IP address"));
+ return array('name' => $this->_dict->t("IP address"));
}
}
$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;
*/
function about()
{
- return array('name' => _("IPv6 address"));
+ return array('name' => $this->_dict->t("IPv6 address"));
}
}
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')));
}
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;
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')));
}
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')));
}
*/
function about()
{
- return array('name' => _("Address Link"));
+ return array('name' => $this->_dict->t("Address Link"));
}
}
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')));
}
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')));
}
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')));
}
*/
function about()
{
- return array('name' => _("File upload"));
+ return array('name' => $this->_dict->t("File upload"));
}
}
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'])) {
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;
}
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')));
}
*/
function about()
{
- return array('name' => _("True or false"));
+ return array('name' => $this->_dict->t("True or false"));
}
}
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')));
}
// 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;
}
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;
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;
}
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'),
),
);
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')));
}
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 {
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;
}
}
*/
function about()
{
- return array('name' => _("Email with confirmation"));
+ return array('name' => $this->_dict->t("Email with confirmation"));
}
}
$valid = strlen(trim($value)) > 0;
if (!$valid) {
- $message = _("This field is required.");
+ $message = $this->_dict->t("This field is required.");
}
}
*/
function about()
{
- return array('name' => _("Password"));
+ return array('name' => $this->_dict->t("Password"));
}
}
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;
}
*/
function about()
{
- return array('name' => _("Password with confirmation"));
+ return array('name' => $this->_dict->t("Password with confirmation"));
}
}
$this->setValues($values);
if ($prompt === true) {
- $this->_prompt = _("-- select --");
+ $this->_prompt = $this->_dict->t("-- select --");
} else {
$this->_prompt = $prompt;
}
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;
}
return true;
}
- $message = _("Invalid data submitted.");
+ $message = $this->_dict->t("Invalid data submitted.");
return false;
}
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')));
}
$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 {
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;
}
return true;
}
- $message = _("Invalid data submitted.");
+ $message = $this->_dict->t("Invalid data submitted.");
return false;
}
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')));
}
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;
return true;
}
- $message = _("Invalid data submitted.");
+ $message = $this->_dict->t("Invalid data submitted.");
return false;
}
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'))
);
}
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')));
}
return true;
}
- $message = _("Invalid data submitted.");
+ $message = $this->_dict->t("Invalid data submitted.");
return false;
}
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')));
}
$valid = strlen(trim($value)) > 0;
if (!$valid) {
- $message = sprintf(_("%s is required"), $var->getHumanName());
+ $message = sprintf($this->_dict->t("%s is required"), $var->getHumanName());
}
}
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);
}
}
*/
function about()
{
- return array('name' => _("Date"));
+ return array('name' => $this->_dict->t("Date"));
}
}
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;
}
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;
}
*/
function about()
{
- return array('name' => _("Time"));
+ return array('name' => $this->_dict->t("Time"));
}
}
}
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;
}
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')));
}
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;
}
*/
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')));
}
$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;
}
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')));
}
$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.");
}
}
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')));
}
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;
}
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;
}
*/
function about()
{
- return array('name' => _("Colour selection"));
+ return array('name' => $this->_dict->t("Colour selection"));
}
}
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;
}
return true;
}
- $message = _("Please choose a sound.");
+ $message = $this->_dict->t("Please choose a sound.");
return false;
}
*/
function about()
{
- return array('name' => _("Sound selection"));
+ return array('name' => $this->_dict->t("Sound selection"));
}
}
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')));
}
{
$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;
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')));
}
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')));
}
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;
}
/* 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;
}
}
*/
function about()
{
- return array('name' => _("Credit card number"));
+ return array('name' => $this->_dict->t("Credit card number"));
}
}
*/
function about()
{
- return array('name' => _("Relationship browser"));
+ return array('name' => $this->_dict->t("Relationship browser"));
}
}
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'))
);
}
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;
}
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'))
);
}
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'))
);
}
*/
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;
}
return true;
}
- $message = _("Invalid data submitted.");
+ $message = $this->_dict->t("Invalid data submitted.");
return false;
}
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')),
);
}
var $_options = array();
/**
+ * Translation provider.
+ *
+ * @var Horde_Translation
+ */
+ protected $_dict;
+
+ /**
* Variable constructor.
*
* @param string $humanName A short description of the variable's
* @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;
$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');
+ }
}
/**
$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;
}
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)) {
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'])) {
*
* @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')
)
);
}
/**
* 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");
}
}
*/
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;
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) {
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;
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;
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':
protected $_logger;
/**
+ * Translation provider.
+ *
+ * @var Horde_Translation
+ */
+ protected $_dict;
+
+ /**
*
* @param $params
*/
$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;
}
// 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;
}
$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");
}
//===========================================================
}
} 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:
$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");
}
//===========================================================
}
} 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...
$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");
}
//===========================================================
}
} 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);
$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;
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;
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;
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
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;
$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
$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
'Unknown';
break;
case 15:
- $result['ISO'] = _("Auto");
+ $result['ISO'] = $this->_dict->t("Auto");
break;
case 16:
$result['ISO'] = 50;
$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
$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)));
$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;
$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
$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
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
*/
protected function _lookupTag($tag)
{
- switch($tag) {
+ switch ($tag) {
case '0000': return 'Version';
case '1000': return 'Quality';
case '1001': return 'Sharpness';
case 'URATIONAL':
case 'SRATIONAL':
$data = bin2hex($data);
- if ($intel == 1) {
+ if ($intel) {
$data = Horde_Image_Exif::intel2Moto($data);
}
$top = hexdec(substr($data, 8, 8));
case 'FLOAT':
case 'DOUBLE':
$data = bin2hex($data);
- if ($intel == 1) {
+ if ($intel) {
$data = Horde_Image_Exif::intel2Moto($data);
}
$data = hexdec($data);
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;
}
default:
$data = bin2hex($data);
- if ($intel == 1) {
+ if ($intel) {
$data = Horde_Image_Exif::intel2Moto($data);
}
break;
*/
public function parse($block, &$result)
{
- $intel = 1;
+ $intel = true;
$model = $result['IFD0']['Model'];
//current place
$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);
//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);
//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);
//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);
//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);
$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);
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;
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;
}
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);
//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;
//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;
}
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':
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;
}
//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;
}
}
//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;
//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;
//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;
//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;
//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;
//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;
//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;
//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;
//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;
//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;
//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;
//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;
//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;
//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;
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;
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');
+ }
}
/**
*/
public function getSummary()
{
- return $this->_vevent->getAttributeDefault('SUMMARY', _("No summary available"));
+ return $this->_vevent->getAttributeDefault('SUMMARY', $this->_dict->t("No summary available"));
}
/**
*/
public function getShortSubject()
{
- return _("Accepted");
+ return $this->_dict->t("Accepted");
}
/**
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
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');
+ }
}
/**
*/
public function getShortSubject()
{
- return _("Declined");
+ return $this->_dict->t("Declined");
}
/**
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
*/
public function getShortSubject()
{
- return _("Tentative");
+ return $this->_dict->t("Tentative");
}
/**
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
*/
function getAppConsts($app)
{
+ $dict = new Horde_Translation_Gettext('Horde_Kolab', dirname(__FILE__) . '/locale');
switch ($app) {
case 'mnemo':
return array(
'allowed_types' => array(
'note',
),
- 'default_folder_name' => _("Notes"),
+ 'default_folder_name' => $dict->t("Notes"),
'application' => $app,
);
'allowed_types' => array(
'event',
),
- 'default_folder_name' => _("Calendar"),
+ 'default_folder_name' => $dict->t("Calendar"),
'application' => $app,
);
'contact',
'distribution-list',
),
- 'default_folder_name' => _("Contacts"),
+ 'default_folder_name' => $dict->t("Contacts"),
'application' => $app,
);
'allowed_types' => array(
'task',
),
- 'default_folder_name' => _("Tasks"),
+ 'default_folder_name' => $dict->t("Tasks"),
'application' => $app,
);
'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));
}
}
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]);
$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));
}
);
/**
+ * 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 {
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));
}
$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
// 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;
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
@$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"));
}
}
$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) {
/**
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();
}
$this->logger = $logger;
+
+ if (isset($params['translation'])) {
+ $this->_dict = $params['translation'];
+ } else {
+ $this->_dict = new Horde_Translation_Gettext('Kolab_FreeBusy', dirname(__FILE__) . '/../../../../../locale');
+ }
}
/**
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;
}
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));
$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);
$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]);
}
}
} 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 */
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',
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));
}
}
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";
/** 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());
}
{
if (!empty($this->_errors)) {
$this->linebreak(1);
- echo _("Errors:");
+ echo $this->_dict->t("Errors:");
$this->linebreak(1);
foreach ($this->_errors as $error) {
echo $error;
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;
}
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');
+ }
}
/**
} 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);
}
/**
$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."));
}
/**
} 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));
}
*/
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
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
$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');
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)) {
} else {
$this->_type_key = '';
}
+
+ if (isset($params['translation'])) {
+ $this->_dict = $params['translation'];
+ } else {
+ $this->_dict = new Horde_Translation_Gettext('Horde_Block', dirname(__FILE__) . '/../../../locale');
+ }
}
/**
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));
}
$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];
}
/**
* 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")
);
}
/**
* 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")
);
}
protected $_mailer_params = array();
/**
+ * Translation provider.
+ *
+ * @var Horde_Translation
+ */
+ protected $_dict;
+
+ /**
* Constructor.
*
* @param array $params A hash with basic message information. 'charset'
*
* @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');
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));
}
}
$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;
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;
}
$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();
$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');
);
/**
+ * 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 . ')');
$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';
}
$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,
$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();
$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,
$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,
$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,
$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 . "\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(
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));
}
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.");
}
}
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;
return true;
}
- $message = _("This field must be a valid number.");
+ $message = $this->_dict->t("This field must be a valid number.");
return false;
}
*/
function about()
{
- return array('name' => _("Number"));
+ return array('name' => $this->_dict->t("Number"));
}
}
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;
}
return true;
}
- $message = _("This field may only contain integers.");
+ $message = $this->_dict->t("This field may only contain integers.");
return false;
}
*/
function about()
{
- return array('name' => _("Integer"));
+ return array('name' => $this->_dict->t("Integer"));
}
}
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;
}
return true;
}
- $message = _("This field may only contain octal values.");
+ $message = $this->_dict->t("This field may only contain octal values.");
return false;
}
*/
function about()
{
- return array('name' => _("Octal"));
+ return array('name' => $this->_dict->t("Octal"));
}
}
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;
}
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;
}
*/
function about()
{
- return array('name' => _("Integer list"));
+ return array('name' => $this->_dict->t("Integer list"));
}
}
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.");
}
}
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')));
}
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')),
);
}
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.");
}
}
*/
function about()
{
- return array('name' => _("Phone number"));
+ return array('name' => $this->_dict->t("Phone number"));
}
}
*/
function about()
{
- return array('name' => _("Mobile phone number"));
+ return array('name' => $this->_dict->t("Mobile phone number"));
}
}
}
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;
*/
function about()
{
- return array('name' => _("IP address"));
+ return array('name' => $this->_dict->t("IP address"));
}
}
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')));
}
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;
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')));
}
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')));
}
*/
function about()
{
- return array('name' => _("File upload"));
+ return array('name' => $this->_dict->t("File upload"));
}
}
*/
function about()
{
- return array('name' => _("True or false"));
+ return array('name' => $this->_dict->t("True or false"));
}
}
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')));
}
// 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;
}
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;
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;
}
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'),
),
);
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')));
}
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();
));
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;
}
}
*/
function about()
{
- return array('name' => _("Email with confirmation"));
+ return array('name' => $this->_dict->t("Email with confirmation"));
}
}
$valid = strlen(trim($value)) > 0;
if (!$valid) {
- $message = _("This field is required.");
+ $message = $this->_dict->t("This field is required.");
}
}
*/
function about()
{
- return array('name' => _("Password"));
+ return array('name' => $this->_dict->t("Password"));
}
}
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;
}
*/
function about()
{
- return array('name' => _("Password with confirmation"));
+ return array('name' => $this->_dict->t("Password with confirmation"));
}
}
$this->_values = $values;
if ($prompt === true) {
- $this->_prompt = _("-- select --");
+ $this->_prompt = $this->_dict->t("-- select --");
} else {
$this->_prompt = $prompt;
}
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;
}
return true;
}
- $message = _("Invalid data.");
+ $message = $this->_dict->t("Invalid data.");
return false;
}
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')));
}
$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 {
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;
}
return true;
}
- $message = _("Invalid data.");
+ $message = $this->_dict->t("Invalid data.");
return false;
}
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')));
}
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;
return true;
}
- $message = _("Invalid data.");
+ $message = $this->_dict->t("Invalid data.");
return false;
}
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'))
);
}
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')));
}
return true;
}
- $message = _("Invalid data.");
+ $message = $this->_dict->t("Invalid data.");
return false;
}
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')));
}
$valid = strlen(trim($value)) > 0;
if (!$valid) {
- $message = sprintf(_("%s is required"), $var->getHumanName());
+ $message = sprintf($this->_dict->t("%s is required"), $var->getHumanName());
}
}
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);
}
}
*/
function about()
{
- return array('name' => _("Date"));
+ return array('name' => $this->_dict->t("Date"));
}
}
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;
}
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;
}
*/
function about()
{
- return array('name' => _("Time"));
+ return array('name' => $this->_dict->t("Time"));
}
}
}
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;
}
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')));
}
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;
}
*/
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')));
}
$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;
}
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')));
}
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')));
}
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;
}
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;
}
*/
function about()
{
- return array('name' => _("Colour selection"));
+ return array('name' => $this->_dict->t("Colour selection"));
}
}
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')));
}
{
$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;
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')));
}
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')));
}
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;
}
/* 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;
}
}
*/
function about()
{
- return array('name' => _("Credit card number"));
+ return array('name' => $this->_dict->t("Credit card number"));
}
}
*/
function about()
{
- return array('name' => _("Relationship browser"));
+ return array('name' => $this->_dict->t("Relationship browser"));
}
}
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'))
);
}
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;
}
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'))
);
}
$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;
}
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)) {
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']);
}
{
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;
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);
}
}
if ($this->_requiredLegend) {
echo '<div class="form-error-example">' . $this->_requiredMarker
- . ' = ' . _("Required Field") . '</div>'."\n";
+ . ' = ' . $this->_dict->t("Required Field") . '</div>'."\n";
}
}
* @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) {
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;
}
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;
}
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;
}
/* 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;
}
}
$valid = strlen(trim($value)) > 0;
if (!$valid) {
- $message = _("This field is required.");
+ $message = $this->_dict->t("This field is required.");
}
}
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);
}
}
// 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;
}
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;
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;
}
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 {
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;
}
}
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;
}
return true;
}
- $message = _("Invalid data.");
+ $message = $this->_dict->t("Invalid data.");
return false;
}
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;
}
return true;
}
- $message = _("This field may only contain integers.");
+ $message = $this->_dict->t("This field may only contain integers.");
return false;
}
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;
return true;
}
- $message = _("This field must be a valid number.");
+ $message = $this->_dict->t("This field must be a valid number.");
return false;
}
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;
}
return true;
}
- $message = _("This field may only contain octal values.");
+ $message = $this->_dict->t("This field may only contain octal values.");
return false;
}
$valid = strlen(trim($value)) > 0;
if (!$valid) {
- $message = _("This field is required.");
+ $message = $this->_dict->t("This field is required.");
}
}
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;
}
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.");
}
}
return true;
}
- $message = _("Invalid data.");
+ $message = $this->_dict->t("Invalid data.");
return false;
}
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;
return true;
}
- $message = _("Invalid data.");
+ $message = $this->_dict->t("Invalid data.");
return false;
}
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.");
}
}
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;
}
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;
}
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
'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()
$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;
}
$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;
}
/* 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;
}
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;
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;
$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>';
}
. '[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",
. $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,
$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";
}
$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()
$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" />',
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;
$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);
}
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)
$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]);
}
{
$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)]);
}
$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) {
$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) {
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>';
}
$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;
/* 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);
/* 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])) {
/* 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]);
/* 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)) {
$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]);
/* 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]);
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;
var $_logBuffer = array();
/**
+ * Translation provider.
+ *
+ * @var Horde_Translation
+ */
+ protected $_dict;
+
+ /**
* Constructor function.
*
* @param array $params Hash containing server parameters.
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');
+ }
}
/**
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));
}
/**
*/
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.
*
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));
}
/**
var $_params;
/**
+ * Translation provider.
+ *
+ * @var Horde_Translation
+ */
+ protected $_dict;
+
+ /**
* Constructor function.
*
* @param array $params Hash containing IMSP parameters.
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');
+ }
}
/**
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."));
}
}
*
* @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);
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;
}
$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])
*
* @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")
);
* 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);
/**
* 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")
);
}
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.
*
$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.
/**
* 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();
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>';
}
$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);
/**
* 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
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())
{
$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);
$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);
}
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
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));
}
}
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'))) {
$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
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"
}
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'])) {
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;
!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);
$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.';
}
// 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.';
}
// 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.';
}
* @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');
+ }
}
/**
} 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();
}
* @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;
}
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();
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()
{
}
*/
function _title()
{
- return _("Scribd Documents");
+ return $this->_localDict->t("Scribd Documents");
}
/**
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();
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));
}
}
/** 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 */
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.
{
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");
}
}
$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!"));
}
}
*/
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!"));
}
}
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();
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();
*/
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"));
}
/**
var $_backendMode;
/**
+ * Translation provider.
+ *
+ * @var Horde_Translation
+ */
+ public $dict;
+
+ /**
* Constructor.
*
* Sets up the default logging mechanism.
* 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)
{
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');
}
$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'),
/**
* Parses gettext tags.
+ *
+ * @todo Convert to use Horde_Translation.
*/
protected function _parseGettext()
{
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);
}
/* 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";
}
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
*/
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,
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;
}
}
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."));
}
}
* @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
var $_params = array();
/**
+ * Translation provider.
+ *
+ * @var Horde_Translation
+ */
+ protected $_dict;
+
+ /**
* Constructs a new VFS_ISOWriter object
*
* @param array $params A hash containing parameters.
$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.
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'] = '/';
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."));
}
}
* @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.
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.
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));
}
}
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');
{
$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) {
}
} else {
if (!@unlink($full)) {
- return PEAR::raiseError(sprintf(_("Could not unlink \"%s\"."),
+ return PEAR::raiseError(sprintf($this->_dict->t("Could not unlink \"%s\"."),
$full));
}
}
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));
}
}
$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;
$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);
}
* @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.
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');
+ }
}
/**
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));
}
/**
* 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();
}
}
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');
$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);
}
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));
}
}
$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);
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);