Jump to content

[SOLVED] Translate email's subject on custom email


pliciweb_stephane

Recommended Posts

Hi,

I have a specific class in override directory that send a specific email with a Prestashop 1.7.4.2

That is my code :

Mail::Send(
	(int) Context::getContext()->language->id,
	'my_specific_template',
	Context::getContext()->getTranslator()->trans(
		'My email subject',
		array(),
		'Emails.Subject',
		Context::getContext()->language->id
	),
	array('{param}' => $param),
	$this->email
)

When i want to translate in International -> Translations-> Translate Email / Subject / English, my subject "My email subject" is not visible.

If i add an entry in "app/Resources/translations/default/EmailsSubject.xlf"

I can see my subject.

But when i translate it in Back office, an entry is created in database ps_translation but my email subject is not translate.

How i can translate my subject ?

 

Thank for your response. Hope, it'll be useful for other people.

Best regards

Stéphane

 

Edited by pliciweb_stephane
Solved (see edit history)
Link to comment
Share on other sites

I realize my mistake, the fourthy parameter of Context::getContext()->getTranslator()->trans get locale "en-US" instead of id_lang (Context::getContext()->language->id).

So if i change my code to

Mail::Send(
	(int) Context::getContext()->language->id,
	'my_specific_template',
	Context::getContext()->getTranslator()->trans(
		'My email subject',
		array(),
		'Emails.Subject'
	),
	array('{param}' => $param),
	$this->email
)

It's work.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...