Jump to content

HTML code in translation string


Recommended Posts

Hi, I'd like to enclose a word of a translated string between strong tags, but the tags are printed as is on the frontend, I suppose htmlspecialchars() is used for the output. So I guess there is no way to insert html code in a translation text?

  • Like 1
Link to comment
Share on other sites

  • 5 months later...
  • 2 months later...

In prestashop 1.5

 

Modify the file : /controllers/admin/AdminTranslationsController.php

 

Replace the following line (line 814)

$str_write .= '$_MODULE['.$pattern.'] = \''.pSQL(str_replace(array("\r\n", "\r", "\n"), ' ', $_POST[$post_key])).'\';'."\n";

 

by

 

$str_write .= '$_MODULE['.$pattern.'] = \''.pSQL(str_replace(array("\r\n", "\r", "\n"), ' ', $_POST[$post_key]), true).'\';'."\n";

 

Adding "true" to the pSQL function.

 

Hope it help.

Link to comment
Share on other sites

Do not modify anything, that is a really bad idea, and a bad solution.

 

Simply don't use any <tags> in a translation function, just the text on the inside.

 

IE

{l s='Some text'} <strong>{l s='Some text in BOLD'}</stong> {l s='some more text....'}

  • Like 1
Link to comment
Share on other sites

Hi Tomerrg3, I undestand what you mean but is not realy useful. Every time we want to add/modify some <tags> we have to change the template file and some times the administartor/editor have no knowledge or basic knowledge about development. It's why I prefer let them adding <tags> from the backoffice.

 

I don't know if it's already possible to have a tinyMCE in a translation page but will be very useful.

Link to comment
Share on other sites

if you are going to go about it then try css and not html, your .tpl that can be modified from your translation, for example: This would be inserted in your .tpl file. Now from the back office you can by language modify your class some-text

 

  <div class=\"some-text\" style=\"
 {l s='font-family: inherit;'}
 {l s='margin-top: 20px;'}
 {l s='margin-right: 10px;'}
 {l s='margin-bottom: 0px;'}
 {l s='margin-left: 0px;'}
 {l s='line-height: 1;'}
 {l s='float: left;'}
 {l s='z-index: 1;'}\">
   </div>";

 

then your back office translation look's like this, (which you can now easily modify).

 

01.27.2013-10.04.53.png

http://screencast.com/t/QcKGXGFw

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

×
×
  • Create New...