I know that multilingual newsletter is not supported at this moment but maybe there is a way that simulate this functionality.

I'm thinking to hack subscribe form to select the language for a subscriber. But I need to use a filter to select the language of nodes. I have no idea where I should work it in template or in the newsletter list.

Someone has made something similar? will be great if someone could explain how to develop this trick.

Multilingual support is discussed in this issue where ParisLiakos inform us that this request will be developed at 7.x-2.x-dev version. I know that is a very alpha version, but I'm interested in helping as far as possible.

CommentFileSizeAuthor
#3 newsletter-templates.jpg91.57 KBRobertoGA
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

RobertoGA’s picture

I think someone may misunderstand my previous request. I do not want a multilanguage newsletter, simply select the language of a newsletter and use the module to create multiple newsletter, one for each language.

RobertoGA’s picture

Setting different terms, one for language, in the taxonomy that managed the newsletter solve the problem partially. Don't forget to fix the correct term to node language.

Then, you should create a mail template for each language related with the correct term and create a list for each mail template.

When someone will be subscribing could select the list corresponding to their favourit language.

There is a little problem to solve... confirmation, welcome and unsubscrition message are in one language (english by default)... Do someone know how to solve this? Is it posible translate these messages?

Thanks

RobertoGA’s picture

FileSize
91.57 KB

Yeah, I got it... now my confirmation, welcome and unsubscription messages are working in differents languages.

I've created 3 different templates for this function with ID 5, 6, 7. Default confirmation, welcome and unsubscription templates have ID 1, 2, 3 by default. I've attached a screenshot for better understanding.

I want to emphasize that I've created this changes just for my use. It will not work on other sites unless you synchronize the templates IDs in newsletter_get_list_id function. I apologize with module creator, ParisLiakos, to touch where I should not... but I needed it.

And now some coding... I create a new function en newsletter.module

/**
 * Get newsletter basic template ID
 *
 * @param $source
 *   Basic template origin
 *
 * @param $email
 *   The subscriber e-mail
 */
function newsletter_get_list_id($source, $email){

  $subscriber_nlid = db_query('SELECT f_data.field_newsletter_list_target_id
				              FROM newsletter_subscriber n_subs
	 				      JOIN field_data_field_newsletter_list f_data
					      WHERE f_data.entity_id = n_subs.nsid
					      AND n_subs.email LIKE :email', array(':email' => $email))->fetchField();
  
  if($subscriber_nlid == '1'){ // My english list
   	$nlids = array("confirmation" => 1, "welcome" => 2, "unsubscribe" => 3);
  }elseif($subscriber_nlid == '2'){ // My spanish list
   	$nlids = array("confirmation" => 5, "welcome" => 6, "unsubscribe" => 7);
  }

  return $nlids[$source];
}

Now, to change the flow for confirmation message, I've modifed some lines at save() function inside include/newsletter.subscriber.controller.inc:

original:

  if ($needs_confirm && arg(0) != 'admin') {
    $sent = newsletter_create()->sendBasic(1, $subscriber->email);
    ...
  }

modified:

  if ($needs_confirm && arg(0) != 'admin') {
    $nlid = newsletter_get_list_id('confirmation', $subscriber->email);
    $sent = newsletter_create()->sendBasic($nlid, $subscriber->email);
    ...
  }

To modify welcome and unsubscribe message I've worked in include/newsletter.pages.inc

Welcome message at newsletter_confirm() function:

original:

  if (variable_get('newsletter_send_welcome', FALSE)) {
    newsletter_create()->sendBasic(2, $subscriber->email);
  }

modified:

  if (variable_get('newsletter_send_welcome', FALSE)) {
    $nlid = newsletter_get_list_id('welcome', $subscriber->email);
    newsletter_create()->sendBasic($nlid, $subscriber->email);
  }

Unsubscribe message at newsletter_unsubscribe_submit() function:

original:

  if (variable_get('newsletter_send_unsubscribe', FALSE)) {
    newsletter_create()->sendBasic(3, $subscriber->email);
  }

modified:

  if (variable_get('newsletter_send_unsubscribe', FALSE)) {
    $nlid = newsletter_get_list_id('unsubscribe', $subscriber->email);
    newsletter_create()->sendBasic($nlid, $subscriber->email);
  }