? translations
Index: simplenews-newsletter-footer.tpl.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simplenews/simplenews-newsletter-footer.tpl.php,v
retrieving revision 1.3
diff -u -p -r1.3 simplenews-newsletter-footer.tpl.php
--- simplenews-newsletter-footer.tpl.php	2 Jan 2009 12:01:17 -0000	1.3
+++ simplenews-newsletter-footer.tpl.php	23 Aug 2009 10:58:36 -0000
@@ -27,7 +27,7 @@
 <?php if ($format == 'html'): ?>
   <p class="newsletter-footer"><a href="!confirm_unsubscribe_url"><?php print $unsubscribe_text ?></a></p>
 <?php else: ?>
--- <?php print $unsubscribe_text ?>: !confirm_unsubscribe_url
+-- <?php print $unsubscribe_text ?>: [simplenews-unsubscribe-url]
 <?php endif ?>
 
 <?php if ($key == 'test'): ?>
Index: simplenews.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simplenews/simplenews.admin.inc,v
retrieving revision 1.58
diff -u -p -r1.58 simplenews.admin.inc
--- simplenews.admin.inc	30 Jul 2009 19:56:47 -0000	1.58
+++ simplenews.admin.inc	23 Aug 2009 10:58:37 -0000
@@ -1009,6 +1009,15 @@ function simplenews_admin_settings_subsc
     '#default_value' => _simplenews_subscription_confirmation_text('unsubscribe_unsubscribed'),
     '#rows' => 5,
   );
+  $form['simplenews_subscription']['subscription_mail']['token_help'] = array(
+    '#title' => t('Replacement patterns'),
+    '#type' => 'fieldset',
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+  $form['simplenews_subscription']['subscription_mail']['token_help']['help'] = array(
+    '#value' => theme('token_help', 'simplenews_subscribe'),
+  );
 
   return system_settings_form($form);
 }
