Skip to content

Commit

Permalink
Changed to translate messages using cake domain.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Apr 13, 2011
1 parent 935badf commit 40e8632
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
38 changes: 19 additions & 19 deletions lib/Cake/Network/CakeEmail.php
Expand Up @@ -246,7 +246,7 @@ public function from($email = null, $name = null) {
if ($email === null) {
return $this->_from;
}
$this->_setEmailSingle('_from', $email, $name, __('From requires only 1 email address.'));
$this->_setEmailSingle('_from', $email, $name, __d('cake', 'From requires only 1 email address.'));
}

/**
Expand All @@ -261,7 +261,7 @@ public function replyTo($email = null, $name = null) {
if ($email === null) {
return $this->_replyTo;
}
$this->_setEmailSingle('_replyTo', $email, $name, __('Reply-To requires only 1 email address.'));
$this->_setEmailSingle('_replyTo', $email, $name, __d('cake', 'Reply-To requires only 1 email address.'));
}

/**
Expand All @@ -276,7 +276,7 @@ public function readReceipt($email = null, $name = null) {
if ($email === null) {
return $this->_readReceipt;
}
$this->_setEmailSingle('_readReceipt', $email, $name, __('Disposition-Notification-To requires only 1 email address.'));
$this->_setEmailSingle('_readReceipt', $email, $name, __d('cake', 'Disposition-Notification-To requires only 1 email address.'));
}

/**
Expand All @@ -291,7 +291,7 @@ public function returnPath($email = null, $name = null) {
if ($email === null) {
return $this->_returnPath;
}
$this->_setEmailSingle('_returnPath', $email, $name, __('Return-Path requires only 1 email address.'));
$this->_setEmailSingle('_returnPath', $email, $name, __d('cake', 'Return-Path requires only 1 email address.'));
}

/**
Expand Down Expand Up @@ -381,7 +381,7 @@ public function addBcc($email, $name = null) {
protected function _setEmail($varName, $email, $name) {
if (!is_array($email)) {
if (!Validation::email($email)) {
throw new SocketException(__('Invalid email: "%s"', $email));
throw new SocketException(__d('cake', 'Invalid email: "%s"', $email));
}
if ($name === null) {
$name = $email;
Expand All @@ -395,7 +395,7 @@ protected function _setEmail($varName, $email, $name) {
$key = $value;
}
if (!Validation::email($key)) {
throw new SocketException(__('Invalid email: "%s"', $key));
throw new SocketException(__d('cake', 'Invalid email: "%s"', $key));
}
$list[$key] = $value;
}
Expand Down Expand Up @@ -432,7 +432,7 @@ protected function _setEmailSingle($varName, $email, $name, $throwMessage) {
protected function _addEmail($varName, $email, $name) {
if (!is_array($email)) {
if (!Validation::email($email)) {
throw new SocketException(__('Invalid email: "%s"', $email));
throw new SocketException(__d('cake', 'Invalid email: "%s"', $email));
}
if ($name === null) {
$name = $email;
Expand All @@ -446,7 +446,7 @@ protected function _addEmail($varName, $email, $name) {
$key = $value;
}
if (!Validation::email($key)) {
throw new SocketException(__('Invalid email: "%s"', $key));
throw new SocketException(__d('cake', 'Invalid email: "%s"', $key));
}
$list[$key] = $value;
}
Expand Down Expand Up @@ -475,7 +475,7 @@ public function subject($subject = null) {
*/
public function setHeaders($headers) {
if (!is_array($headers)) {
throw new SocketException(__('$headers should be an array.'));
throw new SocketException(__d('cake', '$headers should be an array.'));
}
$this->_headers = $headers;
}
Expand All @@ -489,7 +489,7 @@ public function setHeaders($headers) {
*/
public function addHeaders($headers) {
if (!is_array($headers)) {
throw new SocketException(__('$headers should be an array.'));
throw new SocketException(__d('cake', '$headers should be an array.'));
}
$this->_headers = array_merge($this->_headers, $headers);
}
Expand Down Expand Up @@ -646,7 +646,7 @@ public function emailFormat($format = null) {
return $this->_emailFormat;
}
if (!in_array($format, $this->_emailFormatAvailable)) {
throw new SocketException(__('Format not available.'));
throw new SocketException(__d('cake', 'Format not available.'));
}
$this->_emailFormat = $format;
}
Expand Down Expand Up @@ -679,7 +679,7 @@ public function messageID($message = null) {
$this->_messageId = $message;
} else {
if (!preg_match('/^\<.+@.+\>$/', $message)) {
throw new SocketException(__('Invalid format to Message-ID. The text should be something like "<uuid@server.com>"'));
throw new SocketException(__d('cake', 'Invalid format to Message-ID. The text should be something like "<uuid@server.com>"'));
}
$this->_messageId = $message;
}
Expand All @@ -700,7 +700,7 @@ public function attachments($attachments = null) {
foreach ((array)$attachments as $name => $file) {
$path = realpath($file);
if ($path === false) {
throw new SocketException(__('File not found: "%s"', $attach));
throw new SocketException(__d('cake', 'File not found: "%s"', $attach));
}
if (is_int($name)) {
$name = basename($path);
Expand Down Expand Up @@ -758,11 +758,11 @@ public function config($config = null) {
public function send($content = null) {
if (is_string($this->_config)) {
if (!config('email')) {
throw new SocketException(__('%s not found.', APP . DS . 'email.php'));
throw new SocketException(__d('cake', '%s not found.', APP . DS . 'email.php'));
}
$configs = new EMAIL_CONFIG();
if (!isset($configs->{$this->_config})) {
throw new SocketException(__('Unknown email configuration "%s".', $this->_config));
throw new SocketException(__d('cake', 'Unknown email configuration "%s".', $this->_config));
}
$config = $configs->{$this->_config};
} else {
Expand All @@ -773,11 +773,11 @@ public function send($content = null) {
if (!empty($config['from'])) {
$this->to($config['from']);
} else {
throw new SocketException(__('From is not specified.'));
throw new SocketException(__d('cake', 'From is not specified.'));
}
}
if (empty($this->_to) && empty($this->_cc) && empty($this->_bcc)) {
throw new SocketExpcetion(__('You need specify one destination on to, cc or bcc.'));
throw new SocketExpcetion(__d('cake', 'You need specify one destination on to, cc or bcc.'));
}

if (is_array($content)) {
Expand Down Expand Up @@ -818,9 +818,9 @@ public function send($content = null) {
$transportClassname .= 'Transport';
App::uses($transportClassname, $plugin . 'Network/Email');
if (!class_exists($transportClassname)) {
throw new SocketException(__('Class "%s" not found.', $transportClassname));
throw new SocketException(__d('cake', 'Class "%s" not found.', $transportClassname));
} elseif (!method_exists($transportClassname, 'send')) {
throw new SocketException(__('The "%s" do not have send method.', $transportClassname));
throw new SocketException(__d('cake', 'The "%s" do not have send method.', $transportClassname));
}

$transport = new $transportClassname($config);
Expand Down
14 changes: 7 additions & 7 deletions lib/Cake/Network/Email/SmtpTransport.php
Expand Up @@ -77,7 +77,7 @@ public function send(CakeEmail $email) {
protected function _connect() {
$this->_generateSocket();
if (!$this->_socket->connect()) {
throw new SocketException(__('Unable to connect in SMTP server.'));
throw new SocketException(__d('cake', 'Unable to connect in SMTP server.'));
}
$this->_smtpSend(null, '220');

Expand All @@ -95,7 +95,7 @@ protected function _connect() {
try {
$this->_smtpSend("HELO {$host}", '250');
} catch (SocketException $e2) {
throw new SocketException(__('SMTP server not accepted the connection.'));
throw new SocketException(__d('cake', 'SMTP server not accepted the connection.'));
}
}
}
Expand All @@ -111,13 +111,13 @@ protected function _auth() {
$authRequired = $this->_smtpSend('AUTH LOGIN', '334|503');
if ($authRequired == '334') {
if (!$this->_smtpSend(base64_encode($this->_config['username']), '334')) {
throw new SocketException(__('SMTP server not accepted the username.'));
throw new SocketException(__d('cake', 'SMTP server not accepted the username.'));
}
if (!$this->_smtpSend(base64_encode($this->_config['password']), '235')) {
throw new SocketException(__('SMTP server not accepted the password.'));
throw new SocketException(__d('cake', 'SMTP server not accepted the password.'));
}
} elseif ($authRequired != '503') {
throw new SocketException(__('SMTP do not require authentication.'));
throw new SocketException(__d('cake', 'SMTP do not require authentication.'));
}
}
}
Expand Down Expand Up @@ -196,7 +196,7 @@ function _smtpSend($data, $checkCode = '250') {
$response .= $this->_socket->read();
}
if (substr($response, -2) !== "\r\n") {
throw new SocketException(__('SMTP timeout.'));
throw new SocketException(__d('cake', 'SMTP timeout.'));
}
$response = end(explode("\r\n", rtrim($response, "\r\n")));

Expand All @@ -206,7 +206,7 @@ function _smtpSend($data, $checkCode = '250') {
}
return $code[1];
}
throw new SocketException(__('SMTP Error: %s', $response));
throw new SocketException(__d('cake', 'SMTP Error: %s', $response));
}
}

Expand Down

0 comments on commit 40e8632

Please sign in to comment.