Jump to content

Problems with translation of modules in custom theme


Recommended Posts

Hi there,


I'm having some issues with translating PrestaShop, or possibly finding the right page to translate.



I'm using a custom theme (still have the prestashop theme there too), and I'm offering dutch and english translations of the site, where dutch is default.


My theme overwrites a few modules (in theme/mytheme/modules), of course just the TPL files.


First question: Am I making a correct assumption that in order to translate the "custom" modules (they were only in english) I need to translate _every_ module that my theme is overwriting? Cause If I only translate 1 string (block header in my example, all the other translations are gone.


Second question: I have translated all the overwritten modules through the admin panel, and it seems to work correctly. However- All the other "block" modules are now in english on the frontend, whilst they are translated into dutch in the "prestashop" template language files. block_cms is not overwritten by my theme, so it should get the default translations, right?


Right now I can't translate it, unless I make a new folder /themes/mytheme/modules/block_cms and place the exact same content of the normal module.


I tried "copying the translations" from the default theme to my custom theme, but no joy.


Any help ?

Link to comment
Share on other sites

Hi Las3r,


I encountered the same issue monday... I developed my site on localhost for several months. (That is why my version is

I wanted to change 1 line in the language file ("the amount of" in "het bedrag van") via the backend interface. On refresh all the blocks modules where back in English. After some searching, the nl.php ( in /themes/mytheme/translations/) file seems to be completely empty. But on the backend I could clearly see all translations.


I tried copying the one from the prestashop theme to that one, the file was filled again, but the issue remained fir the block.


I really don't know what went wrong, and how to fix it.... So guys, any help would be great !

Link to comment
Share on other sites

experienced the same issue. It seems that the xx.php translation files within themes/xxx/modules are not correctly detected when copied from the /modules folder.


I managed to fix this. I added code to admin/tabs/AdminTranslation.php. It will look for alle empty strings in the theme/xxx/modules and try to find the /modules alternative.


The function to add just above public function displayFormModules($lang):


public function defaultThemeLanguage() {
foreach( $this->modules_translations as $theme => $modules ) {
  if( $theme != 'default' ) {
	foreach( $modules as $module => $templates) {
	  foreach( $templates as $template => $strings) {
		foreach( $strings as $string => $value ) {
		  if( $value == '' ) {
			if( $this->modules_translations['default'][$module][$template][$string] != '' ) {
			  $this->modules_translations[$theme][$module][$template][$string] = $this->modules_translations['default'][$module][$template][$string];


And in the function public function displayFormModules($lang) find the line

foreach ($arr_find_and_fill as $value)
   $this->findAndFillTranslations($value['files'], $value['theme'], $value['module'], $value['dir'], $lang);


and below this place this call:





This results in only replacing empty strings into matching originals. So it will not overwrite existing strings. In case you want to overwrite then you better delete the themes/xxx/modules/xxx/xx.php language files and then go into admin translations again to let this code replace the empty strings.

Link to comment
Share on other sites

  • 5 years later...

With prestashop I still have missing translations while the translation do exist in other modules. 


I've developed to find more translations when you go the the backoffice -> translations -> module translations. And then you should see more translations filled in and you should save the form as these are not yet saved before.


In the file controllers/admin/AdminTranslationsController.php

in the function public function initFormModules()

just before $this->tpl_view_vars

add this line:


And just before the function initFormModules() add these functions:

   protected function translationsByMd5() {
       $this->translationsByMd5 = array();
       $name_var = $this->translations_informations[$this->type_selected]['var'];

       foreach( $GLOBALS[$name_var] as $key => $value ) {
           if(!isset($this->translationsByMd5[$m[1]])) {
               $this->translationsByMd5[$m[1]] = $value;

   protected function drill() {
       foreach( $this->modules_translations as $theme_name => &$l1) {
           foreach( $l1 as $module_name => &$l2 ) {
               foreach( $l2 as $template_name => &$l3 ) {
                   foreach( $l3 as $key => &$l4 ) {
                       if(isset($l4['trad']) && $l4['trad'] == '' ) {
                           $keyMd5 = md5(preg_replace("/\\\*'/", "\'", $key) );
                           $l4['trad'] = $this->translationsByMd5[$keyMd5] ?: '';

   protected function refill() {

Link to comment
Share on other sites

  • 2 years later...

Hi shopimport.nl,


I'm on and I still have the issue.

I've made the change to the AdminTranslationsController.php file but in my situation, although I have already made the translation in the backoffice, it still doesn't shows up in the website.

Is this a common issue? Could you help me?




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...