Index: simplenews.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simplenews/simplenews.module,v
retrieving revision 1.213
diff -u -p -r1.213 simplenews.module
--- simplenews.module	9 Aug 2009 10:46:16 -0000	1.213
+++ simplenews.module	23 Aug 2009 10:58:38 -0000
@@ -330,13 +330,9 @@ function simplenews_nodeapi(&$node, $op,
       if (!isset($node->simplenews_mail)) {
         global $language;
         $context['node'] = $node;
-        $variables = simplenews_mail_tokens($user, $context, $language);
-        if (isset($node->body)) {
-          $node->body = strtr($node->body, $variables);
-        }
-        if (isset($node->teaser)) {
-          $node->teaser = strtr($node->teaser, $variables);
-        }
+        
+        $node->body = token_replace($node->body, 'node', $node);
+        
       }
       break;
     case 'validate':
@@ -508,8 +504,18 @@ function simplenews_form_alter(&$form, $
       // Available variables are based on user_mail_tokens().
       // But uses only those which can be used with uid = 0 since simplenews also sends to anonymous users.
       if (isset($form['body_field'])) {
-        $form['body_field']['body']['#description'] = t("This will be the body of your newsletter. Available variables are: !site (the name of your website), !uri (a link to your homepage), !uri_brief (homepage link without the http://), !date (today's date), !login_uri (link to login page), !confirm_subscribe_url (subscription confirmation link), !confirm_unsubscribe_url (unsubscription link), !newsletter_url (link to this newsletter issue), !newsletter_name (name of this newsletter series).");
+        $form['body_field']['body']['#description'] = t("This will be the body of your newsletter. You can see all available variables under 'Replacement patterns')");
       }
+      $form['simplenews_subscription']['subscription_mail']['token_help'] = array(
+        '#title' => t('Replacement patterns'),
+    	'#type' => 'fieldset',
+    	'#collapsible' => TRUE,
+    	'#collapsed' => TRUE,
+        '#weight' => -20,
+      );
+      $form['simplenews_subscription']['subscription_mail']['token_help']['help'] = array(
+    	'#value' => theme('token_help', 'simplenews'),
+      );
 
       if (isset($form['#node']->simplenews)) {
         $simplenews_values = $form['#node']->simplenews;
@@ -1490,6 +1496,10 @@ function simplenews_send_test($node) {
 function simplenews_mail($key, &$message, $params) {
   $context = $params['context'];
 
+  $object =  new stdClass();
+  $object->tid = $params['context']['newsletter']->tid;
+  $object->uid = $params['context']['account']->uid;
+  
   switch ($key) {
     case 'node':
     case 'test':
@@ -1598,48 +1608,54 @@ function simplenews_mail($key, &$message
         $footer             = $messages[$nid][$langcode]['footer'];
       }
 
-      // Build message body.
-      // Replace tokens with user specific data and
       // Convert to plain text if required.
-      $variables =  simplenews_mail_tokens($context['account'], $context, is_object($context['account']->language) ? $context['account']->language : language_default());
-      $body = strtr($body, $variables);
       if ($context['node']->simplenews['s_format'] == 'plain') {
         $body = simplenews_html_to_text($body, variable_get('simplenews_hyperlinks_'. $context['node']->simplenews['tid'], 1));
       }
+      // Build message body.
+      // Replace tokens with user specific data and
       $message['body']['body'] = $body;
-
+      $message['body']['body'] = token_replace($message['body']['body'], 'simplenews', $object);
+      
       // Build message footer.
       // Replace tokens with user specific data
-      $message['body']['footer'] = strtr($footer, $variables);
+      $message['body']['footer'] = $footer;
+      $message['body']['footer'] = token_replace($message['body']['footer'], 'simplenews', $object);
 
       // Add user specific header data.
-      $message['headers']['List-Unsubscribe'] = strtr('<!confirm_unsubscribe_url>', $variables);
-
+      $message ['headers']['List-Unsubscribe'] = token_replace('[simplenews-unsubscribe-url]', 'simplenews', $object);
+      
       break;
     case 'subscribe':
       // Use formatted from address "name" <mail_address>
       $message['headers']['From'] = $params['from']['formatted'];
 
-      $variables =  simplenews_mail_tokens($context['account'], $context, is_object($context['account']->language) ? $context['account']->language : language_default());
-      $message['subject'] = _simplenews_subscription_confirmation_text('subscribe_subject', $context['account']->language, $variables);
+      $message['subject'] = _simplenews_subscription_confirmation_text('subscribe_subject', $langcode);
+      $message['subject'] = token_replace($message['subject'], 'simplenews_subscribe', $params);
+      
       if (simplenews_user_is_subscribed($context['account']->mail, $context['newsletter']->tid)) {
-        $message['body'] = _simplenews_subscription_confirmation_text('subscribe_subscribed', $context['account']->language, $variables);
+        $message['body'] = _simplenews_subscription_confirmation_text('subscribe_subscribed', $langcode);
+        $message['body'] = token_replace($message['body'], 'simplenews_subscribe', $params);
       }
       else {
-        $message['body'] = _simplenews_subscription_confirmation_text('subscribe_unsubscribed', $context['account']->language, $variables);
+        $message['body'] = _simplenews_subscription_confirmation_text('subscribe_unsubscribed', $langcode);
+        $message['body'] = token_replace($message['body'], 'simplenews_subscribe', $params);
       }
       break;
     case 'unsubscribe':
       // Use formatted from address "name" <mail_address>
       $message['headers']['From'] = $params['from']['formatted'];
 
-      $variables =  simplenews_mail_tokens($context['account'], $context, is_object($context['account']->language) ? $context['account']->language : language_default());
-      $message['subject'] = _simplenews_subscription_confirmation_text('subscribe_subject', $context['account']->language, $variables);
+      $message['subject'] = _simplenews_subscription_confirmation_text('subscribe_subject', $langcode);
+      $message['subject'] = token_replace($message['subject'], 'simplenews_subscribe', $params);
+      
       if (simplenews_user_is_subscribed($context['account']->mail, $context['newsletter']->tid)) {
-        $message['body'] = _simplenews_subscription_confirmation_text('unsubscribe_subscribed', $context['account']->language, $variables);
+        $message['body'] = _simplenews_subscription_confirmation_text('unsubscribe_subscribed', $langcode);
+        $message['body'] = token_replace($message['body'], 'simplenews_subscribe', $params);
       }
       else {
-        $message['body'] = _simplenews_subscription_confirmation_text('unsubscribe_unsubscribed', $context['account']->language, $variables);
+        $message['body'] = _simplenews_subscription_confirmation_text('unsubscribe_unsubscribed', $langcode);
+        $message['body'] = token_replace($message['body'], 'simplenews_subscribe', $params);
       }
       break;
   }
@@ -2291,21 +2307,21 @@ function _simplenews_subscription_confir
 
   if ($admin_setting = variable_get('simplenews_confirm_'. $key, FALSE)) {
     // An admin setting overrides the default string.
-    return t($admin_setting, $variables, $langcode);
+    return $admin_setting;
   }
   else {
     // No override, return default string.
     switch ($key) {
       case 'subscribe_unsubscribed':
-        return t("We have received a request for subscription of !mailto to the !newsletter_name on !site website at !uri. To confirm this subscription please use the link below.\n\n!confirm_subscribe_url", $variables, $langcode);
+        return t("We have received a request from the email [simplenews-rec_email] for subscription to the [simplenews-category] newsletter on [site-name] website at [simplenews-uri]. To confirm this subscription please use the link below.\n\n[simplenews-subscribe-url]", $langcode);
       case 'subscribe_subscribed':
-        return t("We have received a request for subscription of !mailto to the !newsletter_name on !site website at !uri. However, this email is already subscribed to this newsletter. If you intended to unsubscribe please visit our site: !uri", $variables, $langcode);
+        return t("We have received a request from the email [simplenews-rec_email] for subscription to the [simplenews-category] newsletter on [site-name] website at [simplenews-uri]. However, this email is already subscribed to this newsletter. If you intended to unsubscribe please visit our site: [simplenews-uri]", $langcode);
       case 'unsubscribe_subscribed':
-        return t("We have received a request to unsubscribe !mailto from the !newsletter_name on !site website at !uri. To confirm this unsubscription please use the link below.\n\n!confirm_unsubscribe_url", $variables, $langcode);
+        return t("We have received a request from the email [simplenews-rec_email] to unsubscribe you from the [simplenews-category] on [site-name] website at [simplenews-uri]. To confirm this unsubscription please use the  below.\n\n[simplenews-unsubscribe-url]", $langcode);
       case 'unsubscribe_unsubscribed':
-        return t("We have received a request to unsubscribe !mailto from the !newsletter_name on !site website at !uri. However, this email is not subscribed to this newsletter. If you intended to subscribe please visit our site: !uri", $variables, $langcode);
+        return t("We have received a from the email [simplenews-rec_email] request to unsubscribe you from the [simplenews-category] on [site-name] website at [simplenews-uri]. However, this email is not subscribed to this newsletter. If you intended to subscribe please visit our site: [simplenews-uri]", $langcode);
       case 'subscribe_subject':
-        return t("Confirmation for !newsletter_name from !site", $variables, $langcode);
+        return t("Confirmation for [simplenews-category] from [site-name]", $langcode);
     }
   }
 }
