Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 204 Vote(s) - 3.6 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PrestaShop email localization

#1
I am developing a module for PrestaShop 1.5.

I am sending email like this(the documentation is really missing, i studied other default components and this is what i got so far)

Mail::Send(
$this->context->language->id, //int $id_lang
'template_name',//string $template
//Mail::l('Hello', $this->context->language->id),//string $subject
$this->l('Email subject'),//string $subject
array('{discount}' => $code,
'{firstname}' => $customer['firstname'],
'{lastname}' => $customer['lastname'],
'{img_url}' => $img_url,
'{valid_days}' => $form['days_valid']
),//string $template_vars
$customer['email'],//string $to
implode(' ', array_filter( array( $customer['firstname'], $customer['lastname']) )),
strval( Configuration::get('PS_SHOP_EMAIL') ),//string $from
strval( Configuration::get('PS_SHOP_NAME') ),//string $from_name
/* null,//string $from
null//string $from_name */
null,//array $file_attachment
null,//$mode_smtp
$template_path//string $template_path /*__PS_BASE_URI__.'modules/'.$this->name.'/mails/' */

);


Note i tried using

Mail::l('Hello', $this->context->language->id),//string $subject

and

$this->l('Email subject'),//string $subject
as the email's subject.

And i keep getting "No Subject was found for ...". What the customer receive is the hardcoded string i put in the source code.

So how to get rid of this error:
![enter image description here][1]
Plus the emails are sent in apparently random language(sometimes english, sometimes italian).


[1]:
Reply

#2
In your module, you must use Mail::l() in the subject parameter.
Here's an example of Mail::Send() for a module :

Mail::Send($this->context->language->id,
'test',
Mail::l('test subject', $this->context->language->id),
array(),
$to_email);


----------

Here how email translations is working :

AdminTranslationsController will check in "/modules/[module folder]/mails/" for the templates and in "/mails/[lang]/lang.php" for subjects. Subjects will be created when submitting translations.

----------

If that doesn'work, maybe it's a problem with folder's rights.
Open this file :

> /prestashop/mails/it/lang.php

And check if there's a line like this one :

$_LANGMAIL['Email subject'] = 'translation in italian';

If not, check web server rights on this file and parent folders.
Reply

#3
I've now came over same issue working with Prestashop version 1.5.5.0.

In some circumstances, getSubjectMail() method won't recognize email template, so it cannot be matched with subject. The whole point is that while this method looks for subjects to be translated, it parses php files as plain text. Therefore all variables are parsed unresolved.

In my case, I'm calling Mail:Send from the module's controller and it looks like:

Mail::Send(
$id_lang,
$template, // <- don't use variable here, rather type email template there directly.
Mail::l('Message from footer contact form'),
$template_vars,
$contact->email,
$contact->name,
($is_email ? $from : Configuration::get('PS_SHOP_EMAIL')),
'',
null, // file attachment
null, // mode smtp
$this->module->_mailpath
);

Parsing this file would result into matching subject __Message from footer contact form__ to the mail template "__$template__". Which doesn't exist obviously.

To make sure that your subject will be recognized correctly, don't use variable to pass template name.
Reply

#4
The email templates (and not only them) are totally messy in Presta. Since I installed a custom theme I have them now in 6(!!) different locations.

Would not be such a trouble, but it seems that gets the same confused as I did. It takes the templates from one location for editing them, saves them in turn into another location, and takes them from a third location (for a module) when actually creating the mail.

As a result I was able to edit a template once, but after saving it, it appeared to be reverted, because it was actually saved to another location.

So what I did is: I removed the templates for the module ("mailalerts") from the default theme folder (both folder 'mails' and 'modules/mailalerts/mails') and from my custom theme.

If you do so - just keep a copy before you delete them, because you will probably loose some of the translations you already made there.

Decide for one and only one location where you want to keep them (for me it were the original 'mails' resp 'modules' folders) and edit them then later only from this one location. For the locations mentioned here you choose the option "Core" from the dropdown on the "Translations" admin page.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through