Jump to content

ContactController.php translation


mitsos1os

Recommended Posts

Hi guys... I am having trouble with translating the subject of messages received from contact forms...

 

The subject the customer receives when sending a message is "Your message has been correctly sent #ct.... #tc.....)"

I cannot find this anywhere in the email template translations or in any other translation area whatsoever.... From searching within the code, I found the specific message in the file..

/controllers/front/ContactController.php

 

in the line 184 where it reads...

$subject = sprintf(Mail::l('Your message has been correctly sent #ct%1$s #tc%2$s'), $ct->id, $ct->token);

 

By reading the prestashop documentation about translation, it says that the email objects must use the following syntax in order to be translated

 

 

 

Mail::l('Your new admin password', (int)$id_lang)

The second parameter is mandatory. If it is absent, the mail will be sent with an object in the shop's default language.

 

So I tried modifying the line to be like that:

$subject = sprintf(Mail::l('Your message has been correctly sent #ct%1$s #tc%2$s',(int)$ct->id_lang), $ct->id, $ct->token);

 

but unfortunately it didn't appear in the translations again.

 

Also none of the message in the contactcontroller that use the $this->l(......) function appear on the translations... So my question is how do we translate this.......

Link to comment
Share on other sites

  • 1 month later...

Hi,

 

I've had the same issue and searched sometime to solve this.

It's documented at http://doc.prestasho...+PrestaShop+1.5 paragraph 'E-mail template translations'

 

/mails/iso_code/lang.php: for the default translations.

/themes/name_of_the_theme/mails/iso_code/lang.php: for each theme's translations

 

To translate the subject headers of mail messages generated by /controllers/front/ContactController.php look into the file /themes/name_of_the_theme/mails/iso_code/lang.php

 

This file contains translations of the mail subjects.

For the dutch language I've added the following lines to the file /themes/name_of_the_theme/mails/nl/lang.php to translate the ContactController.php generated e-mail messages:

 

$_LANGMAIL['Your message has been correctly sent #ct%1$s #tc%2$s'] = 'Uw bericht is verstuurd #ct%1$s #tc%2$s';
$_LANGMAIL['Your message has been correctly sent'] = 'Uw bericht is verstuurd';

 

 

!! BE AWARE !!

Always be aware to close each line with a semicolon ;. If you forget this tiny character, the complete site will fail to load when you upload the modified translation file!! If you get stuck into this nightmare, get yourself a strong cup of coffee because it might take you all night searching for this little character.

 

The default translation for in ContactController.php

$_LANGMAIL['Message from contact form\').\' [no_sync]'] = 'Bericht van contactenformulier\'). [no_sync]';

does not seem to work properly. Reduce this translation to the first section only

 

$_LANGMAIL['Message from contact form'] = 'Bericht van contactformulier';

This line only translates the first section of the subject line and works just fine.

 

Hope this answer will help someone save some time

Edited by Honingbij (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Should change to "/controllers/front/ContactController.php" this sentence:

$subject = sprintf(Mail::l('Your message has been correctly sent #ct%1$s #tc%2$s',(int)$ct->id_lang), $ct->id, $ct->token);

to this other:

$subject = sprintf(Mail::l('Your message has been correctly sent').' #ct%1$s #tc%2$s', $ct->id, $ct->token);

If you then also applies the changes will work correctly explains Honingbij

  • Like 1
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...